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
This commit is contained in:
litetex 2025-02-16 22:26:00 +01:00
parent b0cc9d47ce
commit d44b520a90
No known key found for this signature in database
GPG Key ID: 525B43E6039B3689

View File

@ -1,6 +1,14 @@
name: CI name: CI
on: on:
workflow_dispatch:
inputs:
downloaderType:
description: 'Downloader Type'
type: choice
options:
- MOCK
- REAL
schedule: schedule:
# once per day # once per day
- cron: 0 0 * * * - cron: 0 0 * * *
@ -24,6 +32,13 @@ jobs:
with: with:
java-version: '11' java-version: '11'
distribution: 'temurin' distribution: 'temurin'
- name: Cache Gradle wrapper dists
uses: actions/cache@v4
with:
path: ~/.gradle/wrapper/dists
key: ${{ runner.os }}-gradle-wrapper-dists-${{ hashFiles('gradle/wrapper/**') }}
restore-keys: ${{ runner.os }}-gradle-wrapper-dists
- name: Cache Gradle dependencies - name: Cache Gradle dependencies
uses: actions/cache@v4 uses: actions/cache@v4
@ -35,14 +50,17 @@ jobs:
# See gradle file for difference between downloaders # See gradle file for difference between downloaders
- name: Build and run Tests - name: Build and run Tests
run: | run: |
downloader_type="${{ github.event.inputs.downloaderType || 'MOCK' }}"
if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then
echo running with real downloader downloader_type="REAL"
./gradlew check --stacktrace -Ddownloader=REAL
else
echo running with mock downloader
./gradlew check --stacktrace -Ddownloader=MOCK
fi fi
echo "Running with $downloader_type downloader"
./gradlew check \
-Dorg.gradle.welcome=never \
--stacktrace \
-Ddownloader=$downloader_type
- name: Upload test reports when failure occurs - name: Upload test reports when failure occurs
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
if: failure() if: failure()