From 14bacb3367912b7b448c2e7535eb0cb7a8adf641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Sun, 17 Nov 2019 19:30:42 +0100 Subject: [PATCH 01/10] Install from hex --- script/build-versions | 19 ----- src/elixir-versions.txt | 24 ------- src/erlang-versions.txt | 143 -------------------------------------- src/install-elixir | 8 +++ src/install-elixir-ubuntu | 13 ---- src/install-otp | 10 +++ src/install-otp-ubuntu | 16 ----- src/installer.js | 11 ++- src/setup-elixir.js | 72 +++++++++++++++---- 9 files changed, 82 insertions(+), 234 deletions(-) delete mode 100755 script/build-versions delete mode 100644 src/elixir-versions.txt delete mode 100644 src/erlang-versions.txt create mode 100755 src/install-elixir delete mode 100755 src/install-elixir-ubuntu create mode 100755 src/install-otp delete mode 100755 src/install-otp-ubuntu diff --git a/script/build-versions b/script/build-versions deleted file mode 100755 index a40f93c..0000000 --- a/script/build-versions +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -# Find all releases that are $major.$minor(.$patch)? (no branch versions or rcs) -curl -fs https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table \ - | cut -d: -f1 \ - | cut -d- -f2 \ - | awk '{$1=$1};1' \ - | grep -E '^\d+\.\d+(?:\.\d+)?$' \ - | sed -E 's/^([0-9]+\.[0-9]+)$/\1.0/g' \ - > src/erlang-versions.txt - -# Find all releases that are $major.$minor(.$patch)? (no rcs) -curl -fs https://api.github.com/repos/elixir-lang/elixir/releases \ - | jq -r '.[].tag_name' \ - | sed 's/^v//' \ - | grep -v '-' \ - > src/elixir-versions.txt \ No newline at end of file diff --git a/src/elixir-versions.txt b/src/elixir-versions.txt deleted file mode 100644 index 3a71b25..0000000 --- a/src/elixir-versions.txt +++ /dev/null @@ -1,24 +0,0 @@ -1.9.4 -1.9.3 -1.9.2 -1.9.1 -1.9.0 -1.8.2 -1.8.1 -1.8.0 -1.7.4 -1.7.3 -1.7.2 -1.7.1 -1.7.0 -1.6.6 -1.6.5 -1.6.4 -1.6.3 -1.6.2 -1.6.1 -1.6.0 -1.5.3 -1.5.2 -1.5.1 -1.5.0 diff --git a/src/erlang-versions.txt b/src/erlang-versions.txt deleted file mode 100644 index 4930d37..0000000 --- a/src/erlang-versions.txt +++ /dev/null @@ -1,143 +0,0 @@ -22.1.5 -22.1.4 -22.1.3 -22.1.2 -22.1.1 -22.1 -22.0.7 -22.0.6 -22.0.5 -22.0.4 -22.0.3 -22.0.2 -22.0.1 -22.0.0 -21.3.8 -21.3.7 -21.3.6 -21.3.5 -21.3.4 -21.3.3 -21.3.2 -21.3.1 -21.3.0 -21.2.7 -21.2.6 -21.2.5 -21.2.4 -21.2.3 -21.2.2 -21.2.1 -21.2.0 -21.1.4 -21.1.3 -21.1.2 -21.1.1 -21.1.0 -21.0.9 -21.0.8 -21.0.7 -21.0.6 -21.0.5 -21.0.4 -21.0.3 -21.0.2 -21.0.1 -21.0.0 -20.3.8 -20.3.7 -20.3.6 -20.3.5 -20.3.4 -20.3.3 -20.3.2 -20.3.1 -20.3.0 -20.2.4 -20.2.3 -20.2.2 -20.2.1 -20.2.0 -20.1.7 -20.1.6 -20.1.5 -20.1.4 -20.1.3 -20.1.2 -20.1.1 -20.1.0 -20.0.5 -20.0.4 -20.0.3 -20.0.2 -20.0.1 -20.0.0 -19.3.6 -19.3.5 -19.3.4 -19.3.3 -19.3.2 -19.3.1 -19.3.0 -19.2.3 -19.2.2 -19.2.1 -19.2.0 -19.1.6 -19.1.5 -19.1.4 -19.1.3 -19.1.2 -19.1.1 -19.1.0 -19.0.7 -19.0.6 -19.0.5 -19.0.4 -19.0.3 -19.0.2 -19.0.1 -19.0.0 -18.3.4 -18.3.3 -18.3.2 -18.3.1 -18.3.0 -18.2.4 -18.2.3 -18.2.2 -18.2.1 -18.2.0 -18.1.5 -18.1.4 -18.1.3 -18.1.2 -18.1.1 -18.1.0 -18.0.3 -18.0.2 -18.0.1 -18.0.0 -17.5.6 -17.5.5 -17.5.4 -17.5.3 -17.5.2 -17.5.1 -17.5.0 -17.4.1 -17.4.0 -17.3.4 -17.3.3 -17.3.2 -17.3.1 -17.3.0 -17.2.2 -17.2.1 -17.2.0 -17.1.2 -17.1.1 -17.1.0 -17.0.2 -17.0.1 -17.0.0 diff --git a/src/install-elixir b/src/install-elixir new file mode 100755 index 0000000..f767922 --- /dev/null +++ b/src/install-elixir @@ -0,0 +1,8 @@ +#!/bin/bash + +set -eo pipefail + +wget -q https://repo.hex.pm/builds/elixir/v${1}-otp-${2}.zip +unzip -d .setup-elixir/elixir v${1}-otp-${2}.zip +rm v${1}-otp-${2}.zip +echo "::add-path::$(pwd)/.setup-elixir/elixir/bin" diff --git a/src/install-elixir-ubuntu b/src/install-elixir-ubuntu deleted file mode 100755 index 8e07c23..0000000 --- a/src/install-elixir-ubuntu +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -release=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d= -f2) -version=$1 -arch=$2 -file=elixir_$version-1~ubuntu~$release\_$arch.deb - -cd /tmp - -wget https://packages.erlang-solutions.com/erlang/debian/pool/$file -sudo dpkg -i $file \ No newline at end of file diff --git a/src/install-otp b/src/install-otp new file mode 100755 index 0000000..a5236ce --- /dev/null +++ b/src/install-otp @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eo pipefail + +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz +mkdir -p .setup-elixir/otp +tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1 +rm otp.tar.gz +.setup-elixir/otp/Install -minimal $(pwd)/.setup-elixir/otp +echo "::add-path::$(pwd)/.setup-elixir/otp/bin" diff --git a/src/install-otp-ubuntu b/src/install-otp-ubuntu deleted file mode 100755 index bc8cd4f..0000000 --- a/src/install-otp-ubuntu +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -release=$(lsb_release -cs) -version=$1 -file=esl-erlang_$version-1~ubuntu~$release\_amd64.deb - -sudo apt-get install -y libwxbase3.0-0v5 -sudo apt-get install -y libwxgtk3.0-0v5 -sudo apt-get install -y libsctp1 - -cd /tmp - -wget https://packages.erlang-solutions.com/erlang/debian/pool/$file -sudo dpkg -i $file \ No newline at end of file diff --git a/src/installer.js b/src/installer.js index f5dfa30..9b2bc51 100644 --- a/src/installer.js +++ b/src/installer.js @@ -8,14 +8,11 @@ module.exports = {installElixir, installOTP} * Install Elixir. * * @param {string} version - * @param {string} arch + * @param {string} otpMajor */ -async function installElixir(version) { - let arch = 'all' - if (semver.gt('1.9.0', version)) arch = 'amd64' - +async function installElixir(version, otpMajor) { if (process.platform === 'linux') { - await exec(path.join(__dirname, 'install-elixir-ubuntu'), [version, arch]) + await exec(path.join(__dirname, 'install-elixir'), [version, otpMajor]) } } @@ -26,7 +23,7 @@ async function installElixir(version) { */ async function installOTP(version) { if (process.platform === 'linux') { - await exec(path.join(__dirname, 'install-otp-ubuntu'), [version]) + await exec(path.join(__dirname, 'install-otp'), [version]) return } diff --git a/src/setup-elixir.js b/src/setup-elixir.js index 247ccae..ba85c13 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -1,9 +1,9 @@ const core = require('@actions/core') const {exec} = require('@actions/exec') const {installElixir, installOTP} = require('./installer') -const {readFile} = require('fs').promises const path = require('path') const semver = require('semver') +const https = require('https') main().catch(err => { core.setFailed(err.message) @@ -14,14 +14,8 @@ async function main() { const otpSpec = core.getInput('otp-version', {required: true}) const elixirSpec = core.getInput('elixir-version', {required: true}) - const otpVersion = await getVersion( - otpSpec, - path.join(__dirname, 'erlang-versions.txt') - ) - const elixirVersion = await getVersion( - elixirSpec, - path.join(__dirname, 'elixir-versions.txt') - ) + const otpVersion = getVersionFromSpec(otpSpec, await getOtpVersions()) + const [elixirVersion, otpMajor] = getElixirVersion(elixirSpec, await getElixirVersions(), otpVersion) let installHex = core.getInput('install-hex') installHex = installHex == null ? true : installHex @@ -33,9 +27,10 @@ async function main() { console.log(`##[endgroup]`) console.log(`##[group]Installing Elixir ${elixirVersion}`) - await installElixir(elixirVersion) + await installElixir(elixirVersion, otpMajor) console.log(`##[endgroup]`) + process.env.PATH = `${process.cwd()}/.setup-elixir/elixir/bin:${process.env.PATH}` if (installRebar) await exec('mix local.rebar --force') if (installHex) await exec('mix local.hex --force') } @@ -47,9 +42,62 @@ function checkPlatform() { ) } -async function getVersion(spec, versionFile) { +function getElixirVersion(spec, versions, otpVersion) { + const version = getVersionFromSpec(spec, Array.from(versions.keys())) + const [otpMajor] = otpVersion.match(/^\d+/) + + if (versions.get(version).includes(otpMajor)) { + return [version, otpMajor] + } else { + throw new Error( + `Elixir ${version} and OTP ${otpVersion} are incompatible` + ) + } +} + +function getVersionFromSpec(spec, versions) { const range = semver.validRange(spec) - const versions = (await readFile(versionFile)).toString().split('\n') const version = semver.maxSatisfying(versions, range) return version || spec } + +async function getOtpVersions() { + const result = await get("https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table") + + return result.trim().split('\n').map(line => { + const [_, version] = line.match(/^OTP-([\.\d]+)/) + return version + }) +} + +async function getElixirVersions() { + const result = await get("https://repo.hex.pm/builds/elixir/builds.txt") + const map = new Map() + + result.trim().split('\n').forEach(line => { + const match = line.match(/^v(\d+\.\d+\.\d+)-otp-(\d+)/) + + if (match) { + const [_, version, otp] = match + const array = (map.get(version) || []) + array.push(otp) + map.set(version, array) + } + }) + + return map +} + +function get(url) { + return new Promise((resolve, reject) => { + const req = https.get(url) + + req.on('response', res => { + let data = '' + res.on('data', (chunk) => { data += chunk }) + res.on('end', () => { resolve(data) }) + }) + + req.on('error', err => { reject(err) }) + }) +} From 71a9eee041935c78a267f96a76ee9121d15b06a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Sun, 17 Nov 2019 23:40:55 +0100 Subject: [PATCH 02/10] Support elixir branches --- .github/workflows/test.yml | 3 +++ src/install-elixir | 6 +++--- src/installer.js | 3 ++- src/setup-elixir.js | 34 ++++++++++++++++++++++------------ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bb4c25..f09163b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,9 @@ jobs: # Semver ranges - otp-version: 21.x elixir-version: <1.9.1 + # Branches + - otp-version: 22.0 + elixir-version: master steps: - uses: actions/checkout@v1.0.0 - name: Use actions/setup-elixir diff --git a/src/install-elixir b/src/install-elixir index f767922..8fc616c 100755 --- a/src/install-elixir +++ b/src/install-elixir @@ -2,7 +2,7 @@ set -eo pipefail -wget -q https://repo.hex.pm/builds/elixir/v${1}-otp-${2}.zip -unzip -d .setup-elixir/elixir v${1}-otp-${2}.zip -rm v${1}-otp-${2}.zip +wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip +unzip -d .setup-elixir/elixir ${1}${2}.zip +rm ${1}${2}.zip echo "::add-path::$(pwd)/.setup-elixir/elixir/bin" diff --git a/src/installer.js b/src/installer.js index 9b2bc51..7a55dbf 100644 --- a/src/installer.js +++ b/src/installer.js @@ -12,7 +12,8 @@ module.exports = {installElixir, installOTP} */ async function installElixir(version, otpMajor) { if (process.platform === 'linux') { - await exec(path.join(__dirname, 'install-elixir'), [version, otpMajor]) + const otpString = otpMajor ? `-otp-${otpMajor}` : '' + await exec(path.join(__dirname, 'install-elixir'), [version, otpString]) } } diff --git a/src/setup-elixir.js b/src/setup-elixir.js index ba85c13..24e0b68 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -14,8 +14,8 @@ async function main() { const otpSpec = core.getInput('otp-version', {required: true}) const elixirSpec = core.getInput('elixir-version', {required: true}) - const otpVersion = getVersionFromSpec(otpSpec, await getOtpVersions()) - const [elixirVersion, otpMajor] = getElixirVersion(elixirSpec, await getElixirVersions(), otpVersion) + const otpVersion = await getOtpVersion(otpSpec) + const [elixirVersion, otpMajor] = await getElixirVersion(elixirSpec, otpVersion) let installHex = core.getInput('install-hex') installHex = installHex == null ? true : installHex @@ -42,23 +42,33 @@ function checkPlatform() { ) } -function getElixirVersion(spec, versions, otpVersion) { - const version = getVersionFromSpec(spec, Array.from(versions.keys())) +async function getOtpVersion(spec) { + return getVersionFromSpec(spec, await getOtpVersions()) || spec +} + +async function getElixirVersion(spec, otpVersion) { + const versions = await getElixirVersions() + const semverRegex = /^v(\d+\.\d+\.\d+)/ + + const semverVersions = + Array.from(versions.keys()) + .filter(str => str.match(semverRegex)) + .map(str => str.match(semverRegex)[1]) + + const version = getVersionFromSpec(spec, semverVersions) + const gitRef = version ? `v${version}` : spec const [otpMajor] = otpVersion.match(/^\d+/) - if (versions.get(version).includes(otpMajor)) { - return [version, otpMajor] + if (versions.get(gitRef).includes(otpMajor)) { + return [gitRef, otpMajor] } else { - throw new Error( - `Elixir ${version} and OTP ${otpVersion} are incompatible` - ) + return [gitRef, null] } } function getVersionFromSpec(spec, versions) { const range = semver.validRange(spec) - const version = semver.maxSatisfying(versions, range) - return version || spec + return semver.maxSatisfying(versions, range) } async function getOtpVersions() { @@ -75,7 +85,7 @@ async function getElixirVersions() { const map = new Map() result.trim().split('\n').forEach(line => { - const match = line.match(/^v(\d+\.\d+\.\d+)-otp-(\d+)/) + const match = line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) || line.match(/^([^-]+)-otp-(\d+)/) if (match) { const [_, version, otp] = match From a12d5327a9ffff158146a4258e8416fd3db83e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Tue, 19 Nov 2019 22:03:23 +0100 Subject: [PATCH 03/10] Check exact version match --- src/setup-elixir.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/setup-elixir.js b/src/setup-elixir.js index 24e0b68..72a53be 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -67,8 +67,12 @@ async function getElixirVersion(spec, otpVersion) { } function getVersionFromSpec(spec, versions) { - const range = semver.validRange(spec) - return semver.maxSatisfying(versions, range) + if (versions.includes(spec)) { + return spec; + } else { + const range = semver.validRange(spec) + return semver.maxSatisfying(versions, range) + } } async function getOtpVersions() { From dfb9431cd0f69c78308619afb86cfefb0b5003bb Mon Sep 17 00:00:00 2001 From: Mijail Rondon Date: Tue, 26 Nov 2019 23:32:07 -0500 Subject: [PATCH 04/10] Problem matcher elixir --- .github/elixir.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/elixir.json diff --git a/.github/elixir.json b/.github/elixir.json new file mode 100644 index 0000000..84dd88c --- /dev/null +++ b/.github/elixir.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "elixir", + "pattern": [ + { + "regexp": "^(\\*\\* \\(.*\\) )?((.:)?[^:]*):(\\d+)(:(\\d+))?: (.*)$", + "file": 2, + "line": 4, + "column": 6, + "message": 7 + } + ] + } + ] +} From c1ab867da977b9183d98a11f63d9338eef5ad985 Mon Sep 17 00:00:00 2001 From: Mijail Rondon Date: Tue, 26 Nov 2019 23:38:31 -0500 Subject: [PATCH 05/10] Add error and warning matchers --- .github/elixir.json | 15 +++++++++++++++ src/setup-elixir.js | 3 +++ 2 files changed, 18 insertions(+) diff --git a/.github/elixir.json b/.github/elixir.json index 84dd88c..4d1d0d1 100644 --- a/.github/elixir.json +++ b/.github/elixir.json @@ -11,6 +11,21 @@ "message": 7 } ] + }, + { + "owner": "elixir-warning", + "pattern": [ + { + "regexp": "^(warning: (.*))$", + "message": 2 + }, + { + "regexp": "^( )((.:)?[^:]*):(\\d+)(:(\\d+))?$", + "file": 2, + "line": 4, + "column": 6 + } + ] } ] } diff --git a/src/setup-elixir.js b/src/setup-elixir.js index 247ccae..b25fdd5 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -38,6 +38,9 @@ async function main() { if (installRebar) await exec('mix local.rebar --force') if (installHex) await exec('mix local.hex --force') + + const matchersPath = path.join(__dirname, '..', '.github'); + console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`); } function checkPlatform() { From 1a3c64091d474cbde0480f3d6b9be27ac85a1fb4 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Mon, 2 Dec 2019 14:18:45 -0500 Subject: [PATCH 06/10] Update version in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8630f37..f3bcc6e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1.0.0 - - uses: actions/setup-elixir@v1.0.0 + - uses: actions/setup-elixir@v1.1.0 with: otp-version: 22.x elixir-version: 1.9.x @@ -53,7 +53,7 @@ jobs: elixir: [1.8.x, 1.9.x] steps: - uses: actions/checkout@v1.0.0 - - uses: actions/setup-elixir@v1.0.0 + - uses: actions/setup-elixir@v1.1.0 with: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} @@ -82,7 +82,7 @@ jobs: steps: - uses: actions/checkout@v1.0.0 - - uses: actions/setup-elixir@v1.0.0 + - uses: actions/setup-elixir@v1.1.0 with: otp-version: 22.x elixir-version: 1.9.x From 8a6d70bfc07906a7dddd22f7c097a6ed196ff817 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Wed, 4 Dec 2019 13:54:33 -0500 Subject: [PATCH 07/10] Install Elixir/OTP in /tmp --- src/install-elixir | 2 ++ src/install-otp | 2 ++ src/setup-elixir.js | 73 ++++++++++++++++++++++++++++----------------- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/install-elixir b/src/install-elixir index 8fc616c..974f47e 100755 --- a/src/install-elixir +++ b/src/install-elixir @@ -2,6 +2,8 @@ set -eo pipefail +cd /tmp + wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip unzip -d .setup-elixir/elixir ${1}${2}.zip rm ${1}${2}.zip diff --git a/src/install-otp b/src/install-otp index a5236ce..469142c 100755 --- a/src/install-otp +++ b/src/install-otp @@ -2,6 +2,8 @@ set -eo pipefail +cd /tmp + wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz mkdir -p .setup-elixir/otp tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1 diff --git a/src/setup-elixir.js b/src/setup-elixir.js index 41dc67e..4e20996 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -15,7 +15,10 @@ async function main() { const otpSpec = core.getInput('otp-version', {required: true}) const elixirSpec = core.getInput('elixir-version', {required: true}) const otpVersion = await getOtpVersion(otpSpec) - const [elixirVersion, otpMajor] = await getElixirVersion(elixirSpec, otpVersion) + const [elixirVersion, otpMajor] = await getElixirVersion( + elixirSpec, + otpVersion + ) let installHex = core.getInput('install-hex') installHex = installHex == null ? true : installHex @@ -30,12 +33,13 @@ async function main() { await installElixir(elixirVersion, otpMajor) console.log(`##[endgroup]`) - process.env.PATH = `${process.cwd()}/.setup-elixir/elixir/bin:${process.env.PATH}` + process.env.PATH = `/tmp/.setup-elixir/elixir/bin:${process.env.PATH}` + if (installRebar) await exec('mix local.rebar --force') if (installHex) await exec('mix local.hex --force') - const matchersPath = path.join(__dirname, '..', '.github'); - console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`); + const matchersPath = path.join(__dirname, '..', '.github') + console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`) } function checkPlatform() { @@ -53,10 +57,9 @@ async function getElixirVersion(spec, otpVersion) { const versions = await getElixirVersions() const semverRegex = /^v(\d+\.\d+\.\d+)/ - const semverVersions = - Array.from(versions.keys()) - .filter(str => str.match(semverRegex)) - .map(str => str.match(semverRegex)[1]) + const semverVersions = Array.from(versions.keys()) + .filter(str => str.match(semverRegex)) + .map(str => str.match(semverRegex)[1]) const version = getVersionFromSpec(spec, semverVersions) const gitRef = version ? `v${version}` : spec @@ -71,7 +74,7 @@ async function getElixirVersion(spec, otpVersion) { function getVersionFromSpec(spec, versions) { if (versions.includes(spec)) { - return spec; + return spec } else { const range = semver.validRange(spec) return semver.maxSatisfying(versions, range) @@ -79,28 +82,38 @@ function getVersionFromSpec(spec, versions) { } async function getOtpVersions() { - const result = await get("https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table") + const result = await get( + 'https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table' + ) - return result.trim().split('\n').map(line => { - const [_, version] = line.match(/^OTP-([\.\d]+)/) - return version - }) + return result + .trim() + .split('\n') + .map(line => { + const [_, version] = line.match(/^OTP-([\.\d]+)/) + return version + }) } async function getElixirVersions() { - const result = await get("https://repo.hex.pm/builds/elixir/builds.txt") + const result = await get('https://repo.hex.pm/builds/elixir/builds.txt') const map = new Map() - result.trim().split('\n').forEach(line => { - const match = line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) || line.match(/^([^-]+)-otp-(\d+)/) + result + .trim() + .split('\n') + .forEach(line => { + const match = + line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) || + line.match(/^([^-]+)-otp-(\d+)/) - if (match) { - const [_, version, otp] = match - const array = (map.get(version) || []) - array.push(otp) - map.set(version, array) - } - }) + if (match) { + const [_, version, otp] = match + const array = map.get(version) || [] + array.push(otp) + map.set(version, array) + } + }) return map } @@ -111,10 +124,16 @@ function get(url) { req.on('response', res => { let data = '' - res.on('data', (chunk) => { data += chunk }) - res.on('end', () => { resolve(data) }) + res.on('data', chunk => { + data += chunk + }) + res.on('end', () => { + resolve(data) + }) }) - req.on('error', err => { reject(err) }) + req.on('error', err => { + reject(err) + }) }) } From ec4e5f880d80e36f8af7163a991505b3a1257534 Mon Sep 17 00:00:00 2001 From: Mike Coutermarsh Date: Sun, 5 Jan 2020 14:30:47 -0800 Subject: [PATCH 08/10] Update versions in readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f3bcc6e..2233672 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1.0.0 - - uses: actions/setup-elixir@v1.1.0 + - uses: actions/checkout@v2 + - uses: actions/setup-elixir@v1.2.0 with: otp-version: 22.x elixir-version: 1.9.x @@ -52,8 +52,8 @@ jobs: otp: [20.x, 21.x, 22.x] elixir: [1.8.x, 1.9.x] steps: - - uses: actions/checkout@v1.0.0 - - uses: actions/setup-elixir@v1.1.0 + - uses: actions/checkout@v2 + - uses: actions/setup-elixir@v1.2.0 with: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} @@ -81,8 +81,8 @@ jobs: --health-retries 5 steps: - - uses: actions/checkout@v1.0.0 - - uses: actions/setup-elixir@v1.1.0 + - uses: actions/checkout@v2 + - uses: actions/setup-elixir@v1.2.0 with: otp-version: 22.x elixir-version: 1.9.x From 3a6105a9349e230af942f6b233cb5ff6aca97d24 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Wed, 8 Jan 2020 13:53:23 -0500 Subject: [PATCH 09/10] Remove Erlang solutions and .x versions from README --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2233672..90f7691 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ See [action.yml](action.yml). **Note** The OTP release version specification is [relatively complex](http://erlang.org/doc/system_principles/versions.html#version-scheme). -For best results, the current recommendation is to use a full exact version -spec from the list available from [Erlang -Solutions](https://www.erlang-solutions.com/resources/download.html). +For best results, we recommend specifying exact OTP and Elixir versions. +However, values like `22.x` are also accepted, and we attempt to resolve them +according to semantic versioning rules. ### Basic example @@ -32,8 +32,8 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-elixir@v1.2.0 with: - otp-version: 22.x - elixir-version: 1.9.x + otp-version: 22.2 + elixir-version: 1.9.4 - run: mix deps.get - run: mix test ``` @@ -49,8 +49,8 @@ jobs: name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: matrix: - otp: [20.x, 21.x, 22.x] - elixir: [1.8.x, 1.9.x] + otp: [20.3, 21.3, 22.2] + elixir: [1.8.2, 1.9.4] steps: - uses: actions/checkout@v2 - uses: actions/setup-elixir@v1.2.0 @@ -84,8 +84,8 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-elixir@v1.2.0 with: - otp-version: 22.x - elixir-version: 1.9.x + otp-version: 22.2 + elixir-version: 1.9.4 - run: mix deps.get - run: mix test ``` From 06ccede3099fb510976dd996084499f8740cee79 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Wed, 8 Jan 2020 13:55:53 -0500 Subject: [PATCH 10/10] Improve wording in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 90f7691..64894a9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [![](https://github.com/actions/setup-elixir/workflows/Test/badge.svg)](https://github.com/actions/setup-elixir/actions) [![](https://github.com/actions/setup-elixir/workflows/Licensed/badge.svg)](https://github.com/actions/setup-elixir/actions) -This actions sets up an Elixir environment for use in Actions by: +This action sets up an Elixir environment for use in a GitHub Actions +workflow by: - Installing OTP - Installing Elixir