Compare commits

...

22 Commits

Author SHA1 Message Date
GitHub Actions e6d7c94229 Automation: update setup-beam version output to fceaea9 2025-07-10 15:21:07 +00:00
Paulo F. Oliveira fceaea9f54 Fix: more versioning around nightly and maint/main (#359)
* Test Elixir main-otp-28 / Erlang maint-28

* Test Gleam nightly / OTP 28

* Tweak versioning

1. stop trying to "coerce" versions on input
2. handle `OTP-` in one more place
3. handle `nightly`

* Remove tests that should be failing previously

There is no strict 27 for macos-15, for example

* Remove similar tests

We'll test once per platform in similar conditions

* `await` for `assert.rejects` (not noticeable if alone inside `it`)

* Test maint- for strict and loose
2025-07-10 16:20:49 +01:00
GitHub Actions 2bb5b653d0 Automation: update setup-beam version output to 1d4efdd 2025-07-10 15:18:41 +00:00
dependabot[bot] 1d4efdd2e9 Bump globals from 16.2.0 to 16.3.0 (#361)
Bumps [globals](https://github.com/sindresorhus/globals) from 16.2.0 to 16.3.0.
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v16.2.0...v16.3.0)

---
updated-dependencies:
- dependency-name: globals
  dependency-version: 16.3.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-10 16:18:18 +01:00
GitHub Actions 73f047e328 Automation: update setup-beam version output to 6dd8a1a 2025-07-10 09:38:56 +00:00
dependabot[bot] 6dd8a1a852 Bump @eslint/js from 9.30.0 to 9.30.1 (#360)
Bumps [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js) from 9.30.0 to 9.30.1.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/commits/v9.30.1/packages/js)

---
updated-dependencies:
- dependency-name: "@eslint/js"
  dependency-version: 9.30.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-10 10:38:37 +01:00
GitHub Actions fd9a2e183f Automation: update setup-beam version output to 65085e3 2025-07-10 09:14:46 +00:00
dependabot[bot] 65085e37bc Bump eslint from 9.30.0 to 9.30.1 (#362)
Bumps [eslint](https://github.com/eslint/eslint) from 9.30.0 to 9.30.1.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.30.0...v9.30.1)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 9.30.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-10 10:14:28 +01:00
GitHub Actions 80c1659516 Automation: update setup-beam version output to 8e7fdef 2025-07-03 18:12:11 +00:00
GitHub Actions 8e7fdef09f Automation: update setup-beam version output to 1fe9179 2025-07-03 16:35:25 +00:00
Paulo F. Oliveira 1fe9179886 Handle .tool-versions' line break on Windows (#357)
* Test .tool-version on top of Windows

* Parse .tool-version with Windows-style line endings
2025-07-03 17:35:06 +01:00
GitHub Actions 6389fe58dc Automation: update setup-beam version output to 8fc1380 2025-07-01 21:13:33 +00:00
Paulo F. Oliveira 8fc1380bb7 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
2025-07-01 22:13:13 +01:00
GitHub Actions 3c915dd1b0 Automation: update setup-beam version output to e5d5058 2025-06-30 21:26:33 +00:00
dependabot[bot] e5d50587ee Bump @eslint/js from 9.29.0 to 9.30.0 (#352)
Bumps [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js) from 9.29.0 to 9.30.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/commits/v9.30.0/packages/js)

---
updated-dependencies:
- dependency-name: "@eslint/js"
  dependency-version: 9.30.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 22:26:13 +01:00
GitHub Actions b1273cf7cc Automation: update setup-beam version output to 9308caf 2025-06-30 21:10:39 +00:00
dependabot[bot] 9308cafcbf Bump prettier from 3.6.0 to 3.6.2 (#353)
Bumps [prettier](https://github.com/prettier/prettier) from 3.6.0 to 3.6.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.6.0...3.6.2)

---
updated-dependencies:
- dependency-name: prettier
  dependency-version: 3.6.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 22:09:53 +01:00
dependabot[bot] 2971b073e5 Bump eslint from 9.29.0 to 9.30.0 (#354)
Bumps [eslint](https://github.com/eslint/eslint) from 9.29.0 to 9.30.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.29.0...v9.30.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 9.30.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 22:09:35 +01:00
GitHub Actions a0b139a890 Automation: update setup-beam version output to 6a38171 2025-06-26 19:39:33 +00:00
Paulo F. Oliveira 6a38171948 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
2025-06-26 20:39:15 +01:00
GitHub Actions 75edbb8287 Automation: update setup-beam version output to a8bc27e 2025-06-24 23:13:55 +00:00
Paulo F. Oliveira a8bc27ec39 Add back deprecated runners with warning (#348)
Add back deprecated elements, with a warning on support/maintenance
2025-06-25 00:13:39 +01:00
10 changed files with 461 additions and 277 deletions
+9
View File
@@ -76,6 +76,7 @@ jobs:
uses: ./
with:
install-rebar: false
install-hex: false
version-file: test/.tool-versions
version-type: strict
@@ -89,6 +90,14 @@ jobs:
node-version: '20'
- run: npm install --production
- run: npm test
- name: .tool-versions test
id: setup-beam
uses: ./
with:
install-rebar: false
install-hex: false
version-file: test/.tool-versions
version-type: strict
unit_tests_macos:
name: Unit tests (macOS)
-6
View File
@@ -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'
- otp-version: '25'
os: 'macos-15'
- otp-version: '26'
+9 -6
View File
@@ -25,6 +25,15 @@ jobs:
fail-fast: false
matrix:
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'
elixir-version: 'v1.17.0'
rebar3-version: '3.23'
@@ -44,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'
+6
View File
@@ -25,6 +25,12 @@ jobs:
fail-fast: false
matrix:
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'
elixir-version: 'v1.17.0'
rebar3-version: '3.23'
+15 -9
View File
@@ -53,19 +53,25 @@ end up being parsed as `23`, which is not equivalent.
#### Pre-release versions
For pre-release versions, such as `v1.11.0-rc.0`, use the full version
specifier (`v1.11.0-rc.0`) and set option `version-type` to `strict`. Pre-release versions are
opt-in, so `1.11.x` will not match a pre-release.
To use a pre-release version such as `v1.11.0-rc.0`, specify the exact version
(`v1.11.0-rc.0`) and set `version-type` to `strict`.
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
Set a tool's version to `latest` to retrieve the latest version of a given tool.
The latest version is (locally) calculated by the action based on the (retrieved) versions
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).
To retrieve the most recent available version of a tool, set the version to `latest`.
This may include pre-release versions such as release candidates.
If in doubt do a test run and compare the obtained release with the one you were expecting to
be the latest.
If you want to target only the latest stable release and exclude pre-releases, use a
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
+121 -60
View File
@@ -25890,9 +25890,11 @@ const _ = __nccwpck_require__(2356)
const MAX_HTTP_RETRIES = 3
main().catch((err) => {
core.setFailed(err.message)
})
if (process.env.NODE_ENV !== 'test') {
main().catch((err) => {
core.setFailed(err.message)
})
}
async function main() {
checkOtpArchitecture()
@@ -25908,15 +25910,14 @@ async function main() {
versions = parseVersionFile(versionFilePath)
}
const osVersion = getRunnerOSVersion()
const otpSpec = getInput('otp-version', true, 'erlang', versions)
const elixirSpec = getInput('elixir-version', false, 'elixir', versions)
const gleamSpec = getInput('gleam-version', false, 'gleam', versions)
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
if (otpSpec !== 'false') {
await installOTP(otpSpec, osVersion)
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpSpec)
await installOTP(otpSpec)
const elixirInstalled = await maybeInstallElixir(elixirSpec)
if (elixirInstalled === true) {
const shouldMixRebar = getInput('install-rebar', false)
await mix(shouldMixRebar, 'rebar')
@@ -25932,11 +25933,12 @@ async function main() {
await maybeInstallRebar3(rebar3Spec)
// undefined is replaced by a function, post- main branch merge
const setupBeamVersion = 'abd725c'
const setupBeamVersion = 'fceaea9'
core.setOutput('setup-beam-version', setupBeamVersion)
}
async function installOTP(otpSpec, osVersion) {
async function installOTP(otpSpec) {
const osVersion = getRunnerOSVersion()
const otpVersion = await getOTPVersion(otpSpec, osVersion)
core.startGroup(
`Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`,
@@ -25958,10 +25960,10 @@ async function installOTP(otpSpec, osVersion) {
return otpVersion
}
async function maybeInstallElixir(elixirSpec, otpSpec) {
async function maybeInstallElixir(elixirSpec) {
let installed = false
if (elixirSpec) {
const elixirVersion = await getElixirVersion(elixirSpec, otpSpec)
const elixirVersion = await getElixirVersion(elixirSpec)
core.startGroup(`Installing Elixir ${elixirVersion}`)
await doWithMirrors({
hexMirrors: hexMirrorsInput(),
@@ -26043,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)
@@ -26070,16 +26076,30 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
const knownBranches = ['main', 'master', 'maint']
const nonSpecificVersions = ['nightly', 'latest']
async function getElixirVersion(exSpec0, otpVersion0) {
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
async function getElixirVersion(exSpec0) {
const otpSuffix = /-otp-(\d+)/
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
let otpVersionMajor = ''
if (userSuppliedOtp && isVersion(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] =
@@ -26094,17 +26114,29 @@ async function getElixirVersion(exSpec0, otpVersion0) {
)
}
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
if (
(elixirVersionComp && elixirVersionComp.includes(otpVersionMajor)) ||
!isVersion(otpVersionMajor)
) {
core.info(
`Using Elixir ${elixirVersionFromSpec} (built for Erlang/OTP ${otpVersionMajor})`,
)
} else {
let foundCombo = false
let otpVersionMajorIter = parseInt(otpVersionMajor)
let otpVersionsMajor = []
while (otpVersionMajorIter > otpVersionMajor - 3) {
otpVersionMajorIter += ''
otpVersionsMajor.push(otpVersionMajorIter)
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
if (
(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(
`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?).' +
'Elixir and Erlang/OTP compatibility can be found at: ' +
'https://hexdocs.pm/elixir/compatibility-and-deprecations.html',
@@ -26113,8 +26145,8 @@ async function getElixirVersion(exSpec0, otpVersion0) {
let elixirVersionForDownload = elixirVersionFromSpec
if (isVersion(otpVersionMajor)) {
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajor}`
if (isVersion(otpVersionMajorIter)) {
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajorIter}`
}
return maybePrependWithV(elixirVersionForDownload)
@@ -26196,12 +26228,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') {
@@ -26215,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') {
@@ -26227,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
})
}
@@ -26323,6 +26351,7 @@ function validVersion(v) {
v.match(
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
) == null &&
// these ones are for rebar3, which has alpha and beta releases
!v.startsWith('a') &&
!v.startsWith('b')
)
@@ -26349,8 +26378,14 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced
if (isStrictVersion() || isRC(version)) {
// If `version-type: strict` or version is RC, we just try to remove a potential initial v
if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
// 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
@@ -26367,13 +26402,19 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null
if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0) ||
spec0 === 'nightly'
) {
if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly
// 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
@@ -26486,17 +26527,33 @@ function getRunnerOSVersion() {
macos14: 'macOS-14',
macos15: 'macOS-15',
}
const deprecatedImageOSToContainer = {
ubuntu18: 'ubuntu-18.04',
ubuntu20: 'ubuntu-20.04',
}
const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS]
if (!containerFromEnvImageOS) {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS' (got " +
`${process.env.ImageOS}` +
"), but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
`${Object.keys(ImageOSToContainer).join("', '")}` +
"']",
)
const deprecatedContainerFromEnvImageOS =
deprecatedImageOSToContainer[process.env.ImageOS]
if (deprecatedContainerFromEnvImageOS) {
core.warning(
`You are using deprecated ImageOS ${deprecatedContainerFromEnvImageOS}. ` +
'Support for maintenance is very limited. Consider a non-deprecated version as ' +
'mentioned in the README.md.',
)
return deprecatedContainerFromEnvImageOS
} else {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS' (got " +
`${process.env.ImageOS}` +
"), but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
`${Object.keys(ImageOSToContainer).join("', '")}` +
"']",
)
}
}
return containerFromEnvImageOS
@@ -26576,7 +26633,7 @@ function xyzAbcVersion(pref, suf) {
// https://www.erlang.org/doc/system_principles/versions.html
const dd = '\\.?(\\d+)?'
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}`,
)
}
@@ -26625,7 +26682,7 @@ function parseVersionFile(versionFilePath0) {
// For the time being we parse .tool-versions
// If we ever start parsing something else, this should
// become default in a new option named e.g. version-file-type
versions.split('\n').forEach((line) => {
versions.split(/\r?\n/).forEach((line) => {
const appVersion = line.match(/^([^ ]+)[ ]+(ref:v?)?([^ #]+)/)
if (appVersion) {
const app = appVersion[1]
@@ -27046,14 +27103,18 @@ function debugLoggingEnabled() {
module.exports = {
get,
getOTPVersion,
getElixirVersion,
getGleamVersion,
getOTPVersion,
getRebar3Version,
getVersionFromSpec,
githubAMDRunnerArchs,
githubARMRunnerArchs,
install,
installOTP,
maybeInstallElixir,
maybeInstallGleam,
maybeInstallRebar3,
parseVersionFile,
}
+25 -30
View File
@@ -15,13 +15,13 @@
"semver": "7.7.2"
},
"devDependencies": {
"@eslint/js": "9.29.0",
"@eslint/js": "9.30.1",
"@vercel/ncc": "0.38.3",
"eslint": "9.29.0",
"eslint": "9.30.1",
"eslint-plugin-yml": "1.18.0",
"globals": "16.2.0",
"globals": "16.3.0",
"markdownlint-cli": "0.45.0",
"prettier": "3.6.0",
"prettier": "3.6.2",
"shellcheck": "3.1.0",
"yarn": "1.22.22"
},
@@ -116,11 +116,10 @@
}
},
"node_modules/@eslint/config-array": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.20.1.tgz",
"integrity": "sha512-OL0RJzC/CBzli0DrrR31qzj6d6i6Mm3HByuhflhl4LOBiWxN+3i6/t/ZQQNii4tjksXi8r2CRW1wMpWA2ULUEw==",
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.0.tgz",
"integrity": "sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@eslint/object-schema": "^2.1.6",
"debug": "^4.3.1",
@@ -131,11 +130,10 @@
}
},
"node_modules/@eslint/config-helpers": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.2.2.tgz",
"integrity": "sha512-+GPzk8PlG0sPpzdU5ZvIRMPidzAnZDl/s9L+y13iodqvb8leL53bTannOrQ/Im7UkpsmFU5Ily5U60LWixnmLg==",
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.0.tgz",
"integrity": "sha512-ViuymvFmcJi04qdZeDc2whTHryouGcDlaxPqarTD0ZE10ISpxGUVZGZDx4w01upyIynL3iu6IXH2bS1NhclQMw==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
@@ -191,9 +189,9 @@
}
},
"node_modules/@eslint/js": {
"version": "9.29.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.29.0.tgz",
"integrity": "sha512-3PIF4cBw/y+1u2EazflInpV+lYsSG0aByVIQzAgb1m1MhHFSbqTyNqtBKHgWf/9Ykud+DhILS9EGkmekVhbKoQ==",
"version": "9.30.1",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.30.1.tgz",
"integrity": "sha512-zXhuECFlyep42KZUhWjfvsmXGX39W8K8LFb8AWXM9gSV9dQB+MrJGLKvW6Zw0Ggnbpw0VHTtrhFXYe3Gym18jg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -208,7 +206,6 @@
"resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz",
"integrity": "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
@@ -967,19 +964,18 @@
}
},
"node_modules/eslint": {
"version": "9.29.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.29.0.tgz",
"integrity": "sha512-GsGizj2Y1rCWDu6XoEekL3RLilp0voSePurjZIkxL3wlm5o5EC9VpgaP7lrCvjnkuLvzFBQWB3vWB3K5KQTveQ==",
"version": "9.30.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.30.1.tgz",
"integrity": "sha512-zmxXPNMOXmwm9E0yQLi5uqXHs7uq2UIiqEKo3Gq+3fwo1XrJ+hijAZImyF7hclW3E6oHz43Yk3RP8at6OTKflQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.12.1",
"@eslint/config-array": "^0.20.1",
"@eslint/config-helpers": "^0.2.1",
"@eslint/config-array": "^0.21.0",
"@eslint/config-helpers": "^0.3.0",
"@eslint/core": "^0.14.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "9.29.0",
"@eslint/js": "9.30.1",
"@eslint/plugin-kit": "^0.3.1",
"@humanfs/node": "^0.16.6",
"@humanwhocodes/module-importer": "^1.0.1",
@@ -1411,9 +1407,9 @@
}
},
"node_modules/globals": {
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz",
"integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==",
"version": "16.3.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-16.3.0.tgz",
"integrity": "sha512-bqWEnJ1Nt3neqx2q5SFfGS8r/ahumIakg3HcwtNlrVlwXIeNumWn/c7Pn/wKzGhf6SaW6H6uWXLqC30STCMchQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2777,11 +2773,10 @@
}
},
"node_modules/prettier": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.0.tgz",
"integrity": "sha512-ujSB9uXHJKzM/2GBuE0hBOUgC77CN3Bnpqa+g80bkv3T3A93wL/xlzDATHhnhkzifz/UE2SNOvmbTz5hSkDlHw==",
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"dev": true,
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
+4 -4
View File
@@ -25,11 +25,11 @@
},
"devDependencies": {
"@vercel/ncc": "0.38.3",
"eslint": "9.29.0",
"@eslint/js": "9.29.0",
"globals": "16.2.0",
"eslint": "9.30.1",
"@eslint/js": "9.30.1",
"globals": "16.3.0",
"markdownlint-cli": "0.45.0",
"prettier": "3.6.0",
"prettier": "3.6.2",
"shellcheck": "3.1.0",
"eslint-plugin-yml": "1.18.0",
"yarn": "1.22.22"
+121 -60
View File
@@ -10,9 +10,11 @@ const _ = require('lodash')
const MAX_HTTP_RETRIES = 3
main().catch((err) => {
core.setFailed(err.message)
})
if (process.env.NODE_ENV !== 'test') {
main().catch((err) => {
core.setFailed(err.message)
})
}
async function main() {
checkOtpArchitecture()
@@ -28,15 +30,14 @@ async function main() {
versions = parseVersionFile(versionFilePath)
}
const osVersion = getRunnerOSVersion()
const otpSpec = getInput('otp-version', true, 'erlang', versions)
const elixirSpec = getInput('elixir-version', false, 'elixir', versions)
const gleamSpec = getInput('gleam-version', false, 'gleam', versions)
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
if (otpSpec !== 'false') {
await installOTP(otpSpec, osVersion)
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpSpec)
await installOTP(otpSpec)
const elixirInstalled = await maybeInstallElixir(elixirSpec)
if (elixirInstalled === true) {
const shouldMixRebar = getInput('install-rebar', false)
await mix(shouldMixRebar, 'rebar')
@@ -52,11 +53,12 @@ async function main() {
await maybeInstallRebar3(rebar3Spec)
// undefined is replaced by a function, post- main branch merge
const setupBeamVersion = 'abd725c'
const setupBeamVersion = 'fceaea9'
core.setOutput('setup-beam-version', setupBeamVersion)
}
async function installOTP(otpSpec, osVersion) {
async function installOTP(otpSpec) {
const osVersion = getRunnerOSVersion()
const otpVersion = await getOTPVersion(otpSpec, osVersion)
core.startGroup(
`Installing Erlang/OTP ${otpVersion} - built on ${getRunnerOSArchitecture()}/${osVersion}`,
@@ -78,10 +80,10 @@ async function installOTP(otpSpec, osVersion) {
return otpVersion
}
async function maybeInstallElixir(elixirSpec, otpSpec) {
async function maybeInstallElixir(elixirSpec) {
let installed = false
if (elixirSpec) {
const elixirVersion = await getElixirVersion(elixirSpec, otpSpec)
const elixirVersion = await getElixirVersion(elixirSpec)
core.startGroup(`Installing Elixir ${elixirVersion}`)
await doWithMirrors({
hexMirrors: hexMirrorsInput(),
@@ -168,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)
@@ -195,16 +201,30 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
const knownBranches = ['main', 'master', 'maint']
const nonSpecificVersions = ['nightly', 'latest']
async function getElixirVersion(exSpec0, otpVersion0) {
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
async function getElixirVersion(exSpec0) {
const otpSuffix = /-otp-(\d+)/
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
let otpVersionMajor = ''
if (userSuppliedOtp && isVersion(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] =
@@ -219,17 +239,29 @@ async function getElixirVersion(exSpec0, otpVersion0) {
)
}
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
if (
(elixirVersionComp && elixirVersionComp.includes(otpVersionMajor)) ||
!isVersion(otpVersionMajor)
) {
core.info(
`Using Elixir ${elixirVersionFromSpec} (built for Erlang/OTP ${otpVersionMajor})`,
)
} else {
let foundCombo = false
let otpVersionMajorIter = parseInt(otpVersionMajor)
let otpVersionsMajor = []
while (otpVersionMajorIter > otpVersionMajor - 3) {
otpVersionMajorIter += ''
otpVersionsMajor.push(otpVersionMajorIter)
const elixirVersionComp = otpVersionsForElixirMap[elixirVersionFromSpec]
if (
(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(
`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?).' +
'Elixir and Erlang/OTP compatibility can be found at: ' +
'https://hexdocs.pm/elixir/compatibility-and-deprecations.html',
@@ -238,8 +270,8 @@ async function getElixirVersion(exSpec0, otpVersion0) {
let elixirVersionForDownload = elixirVersionFromSpec
if (isVersion(otpVersionMajor)) {
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajor}`
if (isVersion(otpVersionMajorIter)) {
elixirVersionForDownload = `${elixirVersionFromSpec}-otp-${otpVersionMajorIter}`
}
return maybePrependWithV(elixirVersionForDownload)
@@ -321,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') {
@@ -340,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') {
@@ -352,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
})
}
@@ -448,6 +476,7 @@ function validVersion(v) {
v.match(
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
) == null &&
// these ones are for rebar3, which has alpha and beta releases
!v.startsWith('a') &&
!v.startsWith('b')
)
@@ -474,8 +503,14 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced
if (isStrictVersion() || isRC(version)) {
// If `version-type: strict` or version is RC, we just try to remove a potential initial v
if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
// 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
@@ -492,13 +527,19 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null
if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0) ||
spec0 === 'nightly'
) {
if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly
// 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
@@ -611,17 +652,33 @@ function getRunnerOSVersion() {
macos14: 'macOS-14',
macos15: 'macOS-15',
}
const deprecatedImageOSToContainer = {
ubuntu18: 'ubuntu-18.04',
ubuntu20: 'ubuntu-20.04',
}
const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS]
if (!containerFromEnvImageOS) {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS' (got " +
`${process.env.ImageOS}` +
"), but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
`${Object.keys(ImageOSToContainer).join("', '")}` +
"']",
)
const deprecatedContainerFromEnvImageOS =
deprecatedImageOSToContainer[process.env.ImageOS]
if (deprecatedContainerFromEnvImageOS) {
core.warning(
`You are using deprecated ImageOS ${deprecatedContainerFromEnvImageOS}. ` +
'Support for maintenance is very limited. Consider a non-deprecated version as ' +
'mentioned in the README.md.',
)
return deprecatedContainerFromEnvImageOS
} else {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS' (got " +
`${process.env.ImageOS}` +
"), but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
`${Object.keys(ImageOSToContainer).join("', '")}` +
"']",
)
}
}
return containerFromEnvImageOS
@@ -701,7 +758,7 @@ function xyzAbcVersion(pref, suf) {
// https://www.erlang.org/doc/system_principles/versions.html
const dd = '\\.?(\\d+)?'
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}`,
)
}
@@ -750,7 +807,7 @@ function parseVersionFile(versionFilePath0) {
// For the time being we parse .tool-versions
// If we ever start parsing something else, this should
// become default in a new option named e.g. version-file-type
versions.split('\n').forEach((line) => {
versions.split(/\r?\n/).forEach((line) => {
const appVersion = line.match(/^([^ ]+)[ ]+(ref:v?)?([^ #]+)/)
if (appVersion) {
const app = appVersion[1]
@@ -1171,13 +1228,17 @@ function debugLoggingEnabled() {
module.exports = {
get,
getOTPVersion,
getElixirVersion,
getGleamVersion,
getOTPVersion,
getRebar3Version,
getVersionFromSpec,
githubAMDRunnerArchs,
githubARMRunnerArchs,
install,
installOTP,
maybeInstallElixir,
maybeInstallGleam,
maybeInstallRebar3,
parseVersionFile,
}
+151 -102
View File
@@ -1,3 +1,5 @@
process.env.NODE_ENV = 'test'
simulateInput('otp-version', '25.1.2')
simulateInput('otp-architecture', '64')
simulateInput('elixir-version', '1.14.2')
@@ -75,7 +77,7 @@ describe('OTP install', () => {
const otpOSVersion = 'ubuntu-08.04'
const otpVersion = 'OTP-23.2'
assert.rejects(
await assert.rejects(
async () => {
await setupBeam.install('otp', {
hexMirror: 'https://builds.hex.pm',
@@ -95,7 +97,7 @@ describe('OTP install', () => {
describe('Elixir install', () => {
it('fails for version 0.11 without OTP', async () => {
const exVersion = '0.11'
assert.rejects(
await assert.rejects(
async () => {
await setupBeam.install('elixir', {
hexMirror: 'https://builds.hex.pm',
@@ -112,7 +114,7 @@ describe('Elixir install', () => {
it('fails for version 1.0.0 on OTP 17 (without OTP)', async () => {
const exVersion = 'v1.0.0-otp-17'
assert.rejects(
await assert.rejects(
async () => {
await setupBeam.install('elixir', {
hexMirror: 'https://builds.hex.pm',
@@ -131,7 +133,7 @@ describe('Elixir install', () => {
describe('Gleam install', () => {
it('fails for unknown OTP', async () => {
const gleamVersion = '0.1.3'
assert.rejects(
await assert.rejects(
async () => {
await setupBeam.install('gleam', { gleamVersion })
},
@@ -147,7 +149,7 @@ describe('Gleam install', () => {
describe('rebar3 install', () => {
it('fails for unknown OTP', async () => {
const r3Version = '0.14.4'
assert.rejects(
await assert.rejects(
async () => {
await setupBeam.install('rebar3', { r3Version })
},
@@ -177,14 +179,6 @@ describe('.getOTPVersion(_) - Erlang', () => {
process.env.RUNNER_ARCH = 'X64'
it('is Ok for known linux version', async () => {
before = simulateInput('version-type', 'strict')
spec = '26'
osVersion = 'ubuntu-24.04'
expected = 'maint-26'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = '27.0'
osVersion = 'ubuntu-24.04'
@@ -309,19 +303,46 @@ describe('.getOTPVersion(_) - Erlang', () => {
}
if (process.platform === 'linux') {
it('is Ok for known linux ARM64 version', async () => {
it('is main-... only if strict/maint-... is used as input', async () => {
const arm64Options = setupBeam.githubARMRunnerArchs()
process.env.RUNNER_ARCH =
arm64Options[Math.floor(Math.random() * arm64Options.length)]
before = simulateInput('version-type', 'strict')
spec = '26'
osVersion = 'ubuntu-24.04'
expected = 'maint-26'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)
await assert.rejects(
async () => {
await setupBeam.getOTPVersion('27', 'ubuntu-24.04')
},
(err) => {
assert.ok(err instanceof Error)
return true
},
`Fetching strict OTP version maint-<v> with input <v> is supposed to fail`,
)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
assert.strictEqual(
await setupBeam.getOTPVersion('maint-27', 'ubuntu-24.04'),
'maint-27',
)
simulateInput('version-type', before)
before = simulateInput('version-type', 'loose')
assert.strictEqual(
await setupBeam.getOTPVersion('maint-27', 'ubuntu-24.04'),
'maint-27',
)
simulateInput('version-type', before)
process.env.RUNNER_ARCH = previousRunnerArch
})
it('is Ok for known linux ARM64 version', async () => {
const arm64Options = setupBeam.githubARMRunnerArchs()
process.env.RUNNER_ARCH =
arm64Options[Math.floor(Math.random() * arm64Options.length)]
before = simulateInput('version-type', 'strict')
spec = '27.0'
osVersion = 'ubuntu-24.04'
@@ -386,14 +407,6 @@ describe('.getOTPVersion(_) - Erlang', () => {
process.env.RUNNER_ARCH =
amd64Options[Math.floor(Math.random() * amd64Options.length)]
before = simulateInput('version-type', 'strict')
spec = '26'
osVersion = 'ubuntu-24.04'
expected = 'maint-26'
got = await setupBeam.getOTPVersion(spec, osVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = '27.0'
osVersion = 'ubuntu-24.04'
@@ -473,6 +486,35 @@ describe('.getOTPVersion(_) - Erlang', () => {
}
if (process.platform === 'darwin') {
it('is main-... only if strict/maint-... is used as input', async () => {
const arm64Options = setupBeam.githubARMRunnerArchs()
process.env.RUNNER_ARCH =
arm64Options[Math.floor(Math.random() * arm64Options.length)]
before = simulateInput('version-type', 'strict')
await assert.rejects(
async () => {
await setupBeam.getOTPVersion('27')
},
(err) => {
assert.ok(err instanceof Error)
return true
},
`Fetching strict OTP version maint-<v> with input <v> is supposed to fail`,
)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
assert.strictEqual(await setupBeam.getOTPVersion('maint-27'), 'maint-27')
simulateInput('version-type', before)
before = simulateInput('version-type', 'loose')
assert.strictEqual(await setupBeam.getOTPVersion('maint-27'), 'maint-27')
simulateInput('version-type', before)
process.env.RUNNER_ARCH = previousRunnerArch
})
it('is Ok for known macos ARM64 version', async () => {
const arm64Options = setupBeam.githubARMRunnerArchs()
process.env.RUNNER_ARCH =
@@ -515,7 +557,7 @@ describe('OTP arch-specific install', () => {
const spec = '26'
const osVersion = 'ubuntu-24.04'
assert.rejects(
await assert.rejects(
async () => {
await setupBeam.getOTPVersion(spec, osVersion)
},
@@ -536,77 +578,70 @@ describe('.getOTPVersion(_) - Elixir', () => {
let spec
let otpVersion
let before
const hexMirrors = simulateInput('hexpm-mirrors', 'https://repo.hex.pm', {
multiline: true,
})
const previousRunnerArch = process.env.RUNNER_ARCH
it('returns the expected value', async () => {
spec = '1.1.x'
otpVersion = 'OTP-17'
expected = 'v1.1.1-otp-17'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
if (process.platform === 'linux') {
process.env.RUNNER_ARCH = 'X64'
spec = '1.10.4'
otpVersion = 'OTP-23'
expected = 'v1.10.4-otp-23'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
it('returns the expected value', async () => {
spec = '1.18.x'
otpVersion = 'OTP-27'
expected = 'v1.18.4-otp-27'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
spec = '1.16.2-otp-26'
otpVersion = 'OTP-27'
expected = 'v1.16.2-otp-26'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
spec = '1.18.2'
otpVersion = 'OTP-27'
expected = 'v1.18.2-otp-27'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
spec = '1.12.1'
otpVersion = 'OTP-24.0.2'
expected = 'v1.12.1-otp-24'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
spec = '1.16.2-otp-26'
otpVersion = 'OTP-27'
expected = 'v1.16.2-otp-26'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
before = simulateInput('version-type', 'strict')
spec = '1.14.0'
otpVersion = 'main'
expected = 'v1.14.0'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
spec = '1.12.1'
otpVersion = 'OTP-24.3.4'
expected = 'v1.12.1-otp-24'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
before = simulateInput('version-type', 'strict')
spec = 'v1.11.0-rc.0'
otpVersion = 'OTP-23'
expected = 'v1.11.0-rc.0-otp-23'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = '1.17'
otpVersion = 'master'
expected = 'v1.17-otp-27'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = 'v1.11.0-rc.0-otp-23'
otpVersion = 'OTP-23'
expected = 'v1.11.0-rc.0-otp-23'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = 'v1.15.0-rc.2'
otpVersion = 'OTP-26.0'
expected = 'v1.15.0-rc.2-otp-26'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = 'v1.11.0'
otpVersion = '22.3.4.2'
expected = 'v1.11.0-otp-22'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
before = simulateInput('version-type', 'strict')
spec = 'main'
otpVersion = '25.2'
expected = 'main-otp-25'
await setupBeam.installOTP(otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)
})
}
before = simulateInput('version-type', 'strict')
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 })
process.env.RUNNER_ARCH = previousRunnerArch
})
describe('.getOTPVersion(_) - Gleam', () => {
@@ -622,6 +657,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)
spec = '0.13.2'
otpVersion = 'OTP-24'
expected = 'v0.13.2'
@@ -875,11 +916,21 @@ describe('.getVersionFromSpec(_)', () => {
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-20.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'
expected = 'OTP-27.0-rc3'
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'
expected = 'OTP-27.0'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04'])
@@ -921,19 +972,21 @@ describe('version file', () => {
const otpVersion = unsimulateInput('otp-version')
const elixirVersion = unsimulateInput('elixir-version')
const gleamVersion = unsimulateInput('gleam-version')
const rebar3Version = unsimulateInput('rebar3-version')
it('is parsed correctly', async () => {
const erlang = '27'
const elixir = '1.17.0'
const gleam = '0.23.0'
const rebar3 = '3.24.0'
const toolVersions = `# a comment
erlang ref:v${erlang}# comment, no space, and ref:v
const erlang = '27.3.4.1'
const elixir = '1.18.4'
const gleam = '1.9.1'
let toolVersions = `# a comment
erlang ref:v${erlang}
elixir ref:${elixir} # comment, with space and ref:
not-gleam 0.23 # not picked up
gleam ${gleam} \nrebar ${rebar3}`
gleam ${gleam} \n`
const filename = 'test/.tool-versions'
if (process.platform === 'win32') {
// Force \r\n to test in Windows
toolVersions = toolVersions.replace(/\n/g, '\r\n')
}
fs.writeFileSync(filename, toolVersions)
process.env.GITHUB_WORKSPACE = ''
const appVersions = setupBeam.parseVersionFile(filename)
@@ -957,15 +1010,11 @@ gleam ${gleam} \nrebar ${rebar3}`
assert.ok(async () => {
await setupBeam.install('gleam', { toolVersion: gleam })
})
assert.ok(async () => {
await setupBeam.install('rebar3', { toolVersion: rebar3 })
})
})
simulateInput('otp-version', otpVersion)
simulateInput('elixir-version', elixirVersion)
simulateInput('gleam-version', gleamVersion)
simulateInput('rebar3-version', rebar3Version)
})
describe('.get(_)', () => {