mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-23 07:06:07 +00:00
Fix calculating -otp- major for Elixir (#351)
* Set expectations * Ease testing without having to install via `require` * Code a solution for the tests * Avoid errors on unit tests rebar3 is saying something about SSL, most likely because our tests are installing a bunch of OTPs which makes for unpredictable behavior * Avoid errors on integration tests
This commit is contained in:
committed by
GitHub
parent
3c915dd1b0
commit
8fc1380bb7
@@ -76,6 +76,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
install-rebar: false
|
install-rebar: false
|
||||||
|
install-hex: false
|
||||||
version-file: test/.tool-versions
|
version-file: test/.tool-versions
|
||||||
version-type: strict
|
version-type: strict
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
combo:
|
combo:
|
||||||
|
- otp-version: '<26'
|
||||||
|
elixir-version: '<1.17'
|
||||||
|
os: 'ubuntu-22.04'
|
||||||
|
- otp-version: 'master'
|
||||||
|
elixir-version: '> 0'
|
||||||
|
os: 'ubuntu-24.04'
|
||||||
|
- otp-version: 'master'
|
||||||
|
elixir-version: 'main'
|
||||||
|
os: 'ubuntu-24.04'
|
||||||
- otp-version: '27'
|
- otp-version: '27'
|
||||||
elixir-version: 'v1.17.0'
|
elixir-version: 'v1.17.0'
|
||||||
rebar3-version: '3.23'
|
rebar3-version: '3.23'
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
combo:
|
combo:
|
||||||
|
- otp-version: '<26'
|
||||||
|
elixir-version: '<1.17'
|
||||||
|
os: 'ubuntu-22.04'
|
||||||
|
- otp-version: 'master'
|
||||||
|
elixir-version: '> 0'
|
||||||
|
os: 'ubuntu-24.04'
|
||||||
- otp-version: '27'
|
- otp-version: '27'
|
||||||
elixir-version: 'v1.17.0'
|
elixir-version: 'v1.17.0'
|
||||||
rebar3-version: '3.23'
|
rebar3-version: '3.23'
|
||||||
|
|||||||
Vendored
+59
-27
@@ -25890,9 +25890,11 @@ const _ = __nccwpck_require__(2356)
|
|||||||
|
|
||||||
const MAX_HTTP_RETRIES = 3
|
const MAX_HTTP_RETRIES = 3
|
||||||
|
|
||||||
main().catch((err) => {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
core.setFailed(err.message)
|
main().catch((err) => {
|
||||||
})
|
core.setFailed(err.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
checkOtpArchitecture()
|
checkOtpArchitecture()
|
||||||
@@ -25908,15 +25910,14 @@ async function main() {
|
|||||||
versions = parseVersionFile(versionFilePath)
|
versions = parseVersionFile(versionFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const osVersion = getRunnerOSVersion()
|
|
||||||
const otpSpec = getInput('otp-version', true, 'erlang', versions)
|
const otpSpec = getInput('otp-version', true, 'erlang', versions)
|
||||||
const elixirSpec = getInput('elixir-version', false, 'elixir', versions)
|
const elixirSpec = getInput('elixir-version', false, 'elixir', versions)
|
||||||
const gleamSpec = getInput('gleam-version', false, 'gleam', versions)
|
const gleamSpec = getInput('gleam-version', false, 'gleam', versions)
|
||||||
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
|
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
|
||||||
|
|
||||||
if (otpSpec !== 'false') {
|
if (otpSpec !== 'false') {
|
||||||
await installOTP(otpSpec, osVersion)
|
await installOTP(otpSpec)
|
||||||
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpSpec)
|
const elixirInstalled = await maybeInstallElixir(elixirSpec)
|
||||||
if (elixirInstalled === true) {
|
if (elixirInstalled === true) {
|
||||||
const shouldMixRebar = getInput('install-rebar', false)
|
const shouldMixRebar = getInput('install-rebar', false)
|
||||||
await mix(shouldMixRebar, 'rebar')
|
await mix(shouldMixRebar, 'rebar')
|
||||||
@@ -25936,7 +25937,8 @@ async function main() {
|
|||||||
core.setOutput('setup-beam-version', setupBeamVersion)
|
core.setOutput('setup-beam-version', setupBeamVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installOTP(otpSpec, osVersion) {
|
async function installOTP(otpSpec) {
|
||||||
|
const osVersion = getRunnerOSVersion()
|
||||||
const otpVersion = await getOTPVersion(otpSpec, osVersion)
|
const otpVersion = await getOTPVersion(otpSpec, osVersion)
|
||||||
core.startGroup(
|
core.startGroup(
|
||||||
`Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`,
|
`Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`,
|
||||||
@@ -25958,10 +25960,10 @@ async function installOTP(otpSpec, osVersion) {
|
|||||||
return otpVersion
|
return otpVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
async function maybeInstallElixir(elixirSpec, otpSpec) {
|
async function maybeInstallElixir(elixirSpec) {
|
||||||
let installed = false
|
let installed = false
|
||||||
if (elixirSpec) {
|
if (elixirSpec) {
|
||||||
const elixirVersion = await getElixirVersion(elixirSpec, otpSpec)
|
const elixirVersion = await getElixirVersion(elixirSpec)
|
||||||
core.startGroup(`Installing Elixir ${elixirVersion}`)
|
core.startGroup(`Installing Elixir ${elixirVersion}`)
|
||||||
await doWithMirrors({
|
await doWithMirrors({
|
||||||
hexMirrors: hexMirrorsInput(),
|
hexMirrors: hexMirrorsInput(),
|
||||||
@@ -26070,16 +26072,30 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
|
|||||||
const knownBranches = ['main', 'master', 'maint']
|
const knownBranches = ['main', 'master', 'maint']
|
||||||
const nonSpecificVersions = ['nightly', 'latest']
|
const nonSpecificVersions = ['nightly', 'latest']
|
||||||
|
|
||||||
async function getElixirVersion(exSpec0, otpVersion0) {
|
async function getElixirVersion(exSpec0) {
|
||||||
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
|
|
||||||
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
|
|
||||||
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
|
|
||||||
|
|
||||||
const otpSuffix = /-otp-(\d+)/
|
const otpSuffix = /-otp-(\d+)/
|
||||||
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
|
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
|
||||||
|
let otpVersionMajor = ''
|
||||||
|
|
||||||
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
|
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
|
||||||
otpVersionMajor = userSuppliedOtp
|
otpVersionMajor = userSuppliedOtp
|
||||||
|
} else {
|
||||||
|
let cmd = 'erl'
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
cmd = 'erl.exe'
|
||||||
|
}
|
||||||
|
const args = [
|
||||||
|
'-noshell',
|
||||||
|
'-eval',
|
||||||
|
'io:format(erlang:system_info(otp_release)), halt().',
|
||||||
|
]
|
||||||
|
await exec(cmd, args, {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => {
|
||||||
|
otpVersionMajor = data.toString()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] =
|
const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] =
|
||||||
@@ -26094,17 +26110,29 @@ async function getElixirVersion(exSpec0, otpVersion0) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
|
let foundCombo = false
|
||||||
if (
|
let otpVersionMajorIter = parseInt(otpVersionMajor)
|
||||||
(elixirVersionComp && elixirVersionComp.includes(otpVersionMajor)) ||
|
let otpVersionsMajor = []
|
||||||
!isVersion(otpVersionMajor)
|
while (otpVersionMajorIter > otpVersionMajor - 3) {
|
||||||
) {
|
otpVersionMajorIter += ''
|
||||||
core.info(
|
otpVersionsMajor.push(otpVersionMajorIter)
|
||||||
`Using Elixir ${elixirVersionFromSpec} (built for Erlang/OTP ${otpVersionMajor})`,
|
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
|
||||||
)
|
if (
|
||||||
} else {
|
(elixirVersionComp && elixirVersionComp.includes(otpVersionMajorIter)) ||
|
||||||
|
!isVersion(otpVersionMajorIter)
|
||||||
|
) {
|
||||||
|
core.info(
|
||||||
|
`Using Elixir ${elixirVersionFromSpec} (built for Erlang/OTP ${otpVersionMajorIter})`,
|
||||||
|
)
|
||||||
|
foundCombo = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
otpVersionMajorIter = parseInt(otpVersionMajorIter) - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundCombo) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Requested Elixir / Erlang/OTP version (${exSpec0} / ${otpVersion0}) not ` +
|
`Requested Elixir / Erlang/OTP version (${exSpec0} / tried ${otpVersionsMajor}) not ` +
|
||||||
'found in version list (did you check Compatibility between Elixir and Erlang/OTP?).' +
|
'found in version list (did you check Compatibility between Elixir and Erlang/OTP?).' +
|
||||||
'Elixir and Erlang/OTP compatibility can be found at: ' +
|
'Elixir and Erlang/OTP compatibility can be found at: ' +
|
||||||
'https://hexdocs.pm/elixir/compatibility-and-deprecations.html',
|
'https://hexdocs.pm/elixir/compatibility-and-deprecations.html',
|
||||||
@@ -26113,8 +26141,8 @@ async function getElixirVersion(exSpec0, otpVersion0) {
|
|||||||
|
|
||||||
let elixirVersionForDownload = elixirVersionFromSpec
|
let elixirVersionForDownload = elixirVersionFromSpec
|
||||||
|
|
||||||
if (isVersion(otpVersionMajor)) {
|
if (isVersion(otpVersionMajorIter)) {
|
||||||
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajor}`
|
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajorIter}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return maybePrependWithV(elixirVersionForDownload)
|
return maybePrependWithV(elixirVersionForDownload)
|
||||||
@@ -27073,14 +27101,18 @@ function debugLoggingEnabled() {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get,
|
get,
|
||||||
getOTPVersion,
|
|
||||||
getElixirVersion,
|
getElixirVersion,
|
||||||
getGleamVersion,
|
getGleamVersion,
|
||||||
|
getOTPVersion,
|
||||||
getRebar3Version,
|
getRebar3Version,
|
||||||
getVersionFromSpec,
|
getVersionFromSpec,
|
||||||
githubAMDRunnerArchs,
|
githubAMDRunnerArchs,
|
||||||
githubARMRunnerArchs,
|
githubARMRunnerArchs,
|
||||||
install,
|
install,
|
||||||
|
installOTP,
|
||||||
|
maybeInstallElixir,
|
||||||
|
maybeInstallGleam,
|
||||||
|
maybeInstallRebar3,
|
||||||
parseVersionFile,
|
parseVersionFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+59
-27
@@ -10,9 +10,11 @@ const _ = require('lodash')
|
|||||||
|
|
||||||
const MAX_HTTP_RETRIES = 3
|
const MAX_HTTP_RETRIES = 3
|
||||||
|
|
||||||
main().catch((err) => {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
core.setFailed(err.message)
|
main().catch((err) => {
|
||||||
})
|
core.setFailed(err.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
checkOtpArchitecture()
|
checkOtpArchitecture()
|
||||||
@@ -28,15 +30,14 @@ async function main() {
|
|||||||
versions = parseVersionFile(versionFilePath)
|
versions = parseVersionFile(versionFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const osVersion = getRunnerOSVersion()
|
|
||||||
const otpSpec = getInput('otp-version', true, 'erlang', versions)
|
const otpSpec = getInput('otp-version', true, 'erlang', versions)
|
||||||
const elixirSpec = getInput('elixir-version', false, 'elixir', versions)
|
const elixirSpec = getInput('elixir-version', false, 'elixir', versions)
|
||||||
const gleamSpec = getInput('gleam-version', false, 'gleam', versions)
|
const gleamSpec = getInput('gleam-version', false, 'gleam', versions)
|
||||||
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
|
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
|
||||||
|
|
||||||
if (otpSpec !== 'false') {
|
if (otpSpec !== 'false') {
|
||||||
await installOTP(otpSpec, osVersion)
|
await installOTP(otpSpec)
|
||||||
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpSpec)
|
const elixirInstalled = await maybeInstallElixir(elixirSpec)
|
||||||
if (elixirInstalled === true) {
|
if (elixirInstalled === true) {
|
||||||
const shouldMixRebar = getInput('install-rebar', false)
|
const shouldMixRebar = getInput('install-rebar', false)
|
||||||
await mix(shouldMixRebar, 'rebar')
|
await mix(shouldMixRebar, 'rebar')
|
||||||
@@ -56,7 +57,8 @@ async function main() {
|
|||||||
core.setOutput('setup-beam-version', setupBeamVersion)
|
core.setOutput('setup-beam-version', setupBeamVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installOTP(otpSpec, osVersion) {
|
async function installOTP(otpSpec) {
|
||||||
|
const osVersion = getRunnerOSVersion()
|
||||||
const otpVersion = await getOTPVersion(otpSpec, osVersion)
|
const otpVersion = await getOTPVersion(otpSpec, osVersion)
|
||||||
core.startGroup(
|
core.startGroup(
|
||||||
`Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`,
|
`Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`,
|
||||||
@@ -78,10 +80,10 @@ async function installOTP(otpSpec, osVersion) {
|
|||||||
return otpVersion
|
return otpVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
async function maybeInstallElixir(elixirSpec, otpSpec) {
|
async function maybeInstallElixir(elixirSpec) {
|
||||||
let installed = false
|
let installed = false
|
||||||
if (elixirSpec) {
|
if (elixirSpec) {
|
||||||
const elixirVersion = await getElixirVersion(elixirSpec, otpSpec)
|
const elixirVersion = await getElixirVersion(elixirSpec)
|
||||||
core.startGroup(`Installing Elixir ${elixirVersion}`)
|
core.startGroup(`Installing Elixir ${elixirVersion}`)
|
||||||
await doWithMirrors({
|
await doWithMirrors({
|
||||||
hexMirrors: hexMirrorsInput(),
|
hexMirrors: hexMirrorsInput(),
|
||||||
@@ -195,16 +197,30 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
|
|||||||
const knownBranches = ['main', 'master', 'maint']
|
const knownBranches = ['main', 'master', 'maint']
|
||||||
const nonSpecificVersions = ['nightly', 'latest']
|
const nonSpecificVersions = ['nightly', 'latest']
|
||||||
|
|
||||||
async function getElixirVersion(exSpec0, otpVersion0) {
|
async function getElixirVersion(exSpec0) {
|
||||||
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
|
|
||||||
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
|
|
||||||
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
|
|
||||||
|
|
||||||
const otpSuffix = /-otp-(\d+)/
|
const otpSuffix = /-otp-(\d+)/
|
||||||
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
|
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
|
||||||
|
let otpVersionMajor = ''
|
||||||
|
|
||||||
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
|
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
|
||||||
otpVersionMajor = userSuppliedOtp
|
otpVersionMajor = userSuppliedOtp
|
||||||
|
} else {
|
||||||
|
let cmd = 'erl'
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
cmd = 'erl.exe'
|
||||||
|
}
|
||||||
|
const args = [
|
||||||
|
'-noshell',
|
||||||
|
'-eval',
|
||||||
|
'io:format(erlang:system_info(otp_release)), halt().',
|
||||||
|
]
|
||||||
|
await exec(cmd, args, {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => {
|
||||||
|
otpVersionMajor = data.toString()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] =
|
const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] =
|
||||||
@@ -219,17 +235,29 @@ async function getElixirVersion(exSpec0, otpVersion0) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
|
let foundCombo = false
|
||||||
if (
|
let otpVersionMajorIter = parseInt(otpVersionMajor)
|
||||||
(elixirVersionComp && elixirVersionComp.includes(otpVersionMajor)) ||
|
let otpVersionsMajor = []
|
||||||
!isVersion(otpVersionMajor)
|
while (otpVersionMajorIter > otpVersionMajor - 3) {
|
||||||
) {
|
otpVersionMajorIter += ''
|
||||||
core.info(
|
otpVersionsMajor.push(otpVersionMajorIter)
|
||||||
`Using Elixir ${elixirVersionFromSpec} (built for Erlang/OTP ${otpVersionMajor})`,
|
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
|
||||||
)
|
if (
|
||||||
} else {
|
(elixirVersionComp && elixirVersionComp.includes(otpVersionMajorIter)) ||
|
||||||
|
!isVersion(otpVersionMajorIter)
|
||||||
|
) {
|
||||||
|
core.info(
|
||||||
|
`Using Elixir ${elixirVersionFromSpec} (built for Erlang/OTP ${otpVersionMajorIter})`,
|
||||||
|
)
|
||||||
|
foundCombo = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
otpVersionMajorIter = parseInt(otpVersionMajorIter) - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundCombo) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Requested Elixir / Erlang/OTP version (${exSpec0} / ${otpVersion0}) not ` +
|
`Requested Elixir / Erlang/OTP version (${exSpec0} / tried ${otpVersionsMajor}) not ` +
|
||||||
'found in version list (did you check Compatibility between Elixir and Erlang/OTP?).' +
|
'found in version list (did you check Compatibility between Elixir and Erlang/OTP?).' +
|
||||||
'Elixir and Erlang/OTP compatibility can be found at: ' +
|
'Elixir and Erlang/OTP compatibility can be found at: ' +
|
||||||
'https://hexdocs.pm/elixir/compatibility-and-deprecations.html',
|
'https://hexdocs.pm/elixir/compatibility-and-deprecations.html',
|
||||||
@@ -238,8 +266,8 @@ async function getElixirVersion(exSpec0, otpVersion0) {
|
|||||||
|
|
||||||
let elixirVersionForDownload = elixirVersionFromSpec
|
let elixirVersionForDownload = elixirVersionFromSpec
|
||||||
|
|
||||||
if (isVersion(otpVersionMajor)) {
|
if (isVersion(otpVersionMajorIter)) {
|
||||||
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajor}`
|
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajorIter}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return maybePrependWithV(elixirVersionForDownload)
|
return maybePrependWithV(elixirVersionForDownload)
|
||||||
@@ -1198,13 +1226,17 @@ function debugLoggingEnabled() {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get,
|
get,
|
||||||
getOTPVersion,
|
|
||||||
getElixirVersion,
|
getElixirVersion,
|
||||||
getGleamVersion,
|
getGleamVersion,
|
||||||
|
getOTPVersion,
|
||||||
getRebar3Version,
|
getRebar3Version,
|
||||||
getVersionFromSpec,
|
getVersionFromSpec,
|
||||||
githubAMDRunnerArchs,
|
githubAMDRunnerArchs,
|
||||||
githubARMRunnerArchs,
|
githubARMRunnerArchs,
|
||||||
install,
|
install,
|
||||||
|
installOTP,
|
||||||
|
maybeInstallElixir,
|
||||||
|
maybeInstallGleam,
|
||||||
|
maybeInstallRebar3,
|
||||||
parseVersionFile,
|
parseVersionFile,
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-69
@@ -1,3 +1,5 @@
|
|||||||
|
process.env.NODE_ENV = 'test'
|
||||||
|
|
||||||
simulateInput('otp-version', '25.1.2')
|
simulateInput('otp-version', '25.1.2')
|
||||||
simulateInput('otp-architecture', '64')
|
simulateInput('otp-architecture', '64')
|
||||||
simulateInput('elixir-version', '1.14.2')
|
simulateInput('elixir-version', '1.14.2')
|
||||||
@@ -536,77 +538,70 @@ describe('.getOTPVersion(_) - Elixir', () => {
|
|||||||
let spec
|
let spec
|
||||||
let otpVersion
|
let otpVersion
|
||||||
let before
|
let before
|
||||||
const hexMirrors = simulateInput('hexpm-mirrors', 'https://repo.hex.pm', {
|
const previousRunnerArch = process.env.RUNNER_ARCH
|
||||||
multiline: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns the expected value', async () => {
|
if (process.platform === 'linux') {
|
||||||
spec = '1.1.x'
|
process.env.RUNNER_ARCH = 'X64'
|
||||||
otpVersion = 'OTP-17'
|
|
||||||
expected = 'v1.1.1-otp-17'
|
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
|
||||||
assert.deepStrictEqual(got, expected)
|
|
||||||
|
|
||||||
spec = '1.10.4'
|
it('returns the expected value', async () => {
|
||||||
otpVersion = 'OTP-23'
|
spec = '1.18.x'
|
||||||
expected = 'v1.10.4-otp-23'
|
otpVersion = 'OTP-27'
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
expected = 'v1.18.4-otp-27'
|
||||||
assert.deepStrictEqual(got, expected)
|
await setupBeam.installOTP(otpVersion)
|
||||||
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
|
assert.deepStrictEqual(got, expected)
|
||||||
|
|
||||||
spec = '1.16.2-otp-26'
|
spec = '1.18.2'
|
||||||
otpVersion = 'OTP-27'
|
otpVersion = 'OTP-27'
|
||||||
expected = 'v1.16.2-otp-26'
|
expected = 'v1.18.2-otp-27'
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
await setupBeam.installOTP(otpVersion)
|
||||||
assert.deepStrictEqual(got, expected)
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
|
assert.deepStrictEqual(got, expected)
|
||||||
|
|
||||||
spec = '1.12.1'
|
spec = '1.16.2-otp-26'
|
||||||
otpVersion = 'OTP-24.0.2'
|
otpVersion = 'OTP-27'
|
||||||
expected = 'v1.12.1-otp-24'
|
expected = 'v1.16.2-otp-26'
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
await setupBeam.installOTP(otpVersion)
|
||||||
assert.deepStrictEqual(got, expected)
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
|
assert.deepStrictEqual(got, expected)
|
||||||
|
|
||||||
before = simulateInput('version-type', 'strict')
|
spec = '1.12.1'
|
||||||
spec = '1.14.0'
|
otpVersion = 'OTP-24.3.4'
|
||||||
otpVersion = 'main'
|
expected = 'v1.12.1-otp-24'
|
||||||
expected = 'v1.14.0'
|
await setupBeam.installOTP(otpVersion)
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
assert.deepStrictEqual(got, expected)
|
assert.deepStrictEqual(got, expected)
|
||||||
simulateInput('version-type', before)
|
|
||||||
|
|
||||||
before = simulateInput('version-type', 'strict')
|
before = simulateInput('version-type', 'strict')
|
||||||
spec = 'v1.11.0-rc.0'
|
spec = '1.17'
|
||||||
otpVersion = 'OTP-23'
|
otpVersion = 'master'
|
||||||
expected = 'v1.11.0-rc.0-otp-23'
|
expected = 'v1.17-otp-27'
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
await setupBeam.installOTP(otpVersion)
|
||||||
assert.deepStrictEqual(got, expected)
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
simulateInput('version-type', before)
|
assert.deepStrictEqual(got, expected)
|
||||||
|
simulateInput('version-type', before)
|
||||||
|
|
||||||
before = simulateInput('version-type', 'strict')
|
before = simulateInput('version-type', 'strict')
|
||||||
spec = 'v1.11.0-rc.0-otp-23'
|
spec = 'v1.15.0-rc.2'
|
||||||
otpVersion = 'OTP-23'
|
otpVersion = 'OTP-26'
|
||||||
expected = 'v1.11.0-rc.0-otp-23'
|
expected = 'v1.15.0-rc.2-otp-26'
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
await setupBeam.installOTP(otpVersion)
|
||||||
assert.deepStrictEqual(got, expected)
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
simulateInput('version-type', before)
|
assert.deepStrictEqual(got, expected)
|
||||||
|
simulateInput('version-type', before)
|
||||||
|
|
||||||
before = simulateInput('version-type', 'strict')
|
before = simulateInput('version-type', 'strict')
|
||||||
spec = 'v1.11.0'
|
spec = 'main'
|
||||||
otpVersion = '22.3.4.2'
|
otpVersion = '25.2'
|
||||||
expected = 'v1.11.0-otp-22'
|
expected = 'main-otp-25'
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
await setupBeam.installOTP(otpVersion)
|
||||||
assert.deepStrictEqual(got, expected)
|
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
||||||
simulateInput('version-type', before)
|
assert.deepStrictEqual(got, expected)
|
||||||
|
simulateInput('version-type', before)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
before = simulateInput('version-type', 'strict')
|
process.env.RUNNER_ARCH = previousRunnerArch
|
||||||
spec = 'main'
|
|
||||||
otpVersion = '23.1'
|
|
||||||
expected = 'main-otp-23'
|
|
||||||
got = await setupBeam.getElixirVersion(spec, otpVersion)
|
|
||||||
assert.deepStrictEqual(got, expected)
|
|
||||||
simulateInput('version-type', before)
|
|
||||||
})
|
|
||||||
|
|
||||||
simulateInput('hexpm-mirrors', hexMirrors, { multiline: true })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('.getOTPVersion(_) - Gleam', () => {
|
describe('.getOTPVersion(_) - Gleam', () => {
|
||||||
@@ -941,18 +936,16 @@ describe('version file', () => {
|
|||||||
const otpVersion = unsimulateInput('otp-version')
|
const otpVersion = unsimulateInput('otp-version')
|
||||||
const elixirVersion = unsimulateInput('elixir-version')
|
const elixirVersion = unsimulateInput('elixir-version')
|
||||||
const gleamVersion = unsimulateInput('gleam-version')
|
const gleamVersion = unsimulateInput('gleam-version')
|
||||||
const rebar3Version = unsimulateInput('rebar3-version')
|
|
||||||
|
|
||||||
it('is parsed correctly', async () => {
|
it('is parsed correctly', async () => {
|
||||||
const erlang = '27'
|
const erlang = '27'
|
||||||
const elixir = '1.17.0'
|
const elixir = '1.17.0'
|
||||||
const gleam = '0.23.0'
|
const gleam = '0.23.0'
|
||||||
const rebar3 = '3.24.0'
|
|
||||||
const toolVersions = `# a comment
|
const toolVersions = `# a comment
|
||||||
erlang ref:v${erlang}# comment, no space, and ref:v
|
erlang ref:v${erlang}# comment, no space, and ref:v
|
||||||
elixir ref:${elixir} # comment, with space and ref:
|
elixir ref:${elixir} # comment, with space and ref:
|
||||||
not-gleam 0.23 # not picked up
|
not-gleam 0.23 # not picked up
|
||||||
gleam ${gleam} \nrebar ${rebar3}`
|
gleam ${gleam} \n`
|
||||||
const filename = 'test/.tool-versions'
|
const filename = 'test/.tool-versions'
|
||||||
fs.writeFileSync(filename, toolVersions)
|
fs.writeFileSync(filename, toolVersions)
|
||||||
process.env.GITHUB_WORKSPACE = ''
|
process.env.GITHUB_WORKSPACE = ''
|
||||||
@@ -977,15 +970,11 @@ gleam ${gleam} \nrebar ${rebar3}`
|
|||||||
assert.ok(async () => {
|
assert.ok(async () => {
|
||||||
await setupBeam.install('gleam', { toolVersion: gleam })
|
await setupBeam.install('gleam', { toolVersion: gleam })
|
||||||
})
|
})
|
||||||
assert.ok(async () => {
|
|
||||||
await setupBeam.install('rebar3', { toolVersion: rebar3 })
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
simulateInput('otp-version', otpVersion)
|
simulateInput('otp-version', otpVersion)
|
||||||
simulateInput('elixir-version', elixirVersion)
|
simulateInput('elixir-version', elixirVersion)
|
||||||
simulateInput('gleam-version', gleamVersion)
|
simulateInput('gleam-version', gleamVersion)
|
||||||
simulateInput('rebar3-version', rebar3Version)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('.get(_)', () => {
|
describe('.get(_)', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user