Skip to content

[1.21.1-NEO] Basic support for AdvancedAE #154

[1.21.1-NEO] Basic support for AdvancedAE

[1.21.1-NEO] Basic support for AdvancedAE #154

Workflow file for this run

name: Build and test
on:
pull_request:
branches: [ 1.21.1 ]
push:
branches: [ 1.21.1 ]
jobs:
build-and-test:
runs-on: ubuntu-24.04
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
with:
fetch-depth: 0
- name: Checkout workflows repo
uses: actions/checkout@v4
with:
repository: GTNewHorizons/GTNH-Actions-Workflows
path: .gtnh-workflows
fetch-depth: 0
- name: Set up JDK versions
uses: actions/setup-java@v4
with:
java-version: |
17
21
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"
validate-wrappers: true
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Compile the mod
run: ./gradlew --build-cache --info --stacktrace assemble
- name: Attach compilation artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.repository_id }}-build-libs
path: build/libs/
retention-days: 90
- name: Run post-build checks
id: build_mod
run: xvfb-run --server-args="-screen 0 1366x768x24" ./gradlew --build-cache --info --stacktrace 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: Attempt to make a PR fixing spotless errors
if: ${{ failure() && steps.build_mod.conclusion == 'failure' && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
run: |
git reset --hard
git checkout "${PR_BRANCH}"
./gradlew --build-cache --info --stacktrace spotlessApply || exit 1
git diff --exit-code && exit 1
git config user.name "GitHub GTNH Actions"
git config user.email "<>"
git switch -c "${FIXED_BRANCH}"
git commit -am "spotlessApply"
git push --force-with-lease origin "${FIXED_BRANCH}"
gh pr create \
--head "${FIXED_BRANCH}" \
--base "${PR_BRANCH}" \
--title "Spotless apply for branch ${PR_BRANCH} for #${{ github.event.pull_request.number }}" \
--body "Automatic spotless apply to fix formatting errors, applies to PR #${{ github.event.pull_request.number }}" \
2>&1 | tee pr-message.log || true
gh pr comment "${PR_BRANCH}" -F pr-message.log || true
shell: bash # ensures set -eo pipefail
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BRANCH: ${{ github.head_ref }}
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes
# - name: Run server for up to 90 seconds
# # if: ${{ !inputs.client-only }}
# run: |
# mkdir -p run/server
# echo "eula=true" > run/server/eula.txt
# # Set a constant seed with a village at spawn
# echo "level-seed=-6202107849386030209\nonline-mode=true\n" > run/server/server.properties
# echo "stop" > run/server/stop.txt
# timeout 90 ./gradlew --build-cache --info --stacktrace runServer 2>&1 < run/server/stop.txt | tee -a server.log || true
# - name: Test no errors reported during server run
# # if: ${{ !inputs.client-only }}
# run: |
# chmod +x .gtnh-workflows/scripts/test_no_error_reports
# .gtnh-workflows/scripts/test_no_error_reports