gradle-build-action
gradle-build-action copied to clipboard
Add resolved Gradle version to action outputs
It would be great to have the resolved Gradle version as an output of the action; that way one could use gradle-version: current
and later pass that version as input to the Gradle build (to be passed to the Gradle TestKit, that requires a specific version).
actions/setup-java
for instance exposes the version
and path
of the provisioned JDK.
For example here, always testing with the current stable version without having to update the workflow every time:
test-matrix:
runs-on: ubuntu-latest
strategy:
matrix:
gradle: ["current", "6.8"] # some specific versions, plus the current stable
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
id: setup-gradle
with:
gradle-version: ${{ matrix.gradle }}
# Only write to the cache for builds on the 'main' branch.
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Execute Gradle build
run: ./gradlew functionalTest -Ptest.gradle-version=${{ steps.setup-gradle.outputs.version }}
…oh, but I had assumed that the provisioned version would be available in Gradle user home's wrappers, but that doesn't seem to be the case, so that would mean downloading the ZIP twice in the code above.
I had assumed that the provisioned version would be available in Gradle user home's wrappers, but that doesn't seem to be the case, so that would mean downloading the ZIP twice in the code above.
So you mean that TestKit is re-downloading the distribution even after it was downloaded as part of "setup-gradle". This is currently the expected behaviour because the provisioned versions are not stored under Gradle User Home.
However, it would be useful if we could find a way to cache a single copy of the distribution for provisioned Gradle and wrappers. It would be even better if this could be built into Gradle itself, so that if a Gradle version is already provisioned then we'd never have to download the same wrapper.
The issue I'm seeing is that gradle-build-action is not requesting "other" Gradle versions (non-primary, used by TestKit). In this build there is a set of Gradle versions being tested - for each run on GHA these are re-downloaded, and then stored in the cache - because they are never requested to be restored.
Perhaps an option to "use/store all distributions" (that have been used, following existing logic) or "use/store these distributions".
Entry: /Users/runner/.gradle/wrapper/dists/gradle-7.0.2-bin/857tjihv64xamwrf0h14cai3r
Requested Key :
Restored Key :
Size:
(Entry not restored: not requested)
Saved Key : wrapper-zips-995c5ff86b65157e176259f65d3083c1
Size: 106 MB (111278744 B)
(Entry saved)
---
Entry: /Users/runner/.gradle/wrapper/dists/gradle-7.3.3-bin/6a41zxkdtcxs8rphpq6y0069z
Requested Key :
Restored Key :
Size:
(Entry not restored: not requested)
Saved Key : wrapper-zips-cae0e1df3f622e44d724c5c692852706
Size: 110 MB (114932525 B)
(Entry saved)
---
Entry: /Users/runner/.gradle/wrapper/dists/gradle-7.6.2-bin/6ot4hgy1mty27tup86cmng5lx
Requested Key :
Restored Key :
Size:
(Entry not restored: not requested)
Saved Key : wrapper-zips-22bfd495195c13c222eeb1696bc9b251
Size: 116 MB (121330511 B)
(Entry saved)
---
Entry: /Users/runner/.gradle/wrapper/dists/gradle-8.0.2-bin/25jlreiuz6u3xu2phlpa2vv4m
Requested Key :
Restored Key :
Size:
(Entry not restored: not requested)
Saved Key : wrapper-zips-cc7b4be6c9118a3453f8df3bdcb64c9b
Size: 118 MB (123435544 B)
(Entry saved)
@cloudshiftchris This sounds like a different issue, and something we should investigate and fix. Can you please open a separate GH issue with as much detail as possible? Thanks.
@tbroyer v2.8.0
will provide a gradle-version
output parameter, closing this issue.
However, I've opened gradle/actions#22 for the key use case of avoiding re-download of Gradle distributions.