Test for updated doc. on latest / ranges / -rc (#349)

* Set the expectations

* Reason on the past

* Also allow for removal of OTP- in comparison to RC

* Test it on what makes sense

* For known elements don't compare with ranges

* Don't put maint-27 alongside 27 in the initial map

* Generate the dist

* Revisit the whole latest vs. rc- vs. strict definition
This commit is contained in:
Paulo F. Oliveira
2025-06-26 20:39:15 +01:00
committed by GitHub
parent 75edbb8287
commit 6a38171948
4 changed files with 65 additions and 17 deletions
+15 -9
View File
@@ -53,19 +53,25 @@ end up being parsed as `23`, which is not equivalent.
#### Pre-release versions #### Pre-release versions
For pre-release versions, such as `v1.11.0-rc.0`, use the full version To use a pre-release version such as `v1.11.0-rc.0`, specify the exact version
specifier (`v1.11.0-rc.0`) and set option `version-type` to `strict`. Pre-release versions are (`v1.11.0-rc.0`) and set `version-type` to `strict`.
opt-in, so `1.11.x` will not match a pre-release. Note that pre-release versions are opt-in by default.
Patterns like `1.11.x` do not include pre-release versions unless `latest` is specified.
#### "Latest" versions #### "Latest" versions
Set a tool's version to `latest` to retrieve the latest version of a given tool. To retrieve the most recent available version of a tool, set the version to `latest`.
The latest version is (locally) calculated by the action based on the (retrieved) versions This may include pre-release versions such as release candidates.
it knows (**note**: it is not the same as [GitHub considers it](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository)
and some repositories might propose).
If in doubt do a test run and compare the obtained release with the one you were expecting to If you want to target only the latest stable release and exclude pre-releases, use a
be the latest. version range like `> 0` instead.
Note that the `latest` version is determined locally by the action based on the versions it
has retrieved. This may differ from how [GitHub defines "latest"](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository),
and some repositories may present different interpretations.
If you're unsure, perform a test run and compare the resolved version against the version you
expect to be considered the latest.
### Compatibility between Operating System and Erlang/OTP ### Compatibility between Operating System and Erlang/OTP
+15 -4
View File
@@ -26323,6 +26323,7 @@ function validVersion(v) {
v.match( v.match(
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
) == null && ) == null &&
// these ones are for rebar3, which has alpha and beta releases
!v.startsWith('a') && !v.startsWith('a') &&
!v.startsWith('b') !v.startsWith('b')
) )
@@ -26349,7 +26350,12 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {} const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => { Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced let coerced
if (isStrictVersion() || isRC(version)) { if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
// If `version-type: strict` or version is RC, we just try to remove a potential initial v // If `version-type: strict` or version is RC, we just try to remove a potential initial v
coerced = maybeRemoveVPrefix(version) coerced = maybeRemoveVPrefix(version)
} else { } else {
@@ -26367,9 +26373,14 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax) const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null let version = null
if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) { if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
) {
if (versions0[spec]) { if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly // We obtain it directly
version = versions0[spec] version = versions0[spec]
} }
} else if (spec0 === 'latest') { } else if (spec0 === 'latest') {
@@ -26592,7 +26603,7 @@ function xyzAbcVersion(pref, suf) {
// https://www.erlang.org/doc/system_principles/versions.html // https://www.erlang.org/doc/system_principles/versions.html
const dd = '\\.?(\\d+)?' const dd = '\\.?(\\d+)?'
return new RegExp( return new RegExp(
`${pref}v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`, `${pref}(?:OTP-)?v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`,
) )
} }
+15 -4
View File
@@ -448,6 +448,7 @@ function validVersion(v) {
v.match( v.match(
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
) == null && ) == null &&
// these ones are for rebar3, which has alpha and beta releases
!v.startsWith('a') && !v.startsWith('a') &&
!v.startsWith('b') !v.startsWith('b')
) )
@@ -474,7 +475,12 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {} const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => { Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced let coerced
if (isStrictVersion() || isRC(version)) { if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
// If `version-type: strict` or version is RC, we just try to remove a potential initial v // If `version-type: strict` or version is RC, we just try to remove a potential initial v
coerced = maybeRemoveVPrefix(version) coerced = maybeRemoveVPrefix(version)
} else { } else {
@@ -492,9 +498,14 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax) const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null let version = null
if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) { if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
) {
if (versions0[spec]) { if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly // We obtain it directly
version = versions0[spec] version = versions0[spec]
} }
} else if (spec0 === 'latest') { } else if (spec0 === 'latest') {
@@ -717,7 +728,7 @@ function xyzAbcVersion(pref, suf) {
// https://www.erlang.org/doc/system_principles/versions.html // https://www.erlang.org/doc/system_principles/versions.html
const dd = '\\.?(\\d+)?' const dd = '\\.?(\\d+)?'
return new RegExp( return new RegExp(
`${pref}v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`, `${pref}(?:OTP-)?v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`,
) )
} }
+20
View File
@@ -875,11 +875,31 @@ describe('.getVersionFromSpec(_)', () => {
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-20.04']) got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-20.04'])
assert.deepStrictEqual(got, expected) assert.deepStrictEqual(got, expected)
spec = 'maint-24'
expected = 'maint-24'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)
spec = '> 0'
expected = 'OTP-26.2.5'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)
spec = 'latest' spec = 'latest'
expected = 'OTP-27.0-rc3' expected = 'OTP-27.0-rc3'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04']) got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected) assert.deepStrictEqual(got, expected)
spec = 'maint-26'
expected = 'maint-26'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)
spec = '> 0'
expected = 'OTP-27.0'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04'])
assert.deepStrictEqual(got, expected)
spec = 'latest' spec = 'latest'
expected = 'OTP-27.0' expected = 'OTP-27.0'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04']) got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04'])