Skip to content

Commit 2167a19

Browse files
committed
chore: use a single shared Maven cache for all workflows
Part of #1656
1 parent 3e76317 commit 2167a19

6 files changed

+92
-13
lines changed

.github/workflows/deploy.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ jobs:
3636
with:
3737
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
3838
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
39-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
39+
40+
- name: Restore existing cache
41+
uses: actions/[email protected] # https://github.com/actions/cache
42+
with:
43+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
44+
key: maven-repository-${{ hashFiles('pom.xml') }}
45+
path: ~/.m2/repository
46+
restore-keys: maven-repository-
4047

4148
- name: Build WAR file
4249
# NOTE: we use -Dmaven.test.skip=true instead of -DskipUnitTests=true

.github/workflows/integration-tests-h2.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ jobs:
4545
with:
4646
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
4747
java-version: ${{ matrix.java-version }} # https://github.com/actions/setup-java#supported-version-syntax
48-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
48+
- name: Restore existing cache
49+
uses: actions/[email protected] # https://github.com/actions/cache
50+
with:
51+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
52+
key: maven-repository-${{ hashFiles('pom.xml') }}
53+
path: ~/.m2/repository
54+
restore-keys: maven-repository-
4955
- name: Run integration tests
5056
run: ./src/main/scripts/execute-command.sh integration-tests
5157
- name: Save RobotFramework reports

.github/workflows/integration-tests-mysql.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ jobs:
5757
with:
5858
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
5959
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
60-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
60+
- name: Restore existing cache
61+
uses: actions/[email protected] # https://github.com/actions/cache
62+
with:
63+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
64+
key: maven-repository-${{ hashFiles('pom.xml') }}
65+
path: ~/.m2/repository
66+
restore-keys: maven-repository-
6167
# This is a workaround for github action limitation: we can't specify command for the service (--character-set-server=utf8)
6268
# and have to modify database manually. See also:
6369
# https://github.com/actions/runner/discussions/1872 and https://github.com/orgs/community/discussions/26688

.github/workflows/integration-tests-postgres.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ jobs:
4848
with:
4949
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
5050
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
51-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
51+
- name: Restore existing cache
52+
uses: actions/[email protected] # https://github.com/actions/cache
53+
with:
54+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
55+
key: maven-repository-${{ hashFiles('pom.xml') }}
56+
path: ~/.m2/repository
57+
restore-keys: maven-repository-
5258
- name: Run integration tests
5359
env:
5460
SPRING_PROFILES_ACTIVE: postgres

.github/workflows/static-analysis.yml

+49-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ jobs:
3030
with:
3131
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
3232
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
33-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
33+
- name: Restore existing cache
34+
uses: actions/[email protected] # https://github.com/actions/cache
35+
with:
36+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
37+
key: maven-repository-${{ hashFiles('pom.xml') }}
38+
path: ~/.m2/repository
39+
restore-keys: maven-repository-
3440
- name: Run CheckStyle
3541
run: ./src/main/scripts/execute-command.sh checkstyle
3642

@@ -49,7 +55,13 @@ jobs:
4955
with:
5056
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
5157
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
52-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
58+
- name: Restore existing cache
59+
uses: actions/[email protected] # https://github.com/actions/cache
60+
with:
61+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
62+
key: maven-repository-${{ hashFiles('pom.xml') }}
63+
path: ~/.m2/repository
64+
restore-keys: maven-repository-
5365
- name: Run PMD
5466
run: ./src/main/scripts/execute-command.sh pmd
5567

@@ -68,7 +80,13 @@ jobs:
6880
with:
6981
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
7082
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
71-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
83+
- name: Restore existing cache
84+
uses: actions/[email protected] # https://github.com/actions/cache
85+
with:
86+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
87+
key: maven-repository-${{ hashFiles('pom.xml') }}
88+
path: ~/.m2/repository
89+
restore-keys: maven-repository-
7290
- name: Check license header
7391
run: ./src/main/scripts/execute-command.sh check-license
7492

@@ -87,7 +105,13 @@ jobs:
87105
with:
88106
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
89107
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
90-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
108+
- name: Restore existing cache
109+
uses: actions/[email protected] # https://github.com/actions/cache
110+
with:
111+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
112+
key: maven-repository-${{ hashFiles('pom.xml') }}
113+
path: ~/.m2/repository
114+
restore-keys: maven-repository-
91115
- name: Check pom.xml
92116
run: ./src/main/scripts/execute-command.sh check-pom
93117

@@ -192,7 +216,13 @@ jobs:
192216
with:
193217
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
194218
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
195-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
219+
- name: Restore existing cache
220+
uses: actions/[email protected] # https://github.com/actions/cache
221+
with:
222+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
223+
key: maven-repository-${{ hashFiles('pom.xml') }}
224+
path: ~/.m2/repository
225+
restore-keys: maven-repository-
196226
- name: Run maven-enforcer-plugin
197227
run: ./src/main/scripts/execute-command.sh enforcer
198228

@@ -211,7 +241,13 @@ jobs:
211241
with:
212242
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
213243
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
214-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
244+
- name: Restore existing cache
245+
uses: actions/[email protected] # https://github.com/actions/cache
246+
with:
247+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
248+
key: maven-repository-${{ hashFiles('pom.xml') }}
249+
path: ~/.m2/repository
250+
restore-keys: maven-repository-
215251
- name: Compile sources
216252
run: >-
217253
mvn \
@@ -237,7 +273,13 @@ jobs:
237273
with:
238274
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
239275
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
240-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
276+
- name: Restore existing cache
277+
uses: actions/[email protected] # https://github.com/actions/cache
278+
with:
279+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
280+
key: maven-repository-${{ hashFiles('pom.xml') }}
281+
path: ~/.m2/repository
282+
restore-keys: maven-repository-
241283
- name: Compile sources
242284
run: >-
243285
mvn \

.github/workflows/unit-tests.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ jobs:
3030
with:
3131
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
3232
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
33-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
33+
- name: Restore existing cache
34+
uses: actions/[email protected] # https://github.com/actions/cache
35+
with:
36+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
37+
key: maven-repository-${{ hashFiles('pom.xml') }}
38+
path: ~/.m2/repository
39+
restore-keys: maven-repository-
3440
- name: Run Jest
3541
run: ./src/main/scripts/execute-command.sh jest
3642

@@ -49,6 +55,12 @@ jobs:
4955
with:
5056
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
5157
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
52-
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
58+
- name: Restore existing cache
59+
uses: actions/[email protected] # https://github.com/actions/cache
60+
with:
61+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
62+
key: maven-repository-${{ hashFiles('pom.xml') }}
63+
path: ~/.m2/repository
64+
restore-keys: maven-repository-
5365
- name: Run unit tests
5466
run: ./src/main/scripts/execute-command.sh unit-tests

0 commit comments

Comments
 (0)