fpgradle-workflows/.github/workflows/build-and-test.yml
2024-06-16 02:45:16 +02:00

102 lines
No EOL
3.2 KiB
YAML

# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test
on:
workflow_call:
inputs:
timeout:
description: 'Timeout for runServer (seconds)'
required: false
default: 90
type: number
workspace:
description: 'setupCIWorkspace/setupDecompWorkspace'
required: false
default: "setupCIWorkspace"
type: string
client-only:
description: 'Do not execute runServer'
required: false
default: false
type: boolean
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Install Ubuntu dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y mesa-utils xvfb x11-xserver-utils
- name: Checkout mod repo
uses: actions/checkout@v4
- name: Checkout workflows repo
uses: actions/checkout@v4
with:
repository: FalsePattern/fpgradle-workflows
path: .fpgradle-workflows
fetch-depth: 0
- name: Set up JDK versions
uses: actions/setup-java@v4
with:
java-version: |
8
17
21
distribution: 'adopt'
cache: gradle
- name: Validate gradle wrapper checksum
uses: gradle/actions/wrapper-validation@v3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew --build-cache ${{ inputs.workspace }}
- name: Compile the mod
run: ./gradlew --build-cache assemble
- name: Attach compilation artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.repository_id }}-build-libs
path: build/libs/
retention-days: 31
- name: Run post-build checks
id: build_mod
run: xvfb-run --server-args="-screen 0 1366x768x24" ./gradlew --build-cache build
- name: Attach gradle reports
if: failure() && steps.build_mod.conclusion == 'failure'
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: ${{ github.repository_id }}-reports
path: build/reports/
retention-days: 31
- name: Run server for ${{ inputs.timeout }} seconds
if: ${{ !inputs.client-only }}
run: |
mkdir -p run
echo "eula=true" > run/eula.txt
# Set a constant seed with a village at spawn
echo "level-seed=-6202107849386030209\nonline-mode=true\n" > run/server.properties
echo "stop" > run/stop.txt
timeout ${{ inputs.timeout }} ./gradlew --build-cache runServer 2>&1 < run/stop.txt | tee -a server.log || true
- name: Test no errors reported during server run
if: ${{ !inputs.client-only }}
run: |
chmod +x .fpgradle-workflows/scripts/test_no_error_reports
.fpgradle-workflows/scripts/test_no_error_reports