Skip to content

Commit

Permalink
Remove use of deprecated 'set-output' command
Browse files Browse the repository at this point in the history
- Use GITHUB_OUTPUT file in init script
- Write to a marker file in configuratiion-cache tests

Fixes #461
  • Loading branch information
bigdaz committed Oct 20, 2022
1 parent c267ad1 commit 22f6aee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflow-samples/groovy-dsl/build.gradle
Expand Up @@ -11,12 +11,12 @@ dependencies {
}

tasks.named("test").configure {
// Echo an output value so we can detect configuration-cache usage
println "::set-output name=task_configured::yes"
// Write marker file so we can detect if task was configured
file("task-configured.txt").text = "true"

doLast {
if (System.properties.verifyCachedBuild) {
throw new RuntimeException("Build was not cached: unexpected execution of test task")
}
}
}
}
4 changes: 2 additions & 2 deletions .github/workflow-samples/kotlin-dsl/build.gradle.kts
Expand Up @@ -18,8 +18,8 @@ tasks.test {
}

tasks.named("test").configure {
// Echo an output value so we can detect configuration-cache usage
println("::set-output name=task_configured::yes")
// Write marker file so we can detect if task was configured
file("task-configured.txt").writeText("true")

doLast {
if (System.getProperties().containsKey("verifyCachedBuild")) {
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/integ-test-restore-configuration-cache.yml
Expand Up @@ -60,11 +60,13 @@ jobs:
working-directory: .github/workflow-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@v6
with:
script: |
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
const fs = require('fs')
if (fs.existsSync('.github/workflow-samples/groovy-dsl/task-configured.txt')) {
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
}
# Check that the build can run when no extracted cache entries are restored
gradle-user-home-not-fully-restored:
Expand Down Expand Up @@ -154,9 +156,11 @@ jobs:
working-directory: .github/workflow-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@v6
with:
script: |
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
const fs = require('fs')
if (fs.existsSync('.github/workflow-samples/kotlin-dsl/task-configured.txt')) {
core.setFailed('Configuration cache was not used - task was configured unexpectedly')
}
5 changes: 4 additions & 1 deletion src/resources/init-scripts/build-result-capture.init.gradle
Expand Up @@ -51,7 +51,10 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProject, invocationId
buildResults.setBuildScanUri(buildScan.buildScanUri.toASCIIString())
buildResults.writeToResultsFile(true)

println("::set-output name=build-scan-url::${buildScan.buildScanUri}")
def githubOutput = System.getenv("GITHUB_OUTPUT")
if (githubOutput) {
new File(githubOutput) << "build-scan-url=${buildScan.buildScanUri}\n"
}
}

onError { error ->
Expand Down

0 comments on commit 22f6aee

Please sign in to comment.