mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-22 22:56:07 +00:00
Introduce rebar-version (#9)
Previously (Remove redundant code) (+27 squashed commits) Squashed commits: [0b79c31] Rename as setup-beam [312b42b] Simplify platform verification [b43ca96] Prevent use of OTP- prefixed Erlang/OTP versions [103a236] Move the promise-based approach to an async-based approach (not testing for failure, so not guaranteeing readable/usable output either) [1e7f631] Remove local test files [d03e0c6] Prevent use of -otp- infixed Elixir versions [697110e] Have versions output in action, not just in tests [7360781] Ease test validations [71e6999] Reinstall tests that were there before [6602f20] Attempt at simplifying regexp matching with build listings [09247af] Provide for an Elixir to "not OTP" fallback mechanism (as explained by the comments) [dfc4083] Attempt at renaming for clarity We also get rid of return values when not reachable We also move the `-otp-` part of the Elixir version upstream so it's easy to reason about (and update the tests accordingly) [0d4eb28] Bump our dep.s (trying to figure out why core.setFailed isn't making the action fail, as it should) [ebf48ef] Have action fail (with an exception) when no expected version is found (we otherwise feel that a simple warning is not enough, as it may end up hiding potential bugs) [8478364] Adapt tests to our actual inputs [16ea63d] Add prettier again, now sync'ed with jslint (pass it on the code, already) [cfc65df] Improve error messages and tests [a017948] Test unavailable Elixir upon mix [7f2a3e9] Test failing installations Also output core.error when expected [08061ca] Attempt at making shell scripts more robust [4ee73cb] Separate test code from production code 1. inputs (for CI) are managed by code, not by .yml env. variables 2. rebar3_builds.txt added for stable repeatability 3. tests tweaked to make it easier to modify and drop dependency on production code 4. `dist` regenerated (duplicate files gone) 5. setup-elixir.js tweaked to this new reality [d17fed4] Remove prettier from the package [7d6f8f5] Actually break CI when we should [b972eaf] Remove unrequired element [0ffa28a] Ease maintenance and readability [4690169] Fix as per broken tests [a1371c6] Merge setup-erlang in
This commit is contained in:
committed by
GitHub
parent
86521d7b4d
commit
89cb00455a
+149
-12
@@ -1,21 +1,158 @@
|
||||
const {getElixirVersion} = require('../src/setup-beam')
|
||||
const {deepStrictEqual} = require('assert')
|
||||
simulateInput('otp-version', '23.2')
|
||||
simulateInput('elixir-version', '1.11')
|
||||
simulateInput('rebar3-version', '3.14')
|
||||
simulateInput('install-rebar', 'true')
|
||||
simulateInput('install-hex', 'true')
|
||||
|
||||
async function test() {
|
||||
let vsn
|
||||
vsn = await getElixirVersion('v1.10.x', '23')
|
||||
deepStrictEqual(vsn, ['v1.10.4', '23'])
|
||||
const setupElixir = require('../src/setup-beam')
|
||||
const assert = require('assert')
|
||||
const installer = require('../src/installer')
|
||||
|
||||
vsn = await getElixirVersion('^v1.10', '23')
|
||||
deepStrictEqual(vsn, ['v1.10.4', '23'])
|
||||
async function all() {
|
||||
await testFailInstallOTP()
|
||||
await testFailInstallElixir()
|
||||
await testFailInstallRebar3()
|
||||
|
||||
vsn = await getElixirVersion('v1.11.0-rc.0', '23')
|
||||
deepStrictEqual(vsn, ['v1.11.0-rc.0', '23'])
|
||||
await testOTPVersions()
|
||||
await testElixirVersions()
|
||||
await testRebar3Versions()
|
||||
}
|
||||
|
||||
test()
|
||||
async function testFailInstallOTP() {
|
||||
const otpOSVersion = 'ubuntu-08.04'
|
||||
const otpVersion = 'OTP-23.2'
|
||||
assert.rejects(
|
||||
async () => {
|
||||
await installer.installOTP(otpOSVersion, otpVersion)
|
||||
},
|
||||
(err) => {
|
||||
assert.ok(err instanceof Error)
|
||||
return true
|
||||
},
|
||||
`Installing Erlang/OTP ${otpVersion} over ${otpOSVersion} is supposed to fail`,
|
||||
)
|
||||
}
|
||||
|
||||
async function testFailInstallElixir() {
|
||||
let exVersion
|
||||
|
||||
exVersion = '0.11'
|
||||
assert.rejects(
|
||||
async () => {
|
||||
await installer.installElixir(exVersion)
|
||||
},
|
||||
(err) => {
|
||||
assert.ok(err instanceof Error)
|
||||
return true
|
||||
},
|
||||
`Installing Elixir ${exVersion} is supposed to fail`,
|
||||
)
|
||||
|
||||
exVersion = 'v1.0.0-otp-17'
|
||||
assert.rejects(
|
||||
async () => {
|
||||
await installer.installElixir(exVersion)
|
||||
},
|
||||
(err) => {
|
||||
assert.ok(err instanceof Error)
|
||||
return true
|
||||
},
|
||||
`Installing Elixir ${exVersion} is supposed to fail`,
|
||||
)
|
||||
}
|
||||
|
||||
async function testFailInstallRebar3() {
|
||||
const r3Version = '0.14.4'
|
||||
assert.rejects(
|
||||
async () => {
|
||||
await installer.installRebar3(r3Version)
|
||||
},
|
||||
(err) => {
|
||||
assert.ok(err instanceof Error)
|
||||
return true
|
||||
},
|
||||
`Installing rebar3 ${r3Version} is supposed to fail`,
|
||||
)
|
||||
}
|
||||
|
||||
async function testOTPVersions() {
|
||||
let got
|
||||
let expected
|
||||
let spec
|
||||
let osVersion
|
||||
|
||||
spec = '19.3.x'
|
||||
osVersion = 'ubuntu-16.04'
|
||||
expected = 'OTP-19.3.6'
|
||||
got = await setupElixir.getOTPVersion(spec, osVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '^19.3.6'
|
||||
osVersion = 'ubuntu-16.04'
|
||||
expected = 'OTP-19.3.6'
|
||||
got = await setupElixir.getOTPVersion(spec, osVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '^19.3'
|
||||
osVersion = 'ubuntu-18.04'
|
||||
expected = 'OTP-19.3.6'
|
||||
got = await setupElixir.getOTPVersion(spec, osVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
}
|
||||
|
||||
async function testElixirVersions() {
|
||||
let got
|
||||
let expected
|
||||
let spec
|
||||
let otpVersion
|
||||
|
||||
spec = '1.1.x'
|
||||
otpVersion = 'OTP-23'
|
||||
expected = 'v1.1.1'
|
||||
got = await setupElixir.getElixirVersion(spec, otpVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '1.10.4'
|
||||
otpVersion = 'OTP-23'
|
||||
expected = 'v1.10.4-otp-23'
|
||||
got = await setupElixir.getElixirVersion(spec, otpVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '1.11.0-rc.0'
|
||||
otpVersion = 'OTP-23'
|
||||
expected = 'v1.11.0-rc.0-otp-23'
|
||||
got = await setupElixir.getElixirVersion(spec, otpVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
}
|
||||
|
||||
async function testRebar3Versions() {
|
||||
let got
|
||||
let expected
|
||||
let spec
|
||||
|
||||
spec = '3.13.x'
|
||||
expected = '3.13.2'
|
||||
got = await setupElixir.getRebar3Version(spec)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '3.13.2'
|
||||
expected = '3.13.2'
|
||||
got = await setupElixir.getRebar3Version(spec)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '3.13'
|
||||
expected = '3.13.2'
|
||||
got = await setupElixir.getRebar3Version(spec)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
}
|
||||
|
||||
function simulateInput(key, value) {
|
||||
process.env[`INPUT_${key.replace(/ /g, '_').toUpperCase()}`] = value
|
||||
}
|
||||
|
||||
all()
|
||||
.then(() => process.exit(0))
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user