Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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: 0 additions & 6 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ jobs:
elixir-version: '1.14.3'
os: 'macos-latest'
version-type: 'strict'
- otp-version: '27'
os: 'macos-15'
version-type: 'strict'
- otp-version: '26'
os: 'macos-15'
version-type: 'strict'
Comment on lines -46 to -51
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This shoulda been failing but wasn't. Guess it wasn't as strict as we intended...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, it was getting calculated as maint-<otp-version>.

- otp-version: '25'
os: 'macos-15'
- otp-version: '26'
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ jobs:
elixir-version: '1.14.3'
os: 'ubuntu-latest'
version-type: 'strict'
- otp-version: '27'
os: 'ubuntu-24.04'
version-type: 'strict'
- otp-version: '26'
os: 'ubuntu-24.04'
version-type: 'strict'
- otp-version: '25'
os: 'ubuntu-24.04'
- otp-version: '26'
Expand Down
42 changes: 22 additions & 20 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26045,10 +26045,14 @@ async function maybeInstallRebar3(rebar3Spec) {
return installed
}

function maybeRemoveOTPPrefix(otpSpec) {
return otpSpec.replace(/^OTP-/, '')
}

async function getOTPVersion(otpSpec0, osVersion) {
const [otpVersions, originListing, hexMirrors] =
await getOTPVersions(osVersion)
let spec = otpSpec0.replace(/^OTP-/, '')
let spec = maybeRemoveOTPPrefix(otpSpec0)
const versions = otpVersions
const otpVersion = getVersionFromSpec(spec, versions)

Expand Down Expand Up @@ -26224,12 +26228,9 @@ async function getOTPVersions(osVersion) {
.trim()
.split('\n')
.forEach((line) => {
const otpMatch = line
.match(/^([^ ]+)?( .+)/)[1]
.match(/^([^-]+-)?(.+)$/)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one goes away.

const otpVersion = otpMatch[2]
const otpVersionOrig = otpMatch[0]
debugLog('OTP line and parsing', [line, otpVersion, otpMatch])
const otpVersionOrig = line.match(/^([^ ]+)?( .+)/)[1]
const otpVersion = maybeRemoveOTPPrefix(otpVersionOrig)
debugLog('OTP line and parsing', [line, otpVersion, otpVersionOrig])
otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference
})
} else if (process.platform === 'win32') {
Expand All @@ -26243,10 +26244,10 @@ async function getOTPVersions(osVersion) {
.flat()
.filter((x) => x.name.match(file_regex))
.forEach((x) => {
const otpMatch = x.name.match(file_regex)
const otpVersion = otpMatch[1]
debugLog('OTP line and parsing', [otpMatch, otpVersion])
otpVersions[otpVersion] = otpVersion
const otpVersionOrig = x.name.match(file_regex)[1]
const otpVersion = otpVersionOrig
debugLog('OTP line and parsing', [x.name, otpVersion, otpVersionOrig])
otpVersions[otpVersion] = otpVersionOrig
})
})
} else if (process.platform === 'darwin') {
Expand All @@ -26255,10 +26256,9 @@ async function getOTPVersions(osVersion) {
columns: true,
})
.forEach((line) => {
const otpMatch = line.ref_name.match(/^([^-]+-)?(.+)$/)
const otpVersion = otpMatch[2]
const otpVersionOrig = otpMatch[0]
debugLog('OTP line and parsing', [line, otpVersion, otpMatch])
const otpVersionOrig = line.ref_name
const otpVersion = maybeRemoveOTPPrefix(otpVersionOrig)
debugLog('OTP line and parsing', [line, otpVersion, otpVersionOrig])
otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference
})
}
Expand Down Expand Up @@ -26384,7 +26384,8 @@ function getVersionFromSpec(spec0, versions0) {
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`, version is an RC, or version is "a branch"
// we just try to remove a potential initial v
coerced = maybeRemoveVPrefix(version)
} else {
// Otherwise, we place the version into a version bucket
Expand All @@ -26401,18 +26402,19 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null

if (
if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
isKnownVerBranch(spec0) ||
spec0 === 'nightly'
) {
if (versions0[spec]) {
// We obtain it directly
version = versions0[spec]
}
} else if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (rangeMax !== null) {
// Otherwise, we compare alt. versions' semver ranges to this version, from highest to lowest
const thatVersion = spec
Expand Down
42 changes: 22 additions & 20 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@ async function maybeInstallRebar3(rebar3Spec) {
return installed
}

function maybeRemoveOTPPrefix(otpSpec) {
return otpSpec.replace(/^OTP-/, '')
}

async function getOTPVersion(otpSpec0, osVersion) {
const [otpVersions, originListing, hexMirrors] =
await getOTPVersions(osVersion)
let spec = otpSpec0.replace(/^OTP-/, '')
let spec = maybeRemoveOTPPrefix(otpSpec0)
const versions = otpVersions
const otpVersion = getVersionFromSpec(spec, versions)

Expand Down Expand Up @@ -349,12 +353,9 @@ async function getOTPVersions(osVersion) {
.trim()
.split('\n')
.forEach((line) => {
const otpMatch = line
.match(/^([^ ]+)?( .+)/)[1]
.match(/^([^-]+-)?(.+)$/)
const otpVersion = otpMatch[2]
const otpVersionOrig = otpMatch[0]
debugLog('OTP line and parsing', [line, otpVersion, otpMatch])
const otpVersionOrig = line.match(/^([^ ]+)?( .+)/)[1]
const otpVersion = maybeRemoveOTPPrefix(otpVersionOrig)
debugLog('OTP line and parsing', [line, otpVersion, otpVersionOrig])
otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference
})
} else if (process.platform === 'win32') {
Expand All @@ -368,10 +369,10 @@ async function getOTPVersions(osVersion) {
.flat()
.filter((x) => x.name.match(file_regex))
.forEach((x) => {
const otpMatch = x.name.match(file_regex)
const otpVersion = otpMatch[1]
debugLog('OTP line and parsing', [otpMatch, otpVersion])
otpVersions[otpVersion] = otpVersion
const otpVersionOrig = x.name.match(file_regex)[1]
const otpVersion = otpVersionOrig
debugLog('OTP line and parsing', [x.name, otpVersion, otpVersionOrig])
otpVersions[otpVersion] = otpVersionOrig
})
})
} else if (process.platform === 'darwin') {
Expand All @@ -380,10 +381,9 @@ async function getOTPVersions(osVersion) {
columns: true,
})
.forEach((line) => {
const otpMatch = line.ref_name.match(/^([^-]+-)?(.+)$/)
const otpVersion = otpMatch[2]
const otpVersionOrig = otpMatch[0]
debugLog('OTP line and parsing', [line, otpVersion, otpMatch])
const otpVersionOrig = line.ref_name
const otpVersion = maybeRemoveOTPPrefix(otpVersionOrig)
debugLog('OTP line and parsing', [line, otpVersion, otpVersionOrig])
otpVersions[otpVersion] = otpVersionOrig // we keep the original for later reference
})
}
Expand Down Expand Up @@ -509,7 +509,8 @@ function getVersionFromSpec(spec0, versions0) {
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`, version is an RC, or version is "a branch"
// we just try to remove a potential initial v
coerced = maybeRemoveVPrefix(version)
} else {
// Otherwise, we place the version into a version bucket
Expand All @@ -526,18 +527,19 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null

if (
if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
isKnownVerBranch(spec0) ||
spec0 === 'nightly'
) {
if (versions0[spec]) {
// We obtain it directly
version = versions0[spec]
}
} else if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (rangeMax !== null) {
// Otherwise, we compare alt. versions' semver ranges to this version, from highest to lowest
const thatVersion = spec
Expand Down
21 changes: 17 additions & 4 deletions test/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('.getOTPVersion(_) - Erlang', () => {

it('is Ok for known linux version', async () => {
before = simulateInput('version-type', 'strict')
spec = '26'
spec = 'maint-26'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This made no sense, but now we see it. Why would we want 26 to strict to be maint-26? These days this is opt-in, so I think some sanity was restored.

osVersion = 'ubuntu-24.04'
expected = 'maint-26'
got = await setupBeam.getOTPVersion(spec, osVersion)
Expand Down Expand Up @@ -317,7 +317,7 @@ describe('.getOTPVersion(_) - Erlang', () => {
arm64Options[Math.floor(Math.random() * arm64Options.length)]

before = simulateInput('version-type', 'strict')
spec = '26'
spec = 'maint-26'
osVersion = 'ubuntu-24.04'
expected = 'maint-26'
got = await setupBeam.getOTPVersion(spec, osVersion)
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('.getOTPVersion(_) - Erlang', () => {
amd64Options[Math.floor(Math.random() * amd64Options.length)]

before = simulateInput('version-type', 'strict')
spec = '26'
spec = 'maint-26'
osVersion = 'ubuntu-24.04'
expected = 'maint-26'
got = await setupBeam.getOTPVersion(spec, osVersion)
Expand Down Expand Up @@ -558,6 +558,13 @@ describe('.getOTPVersion(_) - Elixir', () => {
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)

spec = 'main-otp-28'
otpVersion = 'maint-28'
expected = 'main-otp-28'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the test for #358.


spec = '1.16.2-otp-26'
otpVersion = 'OTP-27'
expected = 'v1.16.2-otp-26'
Expand All @@ -583,7 +590,7 @@ describe('.getOTPVersion(_) - Elixir', () => {

before = simulateInput('version-type', 'strict')
spec = 'v1.15.0-rc.2'
otpVersion = 'OTP-26'
otpVersion = 'OTP-26.0'
expected = 'v1.15.0-rc.2-otp-26'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
Expand Down Expand Up @@ -617,6 +624,12 @@ describe('.getOTPVersion(_) - Gleam', () => {
got = await setupBeam.getGleamVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)

spec = 'nightly'
otpVersion = '28'
expected = 'nightly'
got = await setupBeam.getGleamVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
Comment on lines +660 to +664
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the test for #356.


spec = '0.13.2'
otpVersion = 'OTP-24'
expected = 'v0.13.2'
Expand Down