Skip to content

Commit 17dd5ef

Browse files
authored
CI: cache java dependencies and ccm images (#326)
1 parent c7d60a5 commit 17dd5ef

File tree

1 file changed

+93
-3
lines changed

1 file changed

+93
-3
lines changed

.github/workflows/[email protected]

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,35 @@ jobs:
2828
java-version: ${{ matrix.java-version }}
2929
distribution: 'adopt'
3030

31+
- name: Get POM hash
32+
id: get-pom-hash
33+
run: echo "value=${{ hashFiles('**/pom.xml') }}" >> "$GITHUB_OUTPUT"
34+
35+
- name: Restore maven repository cache
36+
uses: actions/cache/restore@v4
37+
id: java-cache
38+
with:
39+
path: ~/.m2/repository
40+
key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ steps.get-pom-hash.outputs.value }}
41+
3142
- name: Compile source and tests
3243
run: mvn -B compile test-compile -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true
3344

45+
- name: Download test dependencies
46+
if: steps.java-cache.outputs.cache-hit != 'true'
47+
run: mvn -B test -Dtest=TestThatDoesNotExists -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true || true
48+
49+
- name: Download verify dependencies
50+
if: steps.java-cache.outputs.cache-hit != 'true'
51+
run: mvn -B verify -DskipTests || true
52+
53+
- name: Save maven repository cache
54+
uses: actions/cache/save@v4
55+
if: steps.java-cache.outputs.cache-hit != 'true'
56+
with:
57+
path: ~/.m2/repository
58+
key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ steps.get-pom-hash.outputs.value }}
59+
3460
verify:
3561
name: Full verify
3662
runs-on: ubuntu-latest
@@ -51,6 +77,12 @@ jobs:
5177
java-version: ${{ matrix.java-version }}
5278
distribution: 'adopt'
5379

80+
- name: Restore maven repository cache
81+
uses: actions/cache/restore@v4
82+
with:
83+
path: ~/.m2/repository
84+
key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }}
85+
5486
- name: Full verify
5587
run: mvn -B verify -DskipTests
5688

@@ -60,16 +92,27 @@ jobs:
6092
runs-on: ubuntu-latest
6193
timeout-minutes: 10
6294

95+
strategy:
96+
matrix:
97+
java-version: [8]
98+
fail-fast: false
99+
63100
steps:
64101
- name: Checkout source
65102
uses: actions/checkout@v2
66103

67104
- name: Set up JDK 8
68105
uses: actions/setup-java@v2
69106
with:
70-
java-version: '8'
107+
java-version: ${{ matrix.java-version }}
71108
distribution: 'adopt'
72109

110+
- name: Restore maven repository cache
111+
uses: actions/cache/restore@v4
112+
with:
113+
path: ~/.m2/repository
114+
key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }}
115+
73116
- name: Run unit tests
74117
run: mvn -B test -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true
75118

