Skip to content

Commit 251594a

Browse files
committed
Improve caching and remove excessive whitespaces
* Add dedicated caching for pmd and checkstyle * Isolate caching between different goals * Do read-only caching in release workflow on NON-CRITICAL steps
1 parent 2d5dbbb commit 251594a

File tree

3 files changed

+78
-29
lines changed

3 files changed

+78
-29
lines changed

.github/workflows/check-build.yml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,30 @@ jobs:
2626
build:
2727
runs-on: ubuntu-latest
2828
timeout-minutes: 30
29-
3029
strategy:
3130
matrix:
3231
java: [17, 21]
3332
distribution: [temurin]
34-
3533
steps:
3634
- uses: actions/checkout@v5
37-
35+
3836
- name: Set up JDK
3937
uses: actions/setup-java@v5
4038
with:
4139
distribution: ${{ matrix.distribution }}
4240
java-version: ${{ matrix.java }}
43-
cache: 'maven'
44-
41+
42+
- name: Cache Maven
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.m2/repository
46+
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
47+
restore-keys: |
48+
${{ runner.os }}-mvn-build-
49+
4550
- name: Build with Maven
4651
run: ./mvnw -B clean package
47-
52+
4853
- name: Check for uncommited changes
4954
run: |
5055
if [[ "$(git status --porcelain)" != "" ]]; then
@@ -74,21 +79,34 @@ jobs:
7479
runs-on: ubuntu-latest
7580
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
7681
timeout-minutes: 15
77-
7882
strategy:
7983
matrix:
8084
java: [17]
8185
distribution: [temurin]
82-
8386
steps:
8487
- uses: actions/checkout@v5
85-
88+
8689
- name: Set up JDK
8790
uses: actions/setup-java@v5
8891
with:
8992
distribution: ${{ matrix.distribution }}
9093
java-version: ${{ matrix.java }}
91-
cache: 'maven'
94+
95+
- name: Cache Maven
96+
uses: actions/cache@v4
97+
with:
98+
path: ~/.m2/repository
99+
key: ${{ runner.os }}-mvn-checkstyle-${{ hashFiles('**/pom.xml') }}
100+
restore-keys: |
101+
${{ runner.os }}-mvn-checkstyle-
102+
103+
- name: CheckStyle Cache
104+
uses: actions/cache@v4
105+
with:
106+
path: '**/target/checkstyle-cachefile'
107+
key: ${{ runner.os }}-checkstyle-${{ hashFiles('**/pom.xml') }}
108+
restore-keys: |
109+
${{ runner.os }}-checkstyle-
92110
93111
- name: Run Checkstyle
94112
run: ./mvnw -B checkstyle:check -P checkstyle -T2C
@@ -97,12 +115,10 @@ jobs:
97115
runs-on: ubuntu-latest
98116
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
99117
timeout-minutes: 15
100-
101118
strategy:
102119
matrix:
103120
java: [17]
104121
distribution: [temurin]
105-
106122
steps:
107123
- uses: actions/checkout@v5
108124

@@ -111,7 +127,22 @@ jobs:
111127
with:
112128
distribution: ${{ matrix.distribution }}
113129
java-version: ${{ matrix.java }}
114-
cache: 'maven'
130+
131+
- name: Cache Maven
132+
uses: actions/cache@v4
133+
with:
134+
path: ~/.m2/repository
135+
key: ${{ runner.os }}-mvn-pmd-${{ hashFiles('**/pom.xml') }}
136+
restore-keys: |
137+
${{ runner.os }}-mvn-pmd-
138+
139+
- name: PMD Cache
140+
uses: actions/cache@v4
141+
with:
142+
path: '**/target/pmd/pmd.cache'
143+
key: ${{ runner.os }}-pmd-${{ hashFiles('**/pom.xml') }}
144+
restore-keys: |
145+
${{ runner.os }}-pmd-
115146
116147
- name: Run PMD
117148
run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C

.github/workflows/release.yml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,30 @@ permissions:
1111
contents: write
1212
pull-requests: write
1313

