mirror of
https://github.com/GTNewHorizons/GTNH-Actions-Workflows.git
synced 2026-05-30 05:49:55 +02:00
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:
parent
23113b1bb8
commit
57b9aaba93
53
.github/workflows/build-and-test.yml
vendored
53
.github/workflows/build-and-test.yml
vendored
@ -21,6 +21,11 @@ on:
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
disable-spotless-pr:
|
||||
description: 'Do not run spotless PR task'
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
@ -29,6 +34,10 @@ concurrency:
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
outputs:
|
||||
jar_matrix: ${{ steps.expose-jars.outputs.matrix }}
|
||||
|
||||
steps:
|
||||
- name: Install Ubuntu dependencies
|
||||
run: |
|
||||
@ -84,32 +93,26 @@ jobs:
|
||||
- name: Compile the mod
|
||||
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
|
||||
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@v5
|
||||
uses: actions/upload-artifact@v7
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: ${{ github.repository_id }}-reports
|
||||
path: build/reports/
|
||||
retention-days: 31
|
||||
retention-days: 90
|
||||
|
||||
- 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
|
||||
&& github.event.pull_request.head.repo.full_name == github.repository }}
|
||||
${{ !inputs.disable-spotless-pr &&
|
||||
failure() && steps.build_mod.conclusion == 'failure' &&
|
||||
github.event_name == 'pull_request' &&
|
||||
!github.event.pull_request.draft &&
|
||||
github.event.pull_request.head.repo.full_name == github.repository }}
|
||||
run: |
|
||||
git reset --hard
|
||||
git checkout "${PR_BRANCH}"
|
||||
@ -172,3 +175,27 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
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 }}
|
||||
|
||||
28
.github/workflows/upload-individual-jar.yml
vendored
Normal file
28
.github/workflows/upload-individual-jar.yml
vendored
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user