Skip to content

Commit 05612b4

Browse files
committed
[CI] Use gradle/actions/setup-gradle action for caching Gradle dependencies.
1 parent d5ba0f6 commit 05612b4

File tree

4 files changed

+118
-158
lines changed

4 files changed

+118
-158
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ jobs:
3939
uses: actions/checkout@v4
4040
with:
4141
ref: ${{ github.sha }}
42-
- name: Cache Gradle dependencies
43-
uses: actions/cache@v4
44-
with:
45-
path: ~/.gradle/caches
46-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
47-
restore-keys: |
48-
${{ runner.os }}-gradle-
49-
- name: Cache Gradle wrappers
50-
uses: actions/cache@v4
51-
with:
52-
path: ~/.gradle/wrapper
53-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
5442
- name: Setup java
5543
uses: actions/setup-java@v4
5644
with:
@@ -68,11 +56,13 @@ jobs:
6856
java -Xinternalversion
6957
echo "BUILD_JAVA_HOME=$env:JAVA_HOME" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
7058
echo "BUILD_JAVA_VERSION=${{ matrix.java }}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
71-
- name: Setup java
59+
- name: Setup java to run Gradle
7260
uses: actions/setup-java@v4
7361
with:
7462
distribution: 'zulu'
7563
java-version: ${{ env.JAVA_VERSION }}
64+
- name: Setup Gradle
65+
uses: gradle/actions/setup-gradle@v4
7666
- name: Build with Gradle
7767
run: ./gradlew
7868
- name: Copy test logs
@@ -104,23 +94,18 @@ jobs:
10494
uses: actions/checkout@v4
10595
with:
10696
ref: ${{ github.sha }}
107-
- name: Cache Gradle dependencies
108-
uses: actions/cache@v4
109-
with:
110-
path: ~/.gradle/caches
111-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
112-
restore-keys: |
113-
${{ runner.os }}-gradle-
114-
- name: Cache Gradle wrappers
115-
uses: actions/cache@v4
116-
with:
117-
path: ~/.gradle/wrapper
118-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
11997
- name: Setup java to run Gradle script
12098
uses: actions/setup-java@v4
12199
with:
122100
distribution: 'zulu'
123101
java-version: ${{ env.JAVA_VERSION }}
102+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
103+
run: |
104+
java -Xinternalversion
105+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
106+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
107+
- name: Setup Gradle
108+
uses: gradle/actions/setup-gradle@v4
124109
- name: Cache NuGet dependencies
125110
uses: actions/cache@v4
126111
with:
@@ -155,18 +140,6 @@ jobs:
155140
uses: actions/checkout@v4
156141
with:
157142
ref: ${{ github.sha }}
158-
- name: Cache Gradle dependencies
159-
uses: actions/cache@v4
160-
with:
161-
path: ~/.gradle/caches
162-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
163-
restore-keys: |
164-
${{ runner.os }}-gradle-
165-
- name: Cache Gradle wrappers
166-
uses: actions/cache@v4
167-
with:
168-
path: ~/.gradle/wrapper
169-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
170143
- name: Install compiler
171144
run: |
172145
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ bionic main universe"
@@ -176,6 +149,13 @@ jobs:
176149
with:
177150
distribution: 'zulu'
178151
java-version: ${{ env.JAVA_VERSION }}
152+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
153+
run: |
154+
java -Xinternalversion
155+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
156+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
157+
- name: Setup Gradle
158+
uses: gradle/actions/setup-gradle@v4
179159
- name: Build
180160
run: ./cppbuild/cppbuild
181161

@@ -195,18 +175,6 @@ jobs:
195175
uses: actions/checkout@v4
196176
with:
197177
ref: ${{ github.sha }}
198-
- name: Cache Gradle dependencies
199-
uses: actions/cache@v4
200-
with:
201-
path: ~/.gradle/caches
202-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
203-
restore-keys: |
204-
${{ runner.os }}-gradle-
205-
- name: Cache Gradle wrappers
206-
uses: actions/cache@v4
207-
with:
208-
path: ~/.gradle/wrapper
209-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
210178
- name: Install compiler
211179
run: |
212180
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
@@ -217,6 +185,13 @@ jobs:
217185
with:
218186
distribution: 'zulu'
219187
java-version: ${{ env.JAVA_VERSION }}
188+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
189+
run: |
190+
java -Xinternalversion
191+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
192+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
193+
- name: Setup Gradle
194+
uses: gradle/actions/setup-gradle@v4
220195
- name: Build
221196
run: ./cppbuild/cppbuild
222197

@@ -236,18 +211,6 @@ jobs:
236211
uses: actions/checkout@v4
237212
with:
238213
ref: ${{ github.sha }}
239-
- name: Cache Gradle dependencies
240-
uses: actions/cache@v4
241-
with:
242-
path: ~/.gradle/caches
243-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
244-
restore-keys: |
245-
${{ runner.os }}-gradle-
246-
- name: Cache Gradle wrappers
247-
uses: actions/cache@v4
248-
with:
249-
path: ~/.gradle/wrapper
250-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
251214
- name: Install compiler
252215
run: |
253216
sudo mkdir -p /etc/apt/keyrings/
@@ -260,6 +223,13 @@ jobs:
260223
with:
261224
distribution: 'zulu'
262225
java-version: ${{ env.JAVA_VERSION }}
226+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
227+
run: |
228+
java -Xinternalversion
229+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
230+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
231+
- name: Setup Gradle
232+
uses: gradle/actions/setup-gradle@v4
263233
- name: Build
264234
run: ./cppbuild/cppbuild
265235

