mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-22 22:56:07 +00:00
Ease debugging, fix some CI issues, tweak folder structure (#200)
* Enable debug for OTP versions' listings * Make it easier to detect * Prevent error annotation on expected error The fact that one mirror fails in the above test and others follow working is test enough for me A single failing mirror should fail, but it's confusing to have an error annotation for a success (via continue-on-error) while not being able to suppress it via GitHub Actions * Trying to figure out why we have a rebar_core exception Might simply be that the bug is already fixed and we need to bump rebar3 * Try to debug into non-JSON input * Prevent error in rebar_core We're getting Access Denied for Fetching registry from "https://repo.hex.pm:443/registry.ets.gz?" * Try to figure out what's breaking tests * Make jsonParse(...).map failure more understandable * Ease test maintenance * Tweak folder structure while moving console._ to core._
This commit is contained in:
committed by
GitHub
parent
cf692c3264
commit
b9783cdeea
@@ -9,7 +9,6 @@ parserOptions:
|
||||
rules:
|
||||
indent: ["warn", 2]
|
||||
max-len: ["warn", 100]
|
||||
no-console: 0
|
||||
no-undef: "error"
|
||||
no-unused-vars: ["error", {"varsIgnorePattern": "^_"}]
|
||||
no-use-before-define: 0
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
id: setup-beam
|
||||
uses: ./
|
||||
with:
|
||||
version-file: __tests__/.tool-versions
|
||||
version-file: test/.tool-versions
|
||||
version-type: strict
|
||||
|
||||
unit_tests_windows:
|
||||
|
||||
@@ -35,24 +35,3 @@ jobs:
|
||||
https://mirror.invalid
|
||||
https://cdn.jsdelivr.net/hex
|
||||
https://builds.hex.pm
|
||||
|
||||
test-invalid-mirror:
|
||||
name: Test errors with mirror
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use erlef/setup-beam
|
||||
id: failing-setup-beam
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
with:
|
||||
otp-version: '24.3.4.6'
|
||||
elixir-version: 'v1.13.4'
|
||||
install-rebar: true
|
||||
install-hex: true
|
||||
hexpm-mirrors: https://mirror.invalid
|
||||
- name: Report unexpected success
|
||||
if: ${{ steps.failing-setup-beam.outcome == 'success' }}
|
||||
run: |
|
||||
echo "Action is expected to fail"
|
||||
exit 1
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
os: 'ubuntu-latest'
|
||||
- elixir-version: 'v1.4'
|
||||
otp-version: '20'
|
||||
rebar3-version: '3.6.0'
|
||||
rebar3-version: '3.15.0'
|
||||
os: 'ubuntu-20.04'
|
||||
- elixir-version: 'v1.4'
|
||||
otp-version: '20'
|
||||
@@ -165,23 +165,23 @@ jobs:
|
||||
if: ${{matrix.combo.elixir-version}}
|
||||
- name: Run Elixir/Mix project tests
|
||||
run: |
|
||||
cd test-projects/elixir_mix
|
||||
cd test/projects/elixir_mix
|
||||
mix deps.get
|
||||
mix test
|
||||
if: ${{matrix.combo.elixir-version}}
|
||||
- name: Run Erlang/rebar3 project tests
|
||||
run: |
|
||||
cd test-projects/erlang_rebar3
|
||||
cd test/projects/erlang_rebar3
|
||||
rebar3 ct
|
||||
if: ${{matrix.combo.rebar3-version}}
|
||||
- name: Format Gleam project (without installing Erlang/OTP)
|
||||
run: |
|
||||
cd test-projects/gleam_gleam
|
||||
cd test/projects/gleam_gleam
|
||||
gleam format
|
||||
if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }}
|
||||
- name: Run Gleam project tests (without `rebar3`)
|
||||
run: |
|
||||
cd test-projects/gleam_gleam
|
||||
cd test/projects/gleam_gleam
|
||||
gleam test
|
||||
if: ${{ matrix.combo.gleam-version && matrix.combo.otp-version && !matrix.combo.rebar3-version }}
|
||||
- name: Run escript
|
||||
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
if: ${{matrix.combo.rebar3-version}}
|
||||
- name: rebar3 from Rust
|
||||
run: |
|
||||
cd test-projects/rust_rebar3_cmd
|
||||
cd test/projects/rust_rebar3_cmd
|
||||
cargo test -- --nocapture
|
||||
if: ${{matrix.combo.rebar3-version}}
|
||||
- name: mix version and help (CLI)
|
||||
@@ -90,13 +90,13 @@ jobs:
|
||||
if: ${{matrix.combo.elixir-version}}
|
||||
- name: Run Elixir/Mix project tests
|
||||
run: |
|
||||
cd test-projects/elixir_mix
|
||||
cd test/projects/elixir_mix
|
||||
mix deps.get
|
||||
mix test
|
||||
if: ${{matrix.combo.elixir-version}}
|
||||
- name: Run Erlang/rebar3 project tests
|
||||
run: |
|
||||
cd test-projects/erlang_rebar3
|
||||
cd test/projects/erlang_rebar3
|
||||
rebar3 ct
|
||||
if: ${{matrix.combo.rebar3-version}}
|
||||
- name: Run escript
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
node_modules/**
|
||||
dist/.github/workflows
|
||||
__tests__/.tool-versions
|
||||
test/.tool-versions
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Elixir Problem Matchers
|
||||
|
||||
Elixir Problem Matchers in [elixir-matchers.json](.github/elixir-matchers.json)
|
||||
Elixir Problem Matchers in [elixir-matchers.json](matchers/elixir-matchers.json)
|
||||
are adapted from [here](https://github.com/fr1zle/vscode-elixir/blob/45eddb589acd7ac98e0c7305d1c2b24668ca709a/package.json#L70-L118),
|
||||
available under the [MIT license](https://github.com/fr1zle/vscode-elixir/blob/45eddb589acd7ac98e0c7305d1c2b24668ca709a/LICENSE.md):
|
||||
|
||||
|
||||
Vendored
+40
-32
@@ -7303,13 +7303,11 @@ async function main() {
|
||||
|
||||
async function installOTP(otpSpec, osVersion, hexMirrors) {
|
||||
const otpVersion = await getOTPVersion(otpSpec, osVersion, hexMirrors)
|
||||
console.log(
|
||||
`##[group]Installing Erlang/OTP ${otpVersion} - built on ${osVersion}`,
|
||||
)
|
||||
core.startGroup(`Installing Erlang/OTP ${otpVersion} - built on ${osVersion}`)
|
||||
await installer.installOTP(osVersion, otpVersion, hexMirrors)
|
||||
core.setOutput('otp-version', otpVersion)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
return otpVersion
|
||||
}
|
||||
@@ -7323,19 +7321,17 @@ async function maybeInstallElixir(elixirSpec, otpSpec, hexMirrors) {
|
||||
otpSpec,
|
||||
hexMirrors,
|
||||
)
|
||||
console.log(`##[group]Installing Elixir ${elixirVersion}`)
|
||||
core.startGroup(`Installing Elixir ${elixirVersion}`)
|
||||
await installer.installElixir(elixirVersion, hexMirrors)
|
||||
core.setOutput('elixir-version', elixirVersion)
|
||||
const disableProblemMatchers = getInput('disable_problem_matchers', false)
|
||||
if (disableProblemMatchers === 'false') {
|
||||
const matchersPath = __nccwpck_require__.ab + ".github"
|
||||
console.log(
|
||||
`##[add-matcher]${path.join(matchersPath, 'elixir-matchers.json')}`,
|
||||
)
|
||||
const elixirMatchers = __nccwpck_require__.ab + "elixir-matchers.json"
|
||||
core.info(`##[add-matcher]${elixirMatchers}`)
|
||||
}
|
||||
core.addPath(`${os.homedir()}/.mix/escripts`)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/elixir/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
installed = true
|
||||
}
|
||||
@@ -7363,9 +7359,9 @@ async function mix(shouldMix, what, hexMirrors) {
|
||||
if (shouldMix === 'true') {
|
||||
const cmd = 'mix'
|
||||
const args = [`local.${what}`, '--force']
|
||||
console.log(`##[group]Running ${cmd} ${args}`)
|
||||
core.startGroup(`Running ${cmd} ${args}`)
|
||||
await mixWithMirrors(cmd, args, hexMirrors)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7374,11 +7370,11 @@ async function maybeInstallGleam(gleamSpec) {
|
||||
|
||||
if (gleamSpec) {
|
||||
const gleamVersion = await getGleamVersion(gleamSpec)
|
||||
console.log(`##[group]Installing Gleam ${gleamVersion}`)
|
||||
core.startGroup(`Installing Gleam ${gleamVersion}`)
|
||||
await installer.installGleam(gleamVersion)
|
||||
core.setOutput('gleam-version', gleamVersion)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/gleam/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
installed = true
|
||||
}
|
||||
@@ -7396,11 +7392,11 @@ async function maybeInstallRebar3(rebar3Spec) {
|
||||
} else {
|
||||
rebar3Version = await getRebar3Version(rebar3Spec)
|
||||
}
|
||||
console.log(`##[group]Installing rebar3 ${rebar3Version}`)
|
||||
core.startGroup(`Installing rebar3 ${rebar3Version}`)
|
||||
await installer.installRebar3(rebar3Version)
|
||||
core.setOutput('rebar3-version', rebar3Version)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/rebar3/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
installed = true
|
||||
}
|
||||
@@ -7493,16 +7489,16 @@ async function getRebar3Version(r3Spec) {
|
||||
|
||||
async function getOTPVersions(osVersion, hexMirrors) {
|
||||
let otpVersionsListings
|
||||
let originListing
|
||||
if (process.platform === 'linux') {
|
||||
otpVersionsListings = await getWithMirrors(
|
||||
`/builds/otp/${osVersion}/builds.txt`,
|
||||
hexMirrors,
|
||||
)
|
||||
originListing = `/builds/otp/${osVersion}/builds.txt`
|
||||
otpVersionsListings = await getWithMirrors(originListing, hexMirrors)
|
||||
} else if (process.platform === 'win32') {
|
||||
const originListing =
|
||||
originListing =
|
||||
'https://api.github.com/repos/erlang/otp/releases?per_page=100'
|
||||
otpVersionsListings = await get(originListing, [1, 2, 3])
|
||||
}
|
||||
debugLog(`OTP versions listings from ${originListing}`, otpVersionsListings)
|
||||
|
||||
const otpVersions = new Map()
|
||||
|
||||
@@ -7519,7 +7515,7 @@ async function getOTPVersions(osVersion, hexMirrors) {
|
||||
})
|
||||
} else if (process.platform === 'win32') {
|
||||
otpVersionsListings.forEach((otpVersionsListing) => {
|
||||
jsonParse(otpVersionsListing)
|
||||
jsonParseAsList(otpVersionsListing)
|
||||
.map((x) => x.assets)
|
||||
.flat()
|
||||
.filter((x) => x.name.match(/^otp_win64_.*.exe$/))
|
||||
@@ -7566,7 +7562,7 @@ async function getGleamVersions() {
|
||||
)
|
||||
const gleamVersionsListing = []
|
||||
resultJSONs.forEach((resultJSON) => {
|
||||
jsonParse(resultJSON)
|
||||
jsonParseAsList(resultJSON)
|
||||
.map((x) => x.tag_name)
|
||||
.sort()
|
||||
.forEach((v) => gleamVersionsListing.push(v))
|
||||
@@ -7581,7 +7577,7 @@ async function getRebar3Versions() {
|
||||
)
|
||||
const rebar3VersionsListing = []
|
||||
resultJSONs.forEach((resultJSON) => {
|
||||
jsonParse(resultJSON)
|
||||
jsonParseAsList(resultJSON)
|
||||
.map((x) => x.tag_name)
|
||||
.sort()
|
||||
.forEach((v) => rebar3VersionsListing.push(v))
|
||||
@@ -7772,7 +7768,7 @@ function parseVersionFile(versionFilePath0) {
|
||||
`The specified version file, ${versionFilePath0}, does not exist`,
|
||||
)
|
||||
}
|
||||
console.log(`##[group]Parsing version file at ${versionFilePath0}`)
|
||||
core.startGroup(`Parsing version file at ${versionFilePath0}`)
|
||||
const appVersions = new Map()
|
||||
const versions = fs.readFileSync(versionFilePath, 'utf8')
|
||||
// For the time being we parse .tool-versions
|
||||
@@ -7784,31 +7780,43 @@ function parseVersionFile(versionFilePath0) {
|
||||
const app = appVersion[1]
|
||||
if (['erlang', 'elixir', 'gleam', 'rebar'].includes(app)) {
|
||||
const [, , version] = appVersion
|
||||
console.log(`Consuming ${app} at version ${version}`)
|
||||
core.info(`Consuming ${app} at version ${version}`)
|
||||
appVersions.set(app, version)
|
||||
}
|
||||
}
|
||||
})
|
||||
if (!appVersions.size) {
|
||||
console.log('There was apparently nothing to consume')
|
||||
core.info('There was apparently nothing to consume')
|
||||
} else {
|
||||
console.log('... done!')
|
||||
core.info('... done!')
|
||||
}
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
return appVersions
|
||||
}
|
||||
|
||||
function jsonParse(maybeJson) {
|
||||
function jsonParseAsList(maybeJson) {
|
||||
try {
|
||||
return JSON.parse(maybeJson)
|
||||
const obj = JSON.parse(maybeJson)
|
||||
if (!Array.isArray(obj)) {
|
||||
throw new Error('expected a list!')
|
||||
}
|
||||
return obj
|
||||
} catch (exc) {
|
||||
throw new Error(
|
||||
`Got an exception when trying to parse non-JSON ${maybeJson}: ${exc}`,
|
||||
`Got an exception when trying to parse non-JSON list ${maybeJson}: ${exc}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function debugLog(groupName, message) {
|
||||
if (process.env.RUNNER_DEBUG) {
|
||||
core.startGroup(`Debugging for ${groupName}`)
|
||||
core.debug(message)
|
||||
core.endGroup()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getOTPVersion,
|
||||
getElixirVersion,
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "elixir-mixCompileError",
|
||||
"severity": "error",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^\\*\\* \\((\\w+)\\) (.*):(\\d+): (.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"message": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "elixir-mixCompileWarning",
|
||||
"severity": "warning",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^warning: (.*)$",
|
||||
"message": 1
|
||||
},
|
||||
{
|
||||
"regexp": "^ (.*):(\\d+).*$",
|
||||
"file": 1,
|
||||
"line": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "elixir-mixTestFailure",
|
||||
"severity": "error",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^\\s*\\d+\\) (.*)$",
|
||||
"message": 1
|
||||
},
|
||||
{
|
||||
"regexp": "^\\s*(.*):(\\d+)$",
|
||||
"file": 1,
|
||||
"line": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "elixir-credoOutputDefault",
|
||||
"severity": "warning",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^\u2503\\s\\[\\w\\]\\s[\u2191|\u2197|\u2192|\u2198|\u2193]\\s(.*)$",
|
||||
"message": 1
|
||||
},
|
||||
{
|
||||
"regexp": "^\u2503\\s{7}(.*):(\\d+):(\\d+)\\s.*$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
+1
-1
@@ -9,7 +9,7 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "1.10.0",
|
||||
"@actions/exec": "1.1.1",
|
||||
"@actions/http-client": "^2.1.0",
|
||||
"@actions/http-client": "2.1.0",
|
||||
"semver": "7.3.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
+3
-3
@@ -4,12 +4,12 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "ncc build src/setup-beam.js --no-cache",
|
||||
"format": "prettier src/**/*.js --write && prettier __tests__/**/*.js --write",
|
||||
"jslint": "eslint src/**/*.js && eslint __tests__/**/*.js",
|
||||
"format": "prettier src/**/*.js --write && prettier test/**/*.js --write",
|
||||
"jslint": "eslint src/**/*.js && eslint test/**/*.js",
|
||||
"licenses": "yarn licenses generate-disclaimer > 3RD_PARTY_LICENSES",
|
||||
"markdownlint": "markdownlint *.md",
|
||||
"shellcheck": "shellcheck src/install-*.sh .github/workflows/*.sh",
|
||||
"test": "node __tests__/setup-beam.test.js && node ./__tests__/problem-matchers.test.js",
|
||||
"test": "node test/setup-beam.test.js && node ./test/problem-matchers.test.js",
|
||||
"yamllint": "yamllint .github/workflows/**.yml && yamllint .*.yml && yamllint *.yml",
|
||||
"build-dist": "npm install && npm run build && npm run format && npm run markdownlint && npm run shellcheck && npm run yamllint && npm run jslint"
|
||||
},
|
||||
|
||||
+44
-31
@@ -58,13 +58,11 @@ async function main() {
|
||||
|
||||
async function installOTP(otpSpec, osVersion, hexMirrors) {
|
||||
const otpVersion = await getOTPVersion(otpSpec, osVersion, hexMirrors)
|
||||
console.log(
|
||||
`##[group]Installing Erlang/OTP ${otpVersion} - built on ${osVersion}`,
|
||||
)
|
||||
core.startGroup(`Installing Erlang/OTP ${otpVersion} - built on ${osVersion}`)
|
||||
await installer.installOTP(osVersion, otpVersion, hexMirrors)
|
||||
core.setOutput('otp-version', otpVersion)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
return otpVersion
|
||||
}
|
||||
@@ -78,19 +76,22 @@ async function maybeInstallElixir(elixirSpec, otpSpec, hexMirrors) {
|
||||
otpSpec,
|
||||
hexMirrors,
|
||||
)
|
||||
console.log(`##[group]Installing Elixir ${elixirVersion}`)
|
||||
core.startGroup(`Installing Elixir ${elixirVersion}`)
|
||||
await installer.installElixir(elixirVersion, hexMirrors)
|
||||
core.setOutput('elixir-version', elixirVersion)
|
||||
const disableProblemMatchers = getInput('disable_problem_matchers', false)
|
||||
if (disableProblemMatchers === 'false') {
|
||||
const matchersPath = path.join(__dirname, '..', '.github')
|
||||
console.log(
|
||||
`##[add-matcher]${path.join(matchersPath, 'elixir-matchers.json')}`,
|
||||
const elixirMatchers = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'matchers',
|
||||
'elixir-matchers.json',
|
||||
)
|
||||
core.info(`##[add-matcher]${elixirMatchers}`)
|
||||
}
|
||||
core.addPath(`${os.homedir()}/.mix/escripts`)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/elixir/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
installed = true
|
||||
}
|
||||
@@ -118,9 +119,9 @@ async function mix(shouldMix, what, hexMirrors) {
|
||||
if (shouldMix === 'true') {
|
||||
const cmd = 'mix'
|
||||
const args = [`local.${what}`, '--force']
|
||||
console.log(`##[group]Running ${cmd} ${args}`)
|
||||
core.startGroup(`Running ${cmd} ${args}`)
|
||||
await mixWithMirrors(cmd, args, hexMirrors)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +130,11 @@ async function maybeInstallGleam(gleamSpec) {
|
||||
|
||||
if (gleamSpec) {
|
||||
const gleamVersion = await getGleamVersion(gleamSpec)
|
||||
console.log(`##[group]Installing Gleam ${gleamVersion}`)
|
||||
core.startGroup(`Installing Gleam ${gleamVersion}`)
|
||||
await installer.installGleam(gleamVersion)
|
||||
core.setOutput('gleam-version', gleamVersion)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/gleam/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
installed = true
|
||||
}
|
||||
@@ -151,11 +152,11 @@ async function maybeInstallRebar3(rebar3Spec) {
|
||||
} else {
|
||||
rebar3Version = await getRebar3Version(rebar3Spec)
|
||||
}
|
||||
console.log(`##[group]Installing rebar3 ${rebar3Version}`)
|
||||
core.startGroup(`Installing rebar3 ${rebar3Version}`)
|
||||
await installer.installRebar3(rebar3Version)
|
||||
core.setOutput('rebar3-version', rebar3Version)
|
||||
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/rebar3/bin`)
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
installed = true
|
||||
}
|
||||
@@ -248,16 +249,16 @@ async function getRebar3Version(r3Spec) {
|
||||
|
||||
async function getOTPVersions(osVersion, hexMirrors) {
|
||||
let otpVersionsListings
|
||||
let originListing
|
||||
if (process.platform === 'linux') {
|
||||
otpVersionsListings = await getWithMirrors(
|
||||
`/builds/otp/${osVersion}/builds.txt`,
|
||||
hexMirrors,
|
||||
)
|
||||
originListing = `/builds/otp/${osVersion}/builds.txt`
|
||||
otpVersionsListings = await getWithMirrors(originListing, hexMirrors)
|
||||
} else if (process.platform === 'win32') {
|
||||
const originListing =
|
||||
originListing =
|
||||
'https://api.github.com/repos/erlang/otp/releases?per_page=100'
|
||||
otpVersionsListings = await get(originListing, [1, 2, 3])
|
||||
}
|
||||
debugLog(`OTP versions listings from ${originListing}`, otpVersionsListings)
|
||||
|
||||
const otpVersions = new Map()
|
||||
|
||||
@@ -274,7 +275,7 @@ async function getOTPVersions(osVersion, hexMirrors) {
|
||||
})
|
||||
} else if (process.platform === 'win32') {
|
||||
otpVersionsListings.forEach((otpVersionsListing) => {
|
||||
jsonParse(otpVersionsListing)
|
||||
jsonParseAsList(otpVersionsListing)
|
||||
.map((x) => x.assets)
|
||||
.flat()
|
||||
.filter((x) => x.name.match(/^otp_win64_.*.exe$/))
|
||||
@@ -321,7 +322,7 @@ async function getGleamVersions() {
|
||||
)
|
||||
const gleamVersionsListing = []
|
||||
resultJSONs.forEach((resultJSON) => {
|
||||
jsonParse(resultJSON)
|
||||
jsonParseAsList(resultJSON)
|
||||
.map((x) => x.tag_name)
|
||||
.sort()
|
||||
.forEach((v) => gleamVersionsListing.push(v))
|
||||
@@ -336,7 +337,7 @@ async function getRebar3Versions() {
|
||||
)
|
||||
const rebar3VersionsListing = []
|
||||
resultJSONs.forEach((resultJSON) => {
|
||||
jsonParse(resultJSON)
|
||||
jsonParseAsList(resultJSON)
|
||||
.map((x) => x.tag_name)
|
||||
.sort()
|
||||
.forEach((v) => rebar3VersionsListing.push(v))
|
||||
@@ -527,7 +528,7 @@ function parseVersionFile(versionFilePath0) {
|
||||
`The specified version file, ${versionFilePath0}, does not exist`,
|
||||
)
|
||||
}
|
||||
console.log(`##[group]Parsing version file at ${versionFilePath0}`)
|
||||
core.startGroup(`Parsing version file at ${versionFilePath0}`)
|
||||
const appVersions = new Map()
|
||||
const versions = fs.readFileSync(versionFilePath, 'utf8')
|
||||
// For the time being we parse .tool-versions
|
||||
@@ -539,31 +540,43 @@ function parseVersionFile(versionFilePath0) {
|
||||
const app = appVersion[1]
|
||||
if (['erlang', 'elixir', 'gleam', 'rebar'].includes(app)) {
|
||||
const [, , version] = appVersion
|
||||
console.log(`Consuming ${app} at version ${version}`)
|
||||
core.info(`Consuming ${app} at version ${version}`)
|
||||
appVersions.set(app, version)
|
||||
}
|
||||
}
|
||||
})
|
||||
if (!appVersions.size) {
|
||||
console.log('There was apparently nothing to consume')
|
||||
core.info('There was apparently nothing to consume')
|
||||
} else {
|
||||
console.log('... done!')
|
||||
core.info('... done!')
|
||||
}
|
||||
console.log('##[endgroup]')
|
||||
core.endGroup()
|
||||
|
||||
return appVersions
|
||||
}
|
||||
|
||||
function jsonParse(maybeJson) {
|
||||
function jsonParseAsList(maybeJson) {
|
||||
try {
|
||||
return JSON.parse(maybeJson)
|
||||
const obj = JSON.parse(maybeJson)
|
||||
if (!Array.isArray(obj)) {
|
||||
throw new Error('expected a list!')
|
||||
}
|
||||
return obj
|
||||
} catch (exc) {
|
||||
throw new Error(
|
||||
`Got an exception when trying to parse non-JSON ${maybeJson}: ${exc}`,
|
||||
`Got an exception when trying to parse non-JSON list ${maybeJson}: ${exc}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function debugLog(groupName, message) {
|
||||
if (process.env.RUNNER_DEBUG) {
|
||||
core.startGroup(`Debugging for ${groupName}`)
|
||||
core.debug(message)
|
||||
core.endGroup()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getOTPVersion,
|
||||
getElixirVersion,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const assert = require('assert')
|
||||
const { problemMatcher } = require('../.github/elixir-matchers.json')
|
||||
const core = require('@actions/core')
|
||||
const { problemMatcher } = require('../matchers/elixir-matchers.json')
|
||||
|
||||
async function all() {
|
||||
await testElixirMixCompileError()
|
||||
@@ -76,6 +77,6 @@ async function testElixirCredoOutputDefault() {
|
||||
all()
|
||||
.then(() => process.exit(0))
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
core.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -4,9 +4,11 @@ simulateInput('rebar3-version', '3.20')
|
||||
simulateInput('install-rebar', 'true')
|
||||
simulateInput('install-hex', 'true')
|
||||
simulateInput('github-token', process.env.GITHUB_TOKEN)
|
||||
simulateInput('hexpm-mirrors', ['https://builds.hex.pm'])
|
||||
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const core = require('@actions/core')
|
||||
const setupBeam = require('../src/setup-beam')
|
||||
const installer = require('../src/installer')
|
||||
|
||||
@@ -174,6 +176,7 @@ async function testElixirVersions() {
|
||||
let expected
|
||||
let spec
|
||||
let otpVersion
|
||||
let before
|
||||
const hexMirrors = ['https://repo.hex.pm']
|
||||
|
||||
spec = '1.1.x'
|
||||
@@ -194,37 +197,37 @@ async function testElixirVersions() {
|
||||
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '1.14.0'
|
||||
otpVersion = 'master'
|
||||
expected = 'v1.14.0'
|
||||
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
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, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
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, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = 'main'
|
||||
otpVersion = '23.1'
|
||||
expected = 'main-otp-23'
|
||||
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
}
|
||||
|
||||
async function testGleamVersions() {
|
||||
@@ -245,13 +248,13 @@ async function testGleamVersions() {
|
||||
got = await setupBeam.getGleamVersion(spec, otpVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
const before = simulateInput('version-type', 'strict')
|
||||
spec = 'v0.14.0-rc2'
|
||||
otpVersion = 'OTP-22'
|
||||
expected = 'v0.14.0-rc2'
|
||||
got = await setupBeam.getGleamVersion(spec, otpVersion)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
}
|
||||
|
||||
async function testRebar3Versions() {
|
||||
@@ -279,6 +282,7 @@ async function testGetVersionFromSpec() {
|
||||
let got
|
||||
let expected
|
||||
let spec
|
||||
let before
|
||||
const versions = [
|
||||
'3.2.30.5',
|
||||
'3.2.3.5',
|
||||
@@ -320,19 +324,19 @@ async function testGetVersionFromSpec() {
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '1'
|
||||
expected = '1'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '1.0'
|
||||
expected = '1.0'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
spec = '2'
|
||||
expected = '2.10'
|
||||
@@ -359,12 +363,12 @@ async function testGetVersionFromSpec() {
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '24.0-rc3'
|
||||
expected = '24.0-rc3'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
spec = '24.0-rc2'
|
||||
expected = '24.0-rc2'
|
||||
@@ -391,24 +395,24 @@ async function testGetVersionFromSpec() {
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = 'master'
|
||||
expected = 'master'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
|
||||
spec = 'master'
|
||||
expected = 'master'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
|
||||
simulateInput('version-type', 'strict')
|
||||
before = simulateInput('version-type', 'strict')
|
||||
spec = '22.3.4.2'
|
||||
expected = '22.3.4.2'
|
||||
got = setupBeam.getVersionFromSpec(spec, versions)
|
||||
assert.deepStrictEqual(got, expected)
|
||||
simulateInput('version-type', 'loose')
|
||||
simulateInput('version-type', before)
|
||||
}
|
||||
|
||||
async function testParseVersionFile() {
|
||||
@@ -427,7 +431,7 @@ elixir ${elixir} # comment, with space
|
||||
not-gleam 0.23 # not picked up
|
||||
gleam ${gleam}
|
||||
rebar ${rebar3}`
|
||||
const filename = '__tests__/.tool-versions'
|
||||
const filename = 'test/.tool-versions'
|
||||
fs.writeFileSync(filename, toolVersions)
|
||||
process.env.GITHUB_WORKSPACE = ''
|
||||
const appVersions = setupBeam.parseVersionFile(filename)
|
||||
@@ -454,13 +458,13 @@ rebar ${rebar3}`
|
||||
}
|
||||
|
||||
function unsimulateInput(key) {
|
||||
const before = process.env[input(key)]
|
||||
simulateInput(key, '')
|
||||
return before
|
||||
return simulateInput(key, '')
|
||||
}
|
||||
|
||||
function simulateInput(key, value) {
|
||||
const before = process.env[input(key)]
|
||||
process.env[input(key)] = value
|
||||
return before
|
||||
}
|
||||
|
||||
function input(key) {
|
||||
@@ -470,6 +474,6 @@ function input(key) {
|
||||
all()
|
||||
.then(() => process.exit(0))
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
core.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user