Skip to content

Commit

Permalink
Replace ./gradlew with gradle-build-action on CI
Browse files Browse the repository at this point in the history
This simplifies running the build using different Gradle versions,
and it provides a more efficient caching of Gradle User Home between
workflow runs compared to setup-java.

GitHub's actions/cache is scoped to the key and branch, where the
default branch cache is available to other branches. This means
identical cache entries will be stored separately for different
branches. To reduce cache usage and cache eviction rate due to cache
size constraints, we only write to the cache on the 'main' branch.
  • Loading branch information
rognan committed Sep 17, 2022
1 parent c7547d6 commit 79eeeb9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
strategy:
matrix:
include:
- { os: 'macos-latest', arch: 'x64', java-version: '11' }
- { os: 'ubuntu-latest', arch: 'x64', java-version: '11' }
- { os: 'windows-latest', arch: 'x64', java-version: '11' }
name: Java ${{ matrix.java-version }} on ${{ matrix.os }} (${{ matrix.arch }})
- { os: 'macos-latest', arch: 'x64', java-version: '11', gradle-version: '7.3' }
- { os: 'ubuntu-latest', arch: 'x64', java-version: '11', gradle-version: '7.3' }
- { os: 'windows-latest', arch: 'x64', java-version: '11', gradle-version: '7.3' }
name: Gradle ${{ matrix.gradle-version }}, Java ${{ matrix.java-version }} on ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -23,8 +23,12 @@ jobs:
architecture: ${{ matrix.arch }}
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'gradle'
- run: ./gradlew build --scan --no-daemon
- uses: gradle/gradle-build-action@v2
with:
# Only write to the cache on the 'main' branch
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
gradle-version: ${{ matrix.gradle-version }}
arguments: build --scan
- name: Upload build reports
uses: actions/upload-artifact@v2
if: always()
Expand Down

0 comments on commit 79eeeb9

Please sign in to comment.