Skip to content

Commit 4938107

Browse files
authored
Merge branch 'master' into gha-buildscript-maintenance
2 parents 61dced5 + 28d59b9 commit 4938107

30 files changed

Lines changed: 609 additions & 920 deletions
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build Setup
2+
description: Setup for standard Java builds
3+
4+
inputs:
5+
update-cache:
6+
description: If cache should be updated
7+
required: false
8+
default: 'false'
9+
10+
runs:
11+
using: 'composite'
12+
13+
steps:
14+
# RetroFuturaGradle 2.x requires a Java 25 JDK to run the Gradle daemon.
15+
# The last listed version becomes JAVA_HOME (used by the daemon); 8 stays
16+
# available as a compilation toolchain. Jabel runs on the Java 25 toolchain.
17+
- name: Set up JDK 8 and 25
18+
uses: actions/setup-java@v5
19+
with:
20+
cache: gradle
21+
distribution: 'zulu'
22+
java-version: |
23+
8
24+
25
25+
26+
- name: Setup Gradle
27+
uses: gradle/actions/setup-gradle@v6
28+
with:
29+
cache-write-only: ${{ inputs.update-cache }}
30+
gradle-home-cache-includes: |
31+
caches
32+
caches/retro_futura_gradle
33+
notifications
34+
jdks
35+
wrapper
36+
37+
- name: Grant execute permission for gradlew
38+
shell: bash
39+
run: chmod +x gradlew

