From 2106e152d51549d6b8ee99afaf3dbed1a83c06f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Tue, 25 Oct 2022 18:51:38 +0200 Subject: [PATCH] Use new gha API for setting output, latest core actions (#3237) This commit changes the way job output is defined, using the new way of a GITHUB_OUTPUT file environment variable. The old way of echoing strings is deprecated for sensitive elements, including action/job output. It also reorders the output in order to: - ensure BAD version is detected before any output and fails the job - ensure only one version/versionType is outputted when there are multiple modules (here, the `reactor-core` one) Finally it updates core and gradle actions to latest versions. This fixes warnings about deprecated output style and deprecated Node version being still in use by these actions. See reactor/reactor#727. --- .github/workflows/ci.yml | 26 ++++++++--------- .../workflows/gradle-wrapper-validation.yml | 4 +-- .github/workflows/publish.yml | 28 +++++++++---------- gradle/setup.gradle | 28 +++++++++++++++++-- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbf9d76caf..40d1494f5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,19 +7,19 @@ jobs: name: preliminary sanity checks runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 with: fetch-depth: 0 #needed by spotless - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 - - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + - uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 name: spotless (license header) if: always() with: arguments: spotlessCheck -PspotlessFrom=origin/${{ github.base_ref }} - - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + - uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 name: api compatibility if: always() with: @@ -44,12 +44,12 @@ jobs: runs-on: ubuntu-latest needs: preliminary steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 - - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + - uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 name: gradle with: arguments: :reactor-core:test --no-daemon -Pjunit-tags=!slow @@ -58,12 +58,12 @@ jobs: runs-on: ubuntu-latest needs: preliminary steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 - - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + - uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 name: gradle with: arguments: :reactor-core:test --no-daemon -Pjunit-tags=slow @@ -72,12 +72,12 @@ jobs: runs-on: ubuntu-latest needs: preliminary steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 - - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + - uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 name: other tests with: arguments: check -x :reactor-core:test -x spotlessCheck --no-daemon diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 3a39c505e6..b2e2d600d6 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -6,5 +6,5 @@ jobs: name: "validation" runs-on: ubuntu-latest steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b # renovate: tag=v1 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6 # tag=v1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 581e0a88b7..a0ee221b1e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,9 +18,9 @@ jobs: versionType: ${{ steps.version.outputs.versionType }} fullVersion: ${{ steps.version.outputs.fullVersion }} steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 - name: setup java - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 @@ -32,7 +32,7 @@ jobs: run: ./gradlew qualifyVersionGha - name: run checks id: checks - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 with: arguments: check -Pjunit-tags=!slow -x jcstress @@ -41,15 +41,15 @@ jobs: name: slowerChecks runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 - name: setup java - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 - name: run slower tests id: slowerTests - uses: gradle/gradle-build-action@cd579d970f8aec1cf0cae5f62a8e418768970015 # tag=v2 + uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2 with: arguments: reactor-core:test -Pjunit-tags=slow jcstress @@ -61,8 +61,8 @@ jobs: if: needs.prepare.outputs.versionType == 'SNAPSHOT' environment: snapshots steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 @@ -81,8 +81,8 @@ jobs: if: needs.prepare.outputs.versionType == 'MILESTONE' environment: releases steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 @@ -103,8 +103,8 @@ jobs: if: needs.prepare.outputs.versionType == 'RELEASE' environment: releases steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 - - uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # renovate: tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 + - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3 with: distribution: 'temurin' java-version: 8 @@ -126,7 +126,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 - name: tag run: | git config --local user.name 'reactorbot' @@ -141,7 +141,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # tag=v2 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 - name: tag run: | git config --local user.name 'reactorbot' diff --git a/gradle/setup.gradle b/gradle/setup.gradle index a164c748d1..e53af7c0e6 100644 --- a/gradle/setup.gradle +++ b/gradle/setup.gradle @@ -51,17 +51,39 @@ static def qualifyVersion(String v) { return "BAD" } +static def outputToGha(String versionType, String fullVersion) { + def ghaFilename = System.getenv("GITHUB_OUTPUT") + if (ghaFilename == null) { + println "::set-output name=versionType::$versionType" + println "::set-output name=fullVersion::$fullVersion" + } + else { + println "using GITHUB_OUTPUT file" + def ghaFile = new File(ghaFilename) + ghaFile.withWriterAppend { + it.newLine() + it.append("versionType=$versionType") + it.newLine() + it.append("fullVersion=$fullVersion") + } + } +} + task qualifyVersionGha() { doLast { def versionType = qualifyVersion("$version") - - println "::set-output name=versionType::$versionType" - println "::set-output name=fullVersion::$version" + //we ensure that if at least _one_ submodule version is BAD, we only output versionType=BAD + job fails if (versionType == "BAD") { + outputToGha(versionType, version) println "::error ::Unable to parse $version to a VersionNumber with recognizable qualifier" throw new TaskExecutionException(tasks.getByName("qualifyVersionGha"), new IllegalArgumentException("Unable to parse $version to a VersionNumber with recognizable qualifier")) } println "Recognized $version as $versionType" + + //only output the versionType and fullVersion for the main artifact + if (project.name == 'reactor-core') { + outputToGha(versionType, version) + } } }