From 61fb791be66c9bbeb7264a68c289b68811b4b811 Mon Sep 17 00:00:00 2001 From: object-Object Date: Sat, 13 Jul 2024 13:21:30 -0400 Subject: [PATCH 1/7] Remove gradle clean step --- .github/workflows/pr.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fadca52244..6a6de9e7f9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,14 +19,11 @@ jobs: distribution: temurin java-version: "17.0.1" - uses: gradle/actions/setup-gradle@v3 - - - name: Clean - run: | - chmod +x gradlew - ./gradlew clean - name: Build - run: ./gradlew build + run: | + chmod +x gradlew + ./gradlew build - name: Run Datagen run: ./gradlew runAllDatagen From 6fdb3447eb58f2e051db9839422aa0b8b72e4a01 Mon Sep 17 00:00:00 2001 From: object-Object Date: Sat, 13 Jul 2024 13:43:23 -0400 Subject: [PATCH 2/7] Use nick-fields/retry action to work around intermittent ForgeGradle asset download failures --- .github/workflows/pr.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6a6de9e7f9..e4e5a10143 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,8 +25,14 @@ jobs: chmod +x gradlew ./gradlew build + # ForgeGradle datagen asset download often fails (see #692) + # so just allow it to automatically retry a few times - name: Run Datagen - run: ./gradlew runAllDatagen + uses: nick-fields/retry@v3 + with: + timeout_minutes: 10 + max_attempts: 3 + command: ./gradlew runAllDatagen - name: Check Datagen run: | From 44e28dcf602083f93befe3bf9de0259f4026325a Mon Sep 17 00:00:00 2001 From: object-Object Date: Wed, 21 Aug 2024 13:28:55 -0400 Subject: [PATCH 3/7] Add step to upload build artifacts --- .github/workflows/pr.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e4e5a10143..65faa334d7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,6 +39,14 @@ jobs: git add --intent-to-add . git diff --name-only --exit-code -- ":!:*/src/generated/resources/.cache/*" + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + path: | + Common/build/libs/*.jar + Forge/build/libs/*.jar + Fabric/build/libs/*.jar + hexdoc: uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@main permissions: From d573eb5569935a2681a2998937a1fe74e86ecbc0 Mon Sep 17 00:00:00 2001 From: object-Object Date: Wed, 21 Aug 2024 13:37:08 -0400 Subject: [PATCH 4/7] Trigger Gradle build on pushes to the default branch so the cache stays up to date --- .github/workflows/pr.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 65faa334d7..f46da44336 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,6 +6,9 @@ name: Build pull request on: pull_request: workflow_dispatch: + # trigger on pushes to the default branch (main) to keep the cache up to date + push: + branches: main jobs: build: @@ -48,6 +51,8 @@ jobs: Fabric/build/libs/*.jar hexdoc: + # don't bother running the docs build when pushing to main - nothing necessary to cache here + if: github.event_name != 'push' uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@main permissions: contents: write From b880aa86177e894419e386aa803df855f0dc5d7d Mon Sep 17 00:00:00 2001 From: object-Object Date: Wed, 21 Aug 2024 15:21:23 -0400 Subject: [PATCH 5/7] Flatten build artifact structure and add artifact name --- .github/workflows/pr.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f46da44336..276bf89fdc 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -30,25 +30,28 @@ jobs: # ForgeGradle datagen asset download often fails (see #692) # so just allow it to automatically retry a few times - - name: Run Datagen + - name: Run datagen uses: nick-fields/retry@v3 with: timeout_minutes: 10 max_attempts: 3 command: ./gradlew runAllDatagen - - name: Check Datagen + - name: Check datagen run: | git add --intent-to-add . git diff --name-only --exit-code -- ":!:*/src/generated/resources/.cache/*" - - name: Upload Artifacts + - name: Prepare artifacts for upload + run: | + mkdir -p dist + cp {Common,Forge,Fabric}/build/libs/*.jar dist + + - name: Upload artifacts uses: actions/upload-artifact@v4 with: - path: | - Common/build/libs/*.jar - Forge/build/libs/*.jar - Fabric/build/libs/*.jar + name: mod-build + path: dist hexdoc: # don't bother running the docs build when pushing to main - nothing necessary to cache here From 9fdef827e125bd05805bebb6fd546ea3f00e4892 Mon Sep 17 00:00:00 2001 From: object-Object Date: Wed, 21 Aug 2024 15:35:42 -0400 Subject: [PATCH 6/7] Try running build and datagen in parallel --- .github/workflows/pr.yml | 43 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 276bf89fdc..a7b57c0fa8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,6 +10,9 @@ on: push: branches: main +env: + JAVA_VERSION: '17.0.1' + jobs: build: runs-on: ubuntu-latest @@ -20,7 +23,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: temurin - java-version: "17.0.1" + java-version: ${{ env.JAVA_VERSION }} - uses: gradle/actions/setup-gradle@v3 - name: Build @@ -28,6 +31,29 @@ jobs: chmod +x gradlew ./gradlew build + - name: Prepare artifacts for upload + run: | + mkdir -p dist + cp {Common,Forge,Fabric}/build/libs/*.jar dist + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: mod-build + path: dist + + datagen: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ env.JAVA_VERSION }} + - uses: gradle/actions/setup-gradle@v3 + # ForgeGradle datagen asset download often fails (see #692) # so just allow it to automatically retry a few times - name: Run datagen @@ -35,24 +61,15 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: ./gradlew runAllDatagen + command: | + chmod +x gradlew + ./gradlew runAllDatagen - name: Check datagen run: | git add --intent-to-add . git diff --name-only --exit-code -- ":!:*/src/generated/resources/.cache/*" - - name: Prepare artifacts for upload - run: | - mkdir -p dist - cp {Common,Forge,Fabric}/build/libs/*.jar dist - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: mod-build - path: dist - hexdoc: # don't bother running the docs build when pushing to main - nothing necessary to cache here if: github.event_name != 'push' From ca02f95a634a3d3414cde7c724b6f7ea8af0ae70 Mon Sep 17 00:00:00 2001 From: object-Object Date: Wed, 21 Aug 2024 15:47:51 -0400 Subject: [PATCH 7/7] Add 30-day retention period to mod-build artifact --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a7b57c0fa8..2600ad5068 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -41,6 +41,7 @@ jobs: with: name: mod-build path: dist + retention-days: 30 datagen: runs-on: ubuntu-latest