.github/workflows/build-packages.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Build and test the mod
2+
name: Build and test
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
target_branch:
8+
description: 'Target branch to build'
9+
required: false
10+
type: string
11+
timeout:
12+
description: 'Timeout for runServer (seconds)'
13+
required: false
14+
default: 90
15+
type: number
16+
client-only:
17+
description: 'Do not execute runServer'
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
concurrency:
23+
group: build-and-test-${{ inputs.target_branch || github.head_ref || github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
build-and-test:
28+
runs-on: ubuntu-latest
29+
30+
permissions:
31+
contents: write
32+
pull-requests: write
33+
34+
steps:
35+
- name: Checkout Repository
36+
uses: actions/checkout@v6
37+
with:
38+
ref: ${{ inputs.target_branch || github.ref }}
39+
40+
- name: Apply patch to buildscript.properties
41+
run: sed -i 's/debug_all = false/debug_all = true/g' buildscript.properties
42+
43+
- name: Setup Build
44+
uses: ./.github/actions/build_setup
45+
46+
- name: Compile the mod
47+
run: ./gradlew --info --scan --stacktrace assemble
48+
49+
- name: Upload Jars
50+
uses: actions/upload-artifact@v7
51+
with:
52+
name: plz_edit
53+
path: build/libs/*.jar
54+
retention-days: 31
55+
56+
- name: Run post-build checks
57+
id: build_mod
58+
run: ./gradlew --info build
59+
60+
- name: Attempt to make a PR fixing spotless errors
61+
if: ${{ failure() && steps.build_mod.conclusion == 'failure' && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
62+
run: |
63+
git reset --hard
64+
git checkout "${github.ref_name}"
65+
./gradlew --info spotlessApply || exit 1
66+
git diff --exit-code && exit 1
67+
git config user.name "GitHub Actions"
68+
git config user.email "<>"
69+
git switch -c "${FIXED_BRANCH}"
70+
git commit -am "spotlessApply"
71+
git push --force-with-lease origin "${FIXED_BRANCH}"
72+
gh pr create \
73+
--head "${FIXED_BRANCH}" \
74+
--base "${github.ref_name}" \
75+
--title "Spotless apply for branch ${{ github.event.pull_request.head.ref }} for #${{ github.event.pull_request.number }}" \
76+
--body "Automatic spotless apply to fix formatting errors, applies to PR #${{ github.event.pull_request.number }}" \
77+
2>&1 | tee pr-message.log || true
78+
gh pr comment "${github.ref_name}" -F pr-message.log || true
79+
shell: bash # ensures set -eo pipefail
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes
83+
84+
- name: Run server for ${{ inputs.timeout }} seconds
85+
if: ${{ !inputs.client-only }}
86+
run: |
87+
mkdir -p run
88+
echo "eula=true" > run/eula.txt
89+
# Set a constant seed with a village at spawn
90+
echo "stop" > run/stop.txt
91+
timeout ${{ inputs.timeout }} ./gradlew runServer 2>&1 < run/stop.txt | tee -a server.log || true
92+
93+
- name: Test no errors reported during server run
94+
if: ${{ !inputs.client-only }}
95+
run: |
96+
chmod +x ./scripts/test_no_error_reports.sh
97+
./scripts/test_no_error_reports.sh

.github/workflows/buildscript-maintenance.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/format_java.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Runs formatting requirements
2+
name: Java Formatting
3+
4+
on:
5+
pull_request:
6+
paths: ['src/main/java/**', 'src/test/**']
7+
8+
concurrency:
9+
group: format-${{ github.head_ref || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
formatting:
14+
name: Formatting
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
pull-requests: write
19+
contents: write
20+
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v6
24+
with:
25+
ref: ${{ github.head_ref }}
26+
27+
- name: Setup Build
28+
uses: ./.github/actions/build_setup
29+
30+
- name: Check if PR is from a fork
31+
id: fork-check
32+
run: |
33+
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
34+
echo "is_fork=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "is_fork=false" >> $GITHUB_OUTPUT
37+
fi
38+
shell: bash
39+
40+
- name: Run Spotless Formatting Check with Gradle
41+
id: build
42+
run: ./gradlew --info --stacktrace spotlessCheck
43+
44+
- name: Attempt to make a PR fixing spotless errors
45+
if: failure() && steps.build.conclusion == 'failure' && steps.fork-check.outputs.is_fork == 'false'
46+
run: |
47+
git reset --hard
48+
git checkout "${PR_BRANCH}"
49+
./gradlew --info spotlessApply || exit 1
50+
git diff --exit-code && exit 1
51+
git config user.name "GitHub Actions"
52+
git config user.email "<>"
53+
git switch -c "${FIXED_BRANCH}"
54+
git commit -am "spotlessApply"
55+
git push --force-with-lease origin "${FIXED_BRANCH}"
56+
gh pr create \
57+
--head "${FIXED_BRANCH}" \
58+
--base "${PR_BRANCH}" \
59+
--title "Spotless apply for branch ${PR_BRANCH} for #${PR_NUMBER}" \
60+
--body "Automatic spotless apply to fix formatting errors, applies to PR #${PR_NUMBER}" \
61+
2>&1 | tee pr-message.log || true
62+
gh pr comment "${PR_BRANCH}" -F pr-message.log || true
63+
shell: bash
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
67+
PR_NUMBER: ${{ github.event.pull_request.number }}
68+
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes
69+
70+
- name: Comment to PR if from fork and formatting failed
71+
if: failure() && steps.build.conclusion == 'failure' && steps.fork-check.outputs.is_fork == 'true'
72+
run: |
73+
gh pr comment ${{ github.event.pull_request.number }} --body "I can't get automatic fixes by spotless in CI. Please run './gradlew spotlessApply' and push again."
74+
env:
75+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test_java.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Runs tests
2+
name: Java Tests
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- '*'
8+
9+
concurrency:
10+
group: test-${{ github.head_ref || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: Tests
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v6
21+
22+
- name: Apply patch to buildscript.properties
23+
run: sed -i 's/debug_all = false/debug_all = true/g' buildscript.properties
24+
25+
- name: Setup Build
26+
uses: ./.github/actions/build_setup
27+
28+
- name: Run Tests with Gradle
29+
run: ./gradlew --info --scan --stacktrace test

0 commit comments

Comments
 (0)