Skip to content

Update GHA workflows to avoid warnings around output APIs #727

@simonbasle

Description

@simonbasle

See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

There is also a push to switch to the latest supported NodeJS runtime (node16), with some actions still using the older EoL version of the runtime.

In the current build and workflows, several classes of warnings arise:

  1. use of echo-based set-output by our build
  2. use of echo-based output or deprecated APIs by actions
  3. use of a runtime < node16 by actions

Thus there is a need to upgrade actions to the latest releases, as well as to alter the builds to use file-based output rather than echo-based output to eg. set the version type and full version parameters for further jobs.

In the gradle builds, there is also a need to reorder the output so that:

• BAD version is detected before any output and fails the job
• only one version/versionType is outputted when there are multiple modules (eg. the reactor-core one should take precedence over reactor-core-micrometer)

That last part is especially important in 2022.0.0 with the introduction of two submodules in reactor-core and reactor-pool respectively (both have a separate version number).

Example of build change

⚠️ note reactor-pool at the end of qualifyVersionGha. otherwise this code can be copy-pasted in different projects.

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")
		//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-pool') {
			outputToGha(versionType, version)
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/all-projectsissues that are transverse to all projects, epics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions