Skip to content

Commit aa4b8a4

Browse files
Implement for tests
1 parent 58078e9 commit aa4b8a4

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

dist/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25915,8 +25915,8 @@ async function main() {
2591525915
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
2591625916

2591725917
if (otpSpec !== 'false') {
25918-
await installOTP(otpSpec, osVersion)
25919-
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpSpec)
25918+
const otpVersion = await installOTP(otpSpec, osVersion)
25919+
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion)
2592025920
if (elixirInstalled === true) {
2592125921
const shouldMixRebar = getInput('install-rebar', false)
2592225922
await mix(shouldMixRebar, 'rebar')
@@ -25958,10 +25958,10 @@ async function installOTP(otpSpec, osVersion) {
2595825958
return otpVersion
2595925959
}
2596025960

25961-
async function maybeInstallElixir(elixirSpec, otpSpec) {
25961+
async function maybeInstallElixir(elixirSpec, otpVersion) {
2596225962
let installed = false
2596325963
if (elixirSpec) {
25964-
const elixirVersion = await getElixirVersion(elixirSpec, otpSpec)
25964+
const elixirVersion = await getElixirVersion(elixirSpec, otpVersion)
2596525965
core.startGroup(`Installing Elixir ${elixirVersion}`)
2596625966
await doWithMirrors({
2596725967
hexMirrors: hexMirrorsInput(),
@@ -26067,13 +26067,16 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
2606726067
)
2606826068
}
2606926069

26070-
const knownBranches = ['main', 'master', 'maint']
26070+
const knownBranches = ['master', 'maint', 'main']
2607126071
const nonSpecificVersions = ['nightly', 'latest']
2607226072

2607326073
async function getElixirVersion(exSpec0, otpVersion0) {
26074-
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
26075-
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
26076-
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
26074+
let otpVersion = otpVersion0.replace(/-rc.*/, '')
26075+
knownBranches.forEach((branch) => {
26076+
otpVersion = otpVersion.replace(`${branch}-`, '').replace(`${branch}`, '')
26077+
})
26078+
// after this we should have either a number-string of an empty string
26079+
let otpVersionMajor = otpVersion.match(/(\d{1,3}).*/)?.[1] ?? null
2607726080

2607826081
const otpSuffix = /-otp-(\d+)/
2607926082
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null

src/setup-beam.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ async function main() {
3535
const rebar3Spec = getInput('rebar3-version', false, 'rebar', versions)
3636

3737
if (otpSpec !== 'false') {
38-
await installOTP(otpSpec, osVersion)
39-
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpSpec)
38+
const otpVersion = await installOTP(otpSpec, osVersion)
39+
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion)
4040
if (elixirInstalled === true) {
4141
const shouldMixRebar = getInput('install-rebar', false)
4242
await mix(shouldMixRebar, 'rebar')
@@ -78,10 +78,10 @@ async function installOTP(otpSpec, osVersion) {
7878
return otpVersion
7979
}
8080

81-
async function maybeInstallElixir(elixirSpec, otpSpec) {
81+
async function maybeInstallElixir(elixirSpec, otpVersion) {
8282
let installed = false
8383
if (elixirSpec) {
84-
const elixirVersion = await getElixirVersion(elixirSpec, otpSpec)
84+
const elixirVersion = await getElixirVersion(elixirSpec, otpVersion)
8585
core.startGroup(`Installing Elixir ${elixirVersion}`)
8686
await doWithMirrors({
8787
hexMirrors: hexMirrorsInput(),
@@ -192,13 +192,16 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
192192
)
193193
}
194194

195-
const knownBranches = ['main', 'master', 'maint']
195+
const knownBranches = ['master', 'maint', 'main']
196196
const nonSpecificVersions = ['nightly', 'latest']
197197

198198
async function getElixirVersion(exSpec0, otpVersion0) {
199-
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
200-
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
201-
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
199+
let otpVersion = otpVersion0.replace(/-rc.*/, '')
200+
knownBranches.forEach((branch) => {
201+
otpVersion = otpVersion.replace(`${branch}-`, '').replace(`${branch}`, '')
202+
})
203+
// after this we should have either a number-string of an empty string
204+
let otpVersionMajor = otpVersion.match(/(\d{1,3}).*/)?.[1] ?? null
202205

203206
const otpSuffix = /-otp-(\d+)/
204207
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null

0 commit comments

Comments
 (0)