mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-22 22:56:07 +00:00
Rework our version matching algorithm (#217)
* Update some dependencies' versions (also, get rid of husky) * Introduce branch dependency execution We want the most important things to fail first and prevent the other ones from executing e.g. if your dist/ is not updated, there's no point seeing the tests fail * Rid ourselves of bloat * Introduce expectations for upcoming version * Tweak whitespace * Tweak our calls to getVersionFromSpec (increase code consistency) * Remove non-used variable * Start coercing on input, stop sorting/maybe prepending 'v' on input We'll deal with all this in a centralized place to make it easier to reason on the code * Revamp our getVersionFromSpec 1. stop accepting maybePrependWithV0, since this is only used in specialized cases 2. sort versions internally (don't expect it to come sorted) 3. compare rc/strict and .includes in a single go (don't separate these) 4. don't expect already coerced version arrays, coerce them when required (the maybeCoerced version had changed already, which means we're smarter at putting stuff inside the version array) 5. raise an exception if a semver-invalid version is not flagged as strict * Reduce our expectations, but still be appropriate to our mission * Update our tests for our new expectations (start the TDD bit) * Execute npm run build-dist and keep results * Increase inter-job dependency * Don't expect markdownlint to be installed remotely * Revert "Increase inter-job dependency" This reverts commit 500b0fe7e9eec1c4f258b4d16b40719ee1d0a1ad. * Revert "Introduce branch dependency execution" This reverts commit fbe1317a800d7722f4e8b668c073218263d0ab17. * Have all the CI workflows run under the same conditions * Fix as per CI results * Re-establish the possibility to match versions like 22.3.4.2.1.0 We cheat on the semver matching: 1. we keep an ordered list of versions that respect e.g. 22.3.4 2. if we match 22.3.4 when fetching a version, we get the last value from the list of versions that respect it, e.g. 22.3.4.2.1.0 (since this is ordered, it should work as previously expected) This increases code complexity for getVersionFromSpec, but hopefully not by much... We also remove throw-based test cases (non-versions will fail later, with null), and add some tests to prove our need code. * Trim out linting practices But still keep them useful
This commit is contained in:
committed by
GitHub
parent
efc884ac2f
commit
f6a73a7bf1
+52
-2
@@ -104,9 +104,18 @@ async function testOTPVersions() {
|
||||
let expected
|
||||
let spec
|
||||
let osVersion
|
||||
let before
|
||||
const hexMirrors = ['https://repo.hex.pm', 'https://cdn.jsdelivr.net/hex']
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '25.3.2.1'
|
||||
osVersion = 'ubuntu-20.04'
|
||||
expected = 'OTP-25.3.2.1'
|
||||
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', before)
|
||||
|
||||
spec = '19.3.x'
|
||||
osVersion = 'ubuntu-16.04'
|
||||
expected = 'OTP-19.3.6.13'
|
||||
@@ -131,6 +140,12 @@ async function testOTPVersions() {
|
||||
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '20.3.8.26'
|
||||
osVersion = 'ubuntu-20.04'
|
||||
expected = 'OTP-20.3.8.26'
|
||||
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '20.x'
|
||||
osVersion = 'ubuntu-20.04'
|
||||
expected = 'OTP-20.3.8.26'
|
||||
@@ -291,7 +306,7 @@ async function testGetVersionFromSpec() {
|
||||
let expected
|
||||
let spec
|
||||
let before
|
||||
const versions = [
|
||||
const versions0 = [
|
||||
'3.2.30.5',
|
||||
'3.2.3.5',
|
||||
'1',
|
||||
@@ -317,10 +332,20 @@ async function testGetVersionFromSpec() {
|
||||
'22.3.4.9.1',
|
||||
'22.3.4.12.1',
|
||||
'22.3.4.10.1',
|
||||
'22.3.4.2',
|
||||
'main',
|
||||
'v11.11.0-rc.0-otp-23',
|
||||
'22.3.4.2',
|
||||
'22.3.4.2.1.0',
|
||||
'12.1.2.2',
|
||||
'12.1.2.4',
|
||||
'12.1.2.0',
|
||||
'12.1.2.3',
|
||||
'12.1.2.3.0',
|
||||
]
|
||||
const versions = {}
|
||||
versions0.forEach((version) => {
|
||||
versions[version] = version
|
||||
})
|
||||
|
||||
spec = '1'
|
||||
expected = '1.1.0'
|
||||
@@ -417,6 +442,31 @@ async function testGetVersionFromSpec() {
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', before)
|
||||
|
||||
spec = '22.3.4.2'
|
||||
expected = '22.3.4.2.1.0'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '22.3.4.2.1'
|
||||
expected = '22.3.4.2.1.0'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '22.3.4.2.1.0'
|
||||
expected = '22.3.4.2.1.0'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '12.1.2.3'
|
||||
expected = '12.1.2.3.0'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
spec = '22.3.4.2.1.0.1'
|
||||
expected = null
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '22.3.4.3'
|
||||
expected = null
|
||||
|
||||
Reference in New Issue
Block a user