@@ -279,18 +249,6 @@ jobs:
279249
uses: actions/checkout@v4
280250
with:
281251
ref: ${{ github.sha }}
282-
- name: Cache Gradle dependencies
283-
uses: actions/cache@v4
284-
with:
285-
path: ~/.gradle/caches
286-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
287-
restore-keys: |
288-
${{ runner.os }}-gradle-
289-
- name: Cache Gradle wrappers
290-
uses: actions/cache@v4
291-
with:
292-
path: ~/.gradle/wrapper
293-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
294252
- name: Install compiler
295253
run: |
296254
sudo mkdir -p /etc/apt/keyrings/
@@ -303,6 +261,13 @@ jobs:
303261
with:
304262
distribution: 'zulu'
305263
java-version: ${{ env.JAVA_VERSION }}
264+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
265+
run: |
266+
java -Xinternalversion
267+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
268+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
269+
- name: Setup Gradle
270+
uses: gradle/actions/setup-gradle@v4
306271
- name: Build
307272
run: ./cppbuild/cppbuild
308273

@@ -322,23 +287,18 @@ jobs:
322287
uses: actions/checkout@v4
323288
with:
324289
ref: ${{ github.sha }}
325-
- name: Cache Gradle dependencies
326-
uses: actions/cache@v4
327-
with:
328-
path: ~/.gradle/caches
329-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
330-
restore-keys: |
331-
${{ runner.os }}-gradle-
332-
- name: Cache Gradle wrappers
333-
uses: actions/cache@v4
334-
with:
335-
path: ~/.gradle/wrapper
336-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
337290
- name: Setup java to run Gradle script
338291
uses: actions/setup-java@v4
339292
with:
340293
distribution: 'zulu'
341294
java-version: ${{ env.JAVA_VERSION }}
295+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
296+
run: |
297+
java -Xinternalversion
298+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
299+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
300+
- name: Setup Gradle
301+
uses: gradle/actions/setup-gradle@v4
342302
- name: Build
343303
run: cmake --version && ./cppbuild/cppbuild
344304

@@ -358,23 +318,18 @@ jobs:
358318
uses: actions/checkout@v4
359319
with:
360320
ref: ${{ github.sha }}
361-
- name: Cache Gradle dependencies
362-
uses: actions/cache@v4
363-
with:
364-
path: ~/.gradle/caches
365-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
366-
restore-keys: |
367-
${{ runner.os }}-gradle-
368-
- name: Cache Gradle wrappers
369-
uses: actions/cache@v4
370-
with:
371-
path: ~/.gradle/wrapper
372-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
373321
- name: Setup java to run Gradle script
374322
uses: actions/setup-java@v4
375323
with:
376324
distribution: 'zulu'
377325
java-version: ${{ env.JAVA_VERSION }}
326+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
327+
run: |
328+
java -Xinternalversion
329+
echo "BUILD_JAVA_HOME=$env:JAVA_HOME" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
330+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
331+
- name: Setup Gradle
332+
uses: gradle/actions/setup-gradle@v4
378333
- name: Build
379334
run: cppbuild/cppbuild.cmd
380335

@@ -391,18 +346,6 @@ jobs:
391346
uses: actions/checkout@v4
392347
with:
393348
ref: ${{ github.sha }}
394-
- name: Cache Gradle dependencies
395-
uses: actions/cache@v4
396-
with:
397-
path: ~/.gradle/caches
398-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
399-
restore-keys: |
400-
${{ runner.os }}-gradle-
401-
- name: Cache Gradle wrappers
402-
uses: actions/cache@v4
403-
with:
404-
path: ~/.gradle/wrapper
405-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
406349
- name: Rust setup
407350
uses: dtolnay/rust-toolchain@stable
408351
with:
@@ -412,6 +355,13 @@ jobs:
412355
with:
413356
distribution: 'zulu'
414357
java-version: ${{ env.JAVA_VERSION }}
358+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
359+
run: |
360+
java -Xinternalversion
361+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
362+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
363+
- name: Setup Gradle
364+
uses: gradle/actions/setup-gradle@v4
415365
- run: ./gradlew runRustTests
416366

417367
golang-build:
@@ -427,18 +377,6 @@ jobs:
427377
uses: actions/checkout@v4
428378
with:
429379
ref: ${{ github.sha }}
430-
- name: Cache Gradle dependencies
431-
uses: actions/cache@v4
432-
with:
433-
path: ~/.gradle/caches
434-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
435-
restore-keys: |
436-
${{ runner.os }}-gradle-
437-
- name: Cache Gradle wrappers
438-
uses: actions/cache@v4
439-
with:
440-
path: ~/.gradle/wrapper
441-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
442380
- name: Setup Go
443381
uses: actions/setup-go@v4
444382
with:
@@ -448,6 +386,13 @@ jobs:
448386
with:
449387
distribution: 'zulu'
450388
java-version: ${{ env.JAVA_VERSION }}
389+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
390+
run: |
391+
java -Xinternalversion
392+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
393+
echo "BUILD_JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
394+
- name: Setup Gradle
395+
uses: gradle/actions/setup-gradle@v4
451396
- name: Generate jar
452397
run: ./gradlew assemble
453398
- name: Run tests

0 commit comments

Comments
 (0)