14+
# DO NOT RESTORE CACHE for critical release steps to prevent a (extremely unlikely) scenario
15+
# where a supply chain attack could be achieved due to poisoned cache
1416
jobs:
1517
check-code:
1618
runs-on: ubuntu-latest
1719
timeout-minutes: 30
1820
steps:
1921
- uses: actions/checkout@v5
20-
22+
2123
- name: Set up JDK
2224
uses: actions/setup-java@v5
2325
with:
2426
java-version: '17'
2527
distribution: 'temurin'
26-
cache: 'maven'
27-
28+
29+
# Try to reuse existing cache from check-build
30+
- name: Try restore Maven Cache
31+
uses: actions/cache/restore@v4
32+
with:
33+
path: ~/.m2/repository
34+
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: |
36+
${{ runner.os }}-mvn-build-
37+
2838
- name: Build with Maven
2939
run: ./mvnw -B clean package -T2C
3040

@@ -54,31 +64,31 @@ jobs:
5464
upload_url: ${{ steps.create-release.outputs.upload_url }}
5565
steps:
5666
- uses: actions/checkout@v5
57-
67+
5868
- name: Configure Git
5969
run: |
6070
git config --global user.email "[email protected]"
6171
git config --global user.name "GitHub Actions"
62-
72+
6373
- name: Un-SNAP
6474
run: ./mvnw -B versions:set -DremoveSnapshot -DprocessAllModules -DgenerateBackupPoms=false
65-
75+
6676
- name: Get version
6777
id: version
6878
run: |
6979
version=$(../mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
7080
echo "release=$version" >> $GITHUB_OUTPUT
7181
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
7282
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
73-
83+
7484
- name: Commit and Push
7585
run: |
7686
git add -A
7787
git commit -m "Release ${{ steps.version.outputs.release }}"
7888
git push origin
7989
git tag v${{ steps.version.outputs.release }}
8090
git push origin --tags
81-
91+
8292
- name: Create Release
8393
id: create-release
8494
uses: shogo82148/actions-create-release@4661dc54f7b4b564074e9fbf73884d960de569a3 # v1
@@ -106,7 +116,7 @@ jobs:
106116
timeout-minutes: 60
107117
steps:
108118
- uses: actions/checkout@v5
109-
119+
110120
- name: Init Git and pull
111121
run: |
112122
git config --global user.email "[email protected]"
@@ -122,7 +132,7 @@ jobs:
122132
server-password: PACKAGES_CENTRAL_TOKEN
123133
gpg-passphrase: MAVEN_GPG_PASSPHRASE
124134
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Only import once
125-
135+
126136
- name: Publish to GitHub Packages Central
127137
run: ../mvnw -B deploy -P publish -DskipTests -DaltDeploymentRepository=github-central::https://maven.pkg.github.com/xdev-software/central
128138
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
@@ -154,7 +164,7 @@ jobs:
154164
timeout-minutes: 15
155165
steps:
156166
- uses: actions/checkout@v5
157-
167+
158168
- name: Init Git and pull
159169
run: |
160170
git config --global user.email "[email protected]"
@@ -166,7 +176,15 @@ jobs:
166176
with:
167177
java-version: '17'
168178
distribution: 'temurin'
169-
cache: 'maven'
179+
180+
# Try to reuse existing cache from check-build
181+
- name: Try restore Maven Cache
182+
uses: actions/cache/restore@v4
183+
with:
184+
path: ~/.m2/repository
185+
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
186+
restore-keys: |
187+
${{ runner.os }}-mvn-build-
170188
171189
- name: Build site
172190
run: ../mvnw -B compile site -DskipTests -T2C
@@ -185,7 +203,7 @@ jobs:
185203
timeout-minutes: 10
186204
steps:
187205
- uses: actions/checkout@v5
188-
206+
189207
- name: Init Git and pull
190208
run: |
191209
git config --global user.email "[email protected]"
@@ -200,7 +218,7 @@ jobs:
200218
git add -A
201219
git commit -m "Preparing for next development iteration"
202220
git push origin
203-
221+
204222
- name: pull-request
205223
env:
206224
GH_TOKEN: ${{ github.token }}

.github/workflows/test-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
server-password: PACKAGES_CENTRAL_TOKEN
2323
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2424
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Only import once
25-
25+
2626
- name: Publish to GitHub Packages Central
2727
run: ../mvnw -B deploy -P publish -DskipTests -DaltDeploymentRepository=github-central::https://maven.pkg.github.com/xdev-software/central
2828
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
2929
env:
3030
PACKAGES_CENTRAL_TOKEN: ${{ secrets.PACKAGES_CENTRAL_TOKEN }}
3131
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
32-
32+
3333
- name: Set up JDK
3434
uses: actions/setup-java@v5
3535
with: # running setup-java again overwrites the settings.xml

0 commit comments

Comments
 (0)