@@ -79,6 +122,7 @@ jobs:
79122
shopt -s globstar
80123
mkdir unit
81124
cp --parents ./**/target/*-reports/*.xml unit/
125+
82126
- name: Upload test results
83127
uses: actions/upload-artifact@v2
84128
if: success() || failure()
@@ -119,6 +163,7 @@ jobs:
119163
strategy:
120164
matrix:
121165
cassandra-version: ${{ fromJson(needs.setup-integration-tests.outputs.cassandra-integration-tests-versions) }}
166+
java-version: [8]
122167
fail-fast: false
123168

124169
steps:
@@ -128,9 +173,15 @@ jobs:
128173
- name: Set up JDK 8
129174
uses: actions/setup-java@v2
130175
with:
131-
java-version: '8'
176+
java-version: ${{ matrix.java-version }}
132177
distribution: 'adopt'
133178

179+
- name: Restore maven repository cache
180+
uses: actions/cache/restore@v4
181+
with:
182+
path: ~/.m2/repository
183+
key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }}
184+
134185
- name: Setup Python 3
135186
uses: actions/setup-python@v2
136187
with:
@@ -139,15 +190,31 @@ jobs:
139190
- name: Setup environment
140191
run: |
141192
pip3 install https://github.com/scylladb/scylla-ccm/archive/a93125bc6ad7dd5c9694331e89dc1fb212431ffe.zip
193+
194+
- name: Restore CCM image cache
195+
uses: actions/cache/restore@v4
196+
id: ccm-cache
197+
with:
198+
path: ~/.ccm/repository
199+
key: ccm-cassandra-${{ runner.os }}-${{ matrix.cassandra-version }}
200+
142201
- name: Run integration tests on Cassandra (${{ matrix.cassandra-version }})
143202
run: mvn -B -e verify -Dccm.version=${{ matrix.cassandra-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true
144203

204+
- name: Save CCM image cache
205+
uses: actions/cache/save@v4
206+
if: steps.ccm-cache.outputs.cache-hit != 'true'
207+
with:
208+
path: ~/.ccm/repository
209+
key: ccm-cassandra-${{ runner.os }}-${{ matrix.cassandra-version }}
210+
145211
- name: Copy test results
146212
if: success() || failure()
147213
run: |
148214
shopt -s globstar
149215
mkdir cassandra-${{ matrix.cassandra-version }}
150216
cp --parents ./**/target/*-reports/*.xml cassandra-${{ matrix.cassandra-version }}/
217+
151218
- name: Upload test results
152219
uses: actions/upload-artifact@v2
153220
if: success() || failure()
@@ -171,6 +238,7 @@ jobs:
171238
strategy:
172239
matrix:
173240
scylla-version: ${{ fromJson(needs.setup-integration-tests.outputs.scylla-integration-tests-versions) }}
241+
java-version: [8]
174242
fail-fast: false
175243

176244
steps:
@@ -180,9 +248,15 @@ jobs:
180248
- name: Set up JDK 8
181249
uses: actions/setup-java@v2
182250
with:
183-
java-version: '8'
251+
java-version: ${{ matrix.java-version }}
184252
distribution: 'adopt'
185253

254+
- name: Restore maven repository cache
255+
uses: actions/cache/restore@v4
256+
with:
257+
path: ~/.m2/repository
258+
key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }}
259+
186260
- name: Setup Python 3
187261
uses: actions/setup-python@v2
188262
with:
@@ -192,15 +266,31 @@ jobs:
192266
run: |
193267
pip3 install https://github.com/scylladb/scylla-ccm/archive/a93125bc6ad7dd5c9694331e89dc1fb212431ffe.zip
194268
sudo sh -c "echo 2097152 > /proc/sys/fs/aio-max-nr"
269+
270+
- name: Restore CCM image cache
271+
uses: actions/cache/restore@v4
272+
id: ccm-cache
273+
with:
274+
path: ~/.ccm/scylla-repository
275+
key: ccm-scylla-${{ runner.os }}-${{ matrix.scylla-version }}
276+
195277
- name: Run integration tests on Scylla (${{ matrix.scylla-version }})
196278
run: mvn -B verify -Dccm.version=${{ matrix.scylla-version }} -Dccm.scylla=true -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true
197279

280+
- name: Save CCM image cache
281+
uses: actions/cache/save@v4
282+
if: steps.ccm-cache.outputs.cache-hit != 'true'
283+
with:
284+
path: ~/.ccm/repository
285+
key: ccm-scylla-${{ runner.os }}-${{ matrix.scylla-version }}
286+
198287
- name: Copy test results
199288
if: success() || failure()
200289
run: |
201290
shopt -s globstar
202291
mkdir scylla-${{ matrix.scylla-version }}
203292
cp --parents ./**/target/*-reports/*.xml scylla-${{ matrix.scylla-version }}/
293+
204294
- name: Upload test results
205295
uses: actions/upload-artifact@v2
206296
if: success() || failure()

0 commit comments

Comments
 (0)