Skip to content

Commit d44b520

Browse files
committed
Improve github workflow
* Cache gradle wrapper distributions * Don't always show gradle welcome message * Deduplicated code * Make it possible to select downloader and manually execute a run
1 parent b0cc9d4 commit d44b520

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: CI
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
downloaderType:
7+
description: 'Downloader Type'
8+
type: choice
9+
options:
10+
- MOCK
11+
- REAL
412
schedule:
513
# once per day
614
- cron: 0 0 * * *
@@ -24,6 +32,13 @@ jobs:
2432
with:
2533
java-version: '11'
2634
distribution: 'temurin'
35+
36+
- name: Cache Gradle wrapper dists
37+
uses: actions/cache@v4
38+
with:
39+
path: ~/.gradle/wrapper/dists
40+
key: ${{ runner.os }}-gradle-wrapper-dists-${{ hashFiles('gradle/wrapper/**') }}
41+
restore-keys: ${{ runner.os }}-gradle-wrapper-dists
2742

2843
- name: Cache Gradle dependencies
2944
uses: actions/cache@v4
@@ -35,14 +50,17 @@ jobs:
3550
# See gradle file for difference between downloaders
3651
- name: Build and run Tests
3752
run: |
53+
downloader_type="${{ github.event.inputs.downloaderType || 'MOCK' }}"
3854
if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then
39-
echo running with real downloader
40-
./gradlew check --stacktrace -Ddownloader=REAL
41-
else
42-
echo running with mock downloader
43-
./gradlew check --stacktrace -Ddownloader=MOCK
55+
downloader_type="REAL"
4456
fi
4557
58+
echo "Running with $downloader_type downloader"
59+
./gradlew check \
60+
-Dorg.gradle.welcome=never \
61+
--stacktrace \
62+
-Ddownloader=$downloader_type
63+
4664
- name: Upload test reports when failure occurs
4765
uses: actions/upload-artifact@v4
4866
if: failure()

0 commit comments

Comments
 (0)