mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +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: ./
|
||||
with:
|
||||
cache-read-only: true
|
||||
- name: Execute Gradle build and verify cached configuration
|
||||
env:
|
||||
VERIFY_CACHED_CONFIGURATION: true
|
||||
- name: Groovy build with configuration-cache enabled
|
||||
id: execute
|
||||
working-directory: __tests__/samples/groovy-dsl
|
||||
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
|
||||
no-extracted-cache-entries-restored:
|
||||
|
@ -123,8 +128,14 @@ jobs:
|
|||
uses: ./
|
||||
with:
|
||||
cache-read-only: true
|
||||
- name: Execute 'test' again and verify cached configuration
|
||||
env:
|
||||
VERIFY_CACHED_CONFIGURATION: true
|
||||
- name: Execute 'test' again with configuration-cache enabled
|
||||
id: execute
|
||||
working-directory: __tests__/samples/kotlin-dsl
|
||||
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 {
|
||||
// Use an environment variable to bypass config-cache checks
|
||||
if (System.getenv('VERIFY_CACHED_CONFIGURATION') != null) {
|
||||
throw new RuntimeException("Configuration was not cached: unexpected configuration of test task")
|
||||
}
|
||||
// Echo an output value so we can detect configuration-cache usage
|
||||
println "::set-output name=task_configured::yes"
|
||||
|
||||
doLast {
|
||||
if (System.properties.verifyCachedBuild) {
|
||||
throw new RuntimeException("Build was not cached: unexpected execution of test task")
|
||||
|
|
|
@ -18,10 +18,9 @@ tasks.test {
|
|||
}
|
||||
|
||||
tasks.named("test").configure {
|
||||
// Use an environment variable to bypass config-cache checks
|
||||
if (System.getenv("VERIFY_CACHED_CONFIGURATION") != null) {
|
||||
throw RuntimeException("Configuration was not cached: unexpected configuration of test task")
|
||||
}
|
||||
// Echo an output value so we can detect configuration-cache usage
|
||||
println("::set-output name=task_configured::yes")
|
||||
|
||||
doLast {
|
||||
if (System.getProperties().containsKey("verifyCachedBuild")) {
|
||||
throw RuntimeException("Build was not cached: unexpected execution of test task")
|
||||
|
|
Loading…
Reference in a new issue