Unverified Commit 53af4d4f authored by Daz DeBoer's avatar Daz DeBoer
Browse files

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.
parent b10e7caf
Loading
Loading
Loading
Loading
+17 −6
Changes for .github/workflows/integTest-caching-configuration-cache.yml: 17 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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')
+3 −4
Changes for __tests__/samples/groovy-dsl/build.gradle: 3 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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")
+3 −4
Changes for __tests__/samples/kotlin-dsl/build.gradle.kts: 3 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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")