Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add known branch exceptions to version matching #242

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10224,7 +10224,7 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null

if (isStrictVersion() || isRC(spec0)) {
if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly
version = versions0[spec]
Expand Down Expand Up @@ -10296,6 +10296,10 @@ function isRC(ver) {
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
}

function isKnownBranch(ver) {
return ['main', 'master', 'maint'].includes(ver)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to be safer, you could match "maint" anywhere in the version, as OTP has maint-26, maint-25, and so on. :) Just saying, your call, we don't use it right now.

}

function getRunnerOSVersion() {
const ImageOSToContainer = {
ubuntu18: 'ubuntu-18.04',
Expand Down
6 changes: 5 additions & 1 deletion src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null

if (isStrictVersion() || isRC(spec0)) {
if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly
version = versions0[spec]
Expand Down Expand Up @@ -476,6 +476,10 @@ function isRC(ver) {
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
}

function isKnownBranch(ver) {
return ['main', 'master', 'maint'].includes(ver)
}

function getRunnerOSVersion() {
const ImageOSToContainer = {
ubuntu18: 'ubuntu-18.04',
Expand Down
12 changes: 12 additions & 0 deletions test/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ async function testOTPVersions() {
expected = 'OTP-20.0.5'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)

spec = 'maint'
osVersion = 'ubuntu-22.04'
expected = 'maint'
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = 'master'
osVersion = 'ubuntu-22.04'
expected = 'master'
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
}

if (process.platform === 'win32') {
Expand Down