mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-23 01:22:50 +00:00
Fix check for config-cache usage
Now that environment variable reads are auto-detected by Gradle 7.4, we need a different mechanism to check that the configuration cache is being used successfully.
This commit is contained in:
parent
b10e7caf66
commit
53af4d4f57
3 changed files with 23 additions and 14 deletions
|
@ -46,11 +46,16 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
cache-read-only: true
|
cache-read-only: true
|
||||||
- name: Execute Gradle build and verify cached configuration
|
- name: Groovy build with configuration-cache enabled
|
||||||
env:
|
id: execute
|
||||||
VERIFY_CACHED_CONFIGURATION: true
|
|
||||||
working-directory: __tests__/samples/groovy-dsl
|
working-directory: __tests__/samples/groovy-dsl
|
||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
|
- name: Check that configuration-cache was used
|
||||||
|
if: ${{ steps.execute.outputs.task_configured == 'yes' }}
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
|
||||||
|
|
||||||
# Check that the build can run when no extracted cache entries are restored
|
# Check that the build can run when no extracted cache entries are restored
|
||||||
no-extracted-cache-entries-restored:
|
no-extracted-cache-entries-restored:
|
||||||
|
@ -123,8 +128,14 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
cache-read-only: true
|
cache-read-only: true
|
||||||
- name: Execute 'test' again and verify cached configuration
|
- name: Execute 'test' again with configuration-cache enabled
|
||||||
env:
|
id: execute
|
||||||
VERIFY_CACHED_CONFIGURATION: true
|
|
||||||
working-directory: __tests__/samples/kotlin-dsl
|
working-directory: __tests__/samples/kotlin-dsl
|
||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
|
- name: Check that configuration-cache was used
|
||||||
|
if: ${{ steps.execute.outputs.task_configured == 'yes' }}
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,9 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("test").configure {
|
tasks.named("test").configure {
|
||||||
// Use an environment variable to bypass config-cache checks
|
// Echo an output value so we can detect configuration-cache usage
|
||||||
if (System.getenv('VERIFY_CACHED_CONFIGURATION') != null) {
|
println "::set-output name=task_configured::yes"
|
||||||
throw new RuntimeException("Configuration was not cached: unexpected configuration of test task")
|
|
||||||
}
|
|
||||||
doLast {
|
doLast {
|
||||||
if (System.properties.verifyCachedBuild) {
|
if (System.properties.verifyCachedBuild) {
|
||||||
throw new RuntimeException("Build was not cached: unexpected execution of test task")
|
throw new RuntimeException("Build was not cached: unexpected execution of test task")
|
||||||
|
|
|
@ -18,10 +18,9 @@ tasks.test {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("test").configure {
|
tasks.named("test").configure {
|
||||||
// Use an environment variable to bypass config-cache checks
|
// Echo an output value so we can detect configuration-cache usage
|
||||||
if (System.getenv("VERIFY_CACHED_CONFIGURATION") != null) {
|
println("::set-output name=task_configured::yes")
|
||||||
throw RuntimeException("Configuration was not cached: unexpected configuration of test task")
|
|
||||||
}
|
|
||||||
doLast {
|
doLast {
|
||||||
if (System.getProperties().containsKey("verifyCachedBuild")) {
|
if (System.getProperties().containsKey("verifyCachedBuild")) {
|
||||||
throw RuntimeException("Build was not cached: unexpected execution of test task")
|
throw RuntimeException("Build was not cached: unexpected execution of test task")
|
||||||
|
|
Loading…
Reference in a new issue