build-and-test: individual jar uploads and spotless PR toggle (#62)

Co-authored-by: ah-OOG-ah <75745146+ah-OOG-ah@users.noreply.github.com>
This commit is contained in:
Robert 2026-05-21 16:43:45 -05:00 committed by GitHub
parent 23113b1bb8
commit 57b9aaba93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 68 additions and 13 deletions

View File

@ -21,6 +21,11 @@ on:
required: false required: false
default: false default: false
type: boolean type: boolean
disable-spotless-pr:
description: 'Do not run spotless PR task'
required: false
default: false
type: boolean
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@ -29,6 +34,10 @@ concurrency:
jobs: jobs:
build-and-test: build-and-test:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
outputs:
jar_matrix: ${{ steps.expose-jars.outputs.matrix }}
steps: steps:
- name: Install Ubuntu dependencies - name: Install Ubuntu dependencies
run: | run: |
@ -84,32 +93,26 @@ jobs:
- name: Compile the mod - name: Compile the mod
run: ./gradlew --build-cache --info --stacktrace assemble run: ./gradlew --build-cache --info --stacktrace assemble
- name: Attach compilation artifacts
uses: actions/upload-artifact@v5
with:
name: ${{ github.repository_id }}-build-libs
path: build/libs/
retention-days: 90
- name: Run post-build checks - name: Run post-build checks
id: build_mod id: build_mod
run: xvfb-run --server-args="-screen 0 1366x768x24" ./gradlew --build-cache --info --stacktrace build run: xvfb-run --server-args="-screen 0 1366x768x24" ./gradlew --build-cache --info --stacktrace build
- name: Attach gradle reports - name: Attach gradle reports
if: failure() && steps.build_mod.conclusion == 'failure' if: failure() && steps.build_mod.conclusion == 'failure'
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v7
continue-on-error: true continue-on-error: true
with: with:
name: ${{ github.repository_id }}-reports name: ${{ github.repository_id }}-reports
path: build/reports/ path: build/reports/
retention-days: 31 retention-days: 90
- name: Attempt to make a PR fixing spotless errors - name: Attempt to make a PR fixing spotless errors
if: >- if: >-
${{ failure() && steps.build_mod.conclusion == 'failure' ${{ !inputs.disable-spotless-pr &&
&& github.event_name == 'pull_request' failure() && steps.build_mod.conclusion == 'failure' &&
&& !github.event.pull_request.draft github.event_name == 'pull_request' &&
&& github.event.pull_request.head.repo.full_name == github.repository }} !github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository }}
run: | run: |
git reset --hard git reset --hard
git checkout "${PR_BRANCH}" git checkout "${PR_BRANCH}"
@ -172,3 +175,27 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }} PR_NUMBER: ${{ github.event.number }}
- name: Attach compilation artifacts as ZIP
uses: actions/upload-artifact@v7
with:
name: ${{ github.repository_id }}-build-libs
path: build/libs/
retention-days: 90
- name: Store the name of each built file
id: expose-jars
run: |
shopt -s nullglob
JAR_JSON=$(jq -n -c '$ARGS.positional' --args build/libs/*.jar)
echo "matrix=$JAR_JSON" >> "$GITHUB_OUTPUT"
run-individual-uploads:
needs: build-and-test
strategy:
fail-fast: false
matrix:
jar: ${{ fromJson(needs.build-and-test.outputs.jar_matrix) }}
uses: ./.github/workflows/upload-individual-jar.yml
with:
jar_path: ${{ matrix.jar }}

View File

@ -0,0 +1,28 @@
name: Upload individual JAR
on:
workflow_call:
inputs:
jar_path:
required: true
type: string
jobs:
upload-individual-jar:
runs-on: ubuntu-24.04
steps:
# In order to run this for all jars, we have to call it individually for each jar, on a separate job.
# Because dynamically running this workflow file requires a unique job run, we can't just grab the jars directly because they're already gone by then.
# We have to do this because unzipped upload can only be ran on one file (arbitrary restrictions 💢)
- name: Extract archive to retrieve artifact
uses: actions/download-artifact@v8
with:
name: ${{ github.repository_id }}-build-libs
path: build/libs
- name: Upload individual compilation artifact
uses: actions/upload-artifact@v7
with:
path: ${{ inputs.jar_path }}
retention-days: 90
archive: false