Skip to content

Commit 785e4a6

Browse files
authored
ci: update action configuration (#1214)
### Motivation The current action configuration does no longer properly keep up with our requirements. ### Modification A list of all modifications: * There are no longer caches stored for each branch. While the action will be able to restore a cache, it's always based on nightly and only the nightly branch will update the cache. This should reduce the amount of stored caches. * The `gradle-build-action` is now used to manage the caches. The action manages the cache way better than the current, default configuration for gradle caches shipped with the `setup-java` action. * A specified action step was added that just caches the created Fabric Loom cache. The cache restore is based on the dependency versions and gradle version (it doesn't seems like there is a better way to cache the loom output rather than based off on all dependencies). * An action step was added that attaches the test results to pull requests and the workflow run. * Both CodeQL and the Maven Central publish action now use the read-only gradle cache as well. * The build process is no longer executed on Java 19 alongside Java 17. This will be re-enabled when Kotlin finally supports Java 20 or 21, and it actually makes sense again to test. ### Result Faster build times and a better action configuration.
1 parent 034f17a commit 785e4a6

File tree

3 files changed

+43
-19
lines changed

3 files changed

+43
-19
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
- cron: '00 2 * * *'
77

88
concurrency:
9-
group: cq-${{ github.event.pull_request.number || github.job }}
109
cancel-in-progress: true
10+
group: cq-${{ github.event.pull_request.number || github.job }}
1111

1212
jobs:
1313
analyze:
@@ -22,10 +22,14 @@ jobs:
2222
- name: Setup java
2323
uses: actions/setup-java@v3
2424
with:
25-
distribution: 'zulu'
2625
java-version: 17
2726
check-latest: true
28-
cache: 'gradle'
27+
distribution: 'zulu'
28+
29+
- name: Setup gradle cache
30+
uses: gradle/gradle-build-action@v2
31+
with:
32+
cache-read-only: true
2933

3034
- name: Initialize CodeQL
3135
uses: github/codeql-action/init@v2

.github/workflows/gradle-release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ jobs:
2020
- name: Setup java
2121
uses: actions/setup-java@v3
2222
with:
23-
distribution: 'zulu'
2423
java-version: 17
2524
check-latest: true
26-
cache: 'gradle'
25+
distribution: 'zulu'
26+
27+
- name: Setup gradle cache
28+
uses: gradle/gradle-build-action@v2
29+
with:
30+
cache-read-only: true
2731

2832
- name: Publish release to Sonatype
2933
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository

.github/workflows/gradle.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
merge_group:
1010

1111
concurrency:
12-
group: build-${{ github.event.pull_request.number || github.ref }}
1312
cancel-in-progress: true
13+
group: build-${{ github.event.pull_request.number || github.ref }}
1414

1515
jobs:
1616
build:
@@ -21,33 +21,49 @@ jobs:
2121
matrix:
2222
java:
2323
- 17
24-
- 19
2524

2625
steps:
2726
- name: Checkout repository
2827
uses: actions/checkout@v3
2928

30-
- name: Get branch name
31-
id: branch-name
32-
uses: tj-actions/branch-names@v6
33-
3429
- name: Validate gradle wrapper
3530
uses: gradle/wrapper-validation-action@v1
3631

3732
- name: Setup java
3833
uses: actions/setup-java@v3
3934
with:
35+
check-latest: true
4036
distribution: 'zulu'
4137
java-version: ${{ matrix.java }}
42-
check-latest: true
43-
cache: 'gradle'
4438

45-
- name: Run build lifecycle
46-
run: ./gradlew build test shadowJar genUpdaterInformation --no-daemon --stacktrace
39+
- name: Setup gradle cache
40+
uses: gradle/gradle-build-action@v2
41+
with:
42+
cache-read-only: ${{ github.ref != 'refs/heads/nightly' || matrix.java != 17 }}
43+
44+
- name: Setup Loom cache
45+
uses: actions/cache@v3
46+
with:
47+
path: '.gradle/loom-cache'
48+
restore-keys: ${{ runner.os }}-gradle-loom-
49+
key: ${{ runner.os }}-gradle-loom-${{ hashFiles('gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }}
50+
51+
- name: Execute build and tests
52+
run: ./gradlew build test shadowJar genUpdaterInformation --stacktrace
53+
54+
- name: Publish test summary
55+
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && matrix.java == 17 }}
56+
uses: EnricoMi/publish-unit-test-result-action@v2
57+
with:
58+
junit_files: "**/build/test-results/test/TEST-*.xml"
59+
60+
- name: Get branch name
61+
id: branch-name
62+
uses: tj-actions/branch-names@v6
4763

4864
- name: Publish updater metadata
4965
uses: s0/git-publish-subdir-action@develop
50-
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/heads/renovate/') && matrix.java == 17 }}
66+
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/heads/renovate/') && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && matrix.java == 17 }}
5167
env:
5268
REPO: git@github.com:CloudNetService/launchermeta.git
5369
BRANCH: ${{ steps.branch-name.outputs.current_branch }}
@@ -68,14 +84,14 @@ jobs:
6884
fi
6985
7086
- name: Publish snapshot to Sonatype
71-
if: ${{ github.event_name == 'push' && env.STATUS != 'release' && startsWith(github.ref, 'refs/heads/nightly') && matrix.java == 17 }}
87+
if: ${{ github.event_name == 'push' && env.STATUS != 'release' && startsWith(github.ref, 'refs/heads/nightly') && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && matrix.java == 17 }}
7288
run: ./gradlew publish
7389
env:
7490
SONATYPE_USER: "${{ secrets.SONATYPE_USER }}"
7591
SONATYPE_TOKEN: "${{ secrets.SONATYPE_TOKEN }}"
7692

7793
- name: Prepare artifacts zip
78-
if: ${{ github.event_name == 'push' && matrix.java == 17 }}
94+
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && matrix.java == 17 }}
7995
run: |
8096
mkdir -p temp/;
8197
mkdir -p temp/plugins;
@@ -88,7 +104,7 @@ jobs:
88104
89105
- name: Upload artifacts zip
90106
uses: actions/upload-artifact@v3
91-
if: ${{ github.event_name == 'push' && matrix.java == 17 }}
107+
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && matrix.java == 17 }}
92108
with:
93109
name: CloudNet
94110
path: temp/

0 commit comments

Comments
 (0)