From d114e80cc4fd39b2e18604827e2548ccfd86dce3 Mon Sep 17 00:00:00 2001 From: Denis Kulicek Date: Wed, 28 Oct 2020 15:12:26 +0100 Subject: [PATCH 1/4] Add osVersion parameter based on ImageOS env variable --- dist/index.js | 20 ++++++++++++++++---- dist/install-otp | 2 +- src/install-otp | 2 +- src/installer.js | 4 ++-- src/setup-elixir.js | 16 ++++++++++++++-- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7e978a9..724995d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2955,9 +2955,9 @@ async function installElixir(version, otpMajor) { * * @param {string} version */ -async function installOTP(version) { +async function installOTP(version, osVersion) { if (process.platform === 'linux') { - await exec(__webpack_require__.ab + "install-otp", [version]) + await exec(__webpack_require__.ab + "install-otp", [version, osVersion]) return } @@ -3321,14 +3321,15 @@ async function main() { elixirSpec, otpVersion ) + const osVersion = getOSVersion() let installHex = core.getInput('install-hex') installHex = installHex == null ? 'true' : installHex let installRebar = core.getInput('install-rebar') installRebar = installRebar == null ? 'true' : installRebar - console.log(`##[group]Installing OTP ${otpVersion}`) - await installOTP(otpVersion) + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`) + await installOTP(otpVersion, osVersion) console.log(`##[endgroup]`) console.log(`##[group]Installing Elixir ${elixirVersion}`) @@ -3344,6 +3345,7 @@ async function main() { console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`) core.setOutput('otp-version', otpVersion) core.setOutput('elixir-version', elixirVersion) + core.setOutput('osVersion', osVersion) } function checkPlatform() { @@ -3357,6 +3359,16 @@ async function getOtpVersion(spec) { return getVersionFromSpec(spec, await getOtpVersions()) || spec } +function getOSVersion() { + const mapToUbuntuVersion = { + ubuntu16: 'ubuntu-16.04', + ubuntu18: 'ubuntu-18.04', + ubuntu20: 'ubuntu-20.04', + } + + return mapToUbuntuVersion[process.env.ImageOS] || 'ubuntu-18.04' +} + exports.getElixirVersion = getElixirVersion async function getElixirVersion(spec, otpVersion) { diff --git a/dist/install-otp b/dist/install-otp index 659803e..13145bc 100755 --- a/dist/install-otp +++ b/dist/install-otp @@ -4,7 +4,7 @@ set -eo pipefail cd $RUNNER_TEMP -wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/${2}/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 diff --git a/src/install-otp b/src/install-otp index 659803e..13145bc 100755 --- a/src/install-otp +++ b/src/install-otp @@ -4,7 +4,7 @@ set -eo pipefail cd $RUNNER_TEMP -wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/${2}/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 diff --git a/src/installer.js b/src/installer.js index 7a55dbf..a64b23c 100644 --- a/src/installer.js +++ b/src/installer.js @@ -22,9 +22,9 @@ async function installElixir(version, otpMajor) { * * @param {string} version */ -async function installOTP(version) { +async function installOTP(version, osVersion) { if (process.platform === 'linux') { - await exec(path.join(__dirname, 'install-otp'), [version]) + await exec(path.join(__dirname, 'install-otp'), [version, osVersion]) return } diff --git a/src/setup-elixir.js b/src/setup-elixir.js index 4f45b16..b896d7e 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -23,14 +23,15 @@ async function main() { elixirSpec, otpVersion ) + const osVersion = getOSVersion() let installHex = core.getInput('install-hex') installHex = installHex == null ? 'true' : installHex let installRebar = core.getInput('install-rebar') installRebar = installRebar == null ? 'true' : installRebar - console.log(`##[group]Installing OTP ${otpVersion}`) - await installOTP(otpVersion) + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`) + await installOTP(otpVersion, osVersion) console.log(`##[endgroup]`) console.log(`##[group]Installing Elixir ${elixirVersion}`) @@ -46,6 +47,7 @@ async function main() { console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`) core.setOutput('otp-version', otpVersion) core.setOutput('elixir-version', elixirVersion) + core.setOutput('osVersion', osVersion) } function checkPlatform() { @@ -59,6 +61,16 @@ async function getOtpVersion(spec) { return getVersionFromSpec(spec, await getOtpVersions()) || spec } +function getOSVersion() { + const mapToUbuntuVersion = { + ubuntu16: 'ubuntu-16.04', + ubuntu18: 'ubuntu-18.04', + ubuntu20: 'ubuntu-20.04', + } + + return mapToUbuntuVersion[process.env.ImageOS] || 'ubuntu-18.04' +} + exports.getElixirVersion = getElixirVersion async function getElixirVersion(spec, otpVersion) { From 7b728b73d09ae43c4abe79b9830ff062fbb016c2 Mon Sep 17 00:00:00 2001 From: Denis Kulicek Date: Thu, 29 Oct 2020 14:27:52 +0100 Subject: [PATCH 2/4] Add experimental-otp input opt-in flag --- dist/index.js | 8 ++++++-- src/setup-elixir.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 724995d..5cf9a60 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3321,13 +3321,17 @@ async function main() { elixirSpec, otpVersion ) - const osVersion = getOSVersion() let installHex = core.getInput('install-hex') installHex = installHex == null ? 'true' : installHex + let installRebar = core.getInput('install-rebar') installRebar = installRebar == null ? 'true' : installRebar + const experimentalOTP = core.getInput('experimental-otp') + const osVersion = + experimentalOTP === 'true' ? getRunnerOSVersion() : 'ubuntu-14.04' + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`) await installOTP(otpVersion, osVersion) console.log(`##[endgroup]`) @@ -3359,7 +3363,7 @@ async function getOtpVersion(spec) { return getVersionFromSpec(spec, await getOtpVersions()) || spec } -function getOSVersion() { +function getRunnerOSVersion(experimentalOTP) { const mapToUbuntuVersion = { ubuntu16: 'ubuntu-16.04', ubuntu18: 'ubuntu-18.04', diff --git a/src/setup-elixir.js b/src/setup-elixir.js index b896d7e..c1046c4 100644 --- a/src/setup-elixir.js +++ b/src/setup-elixir.js @@ -23,13 +23,17 @@ async function main() { elixirSpec, otpVersion ) - const osVersion = getOSVersion() let installHex = core.getInput('install-hex') installHex = installHex == null ? 'true' : installHex + let installRebar = core.getInput('install-rebar') installRebar = installRebar == null ? 'true' : installRebar + const experimentalOTP = core.getInput('experimental-otp') + const osVersion = + experimentalOTP === 'true' ? getRunnerOSVersion() : 'ubuntu-14.04' + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`) await installOTP(otpVersion, osVersion) console.log(`##[endgroup]`) @@ -61,7 +65,7 @@ async function getOtpVersion(spec) { return getVersionFromSpec(spec, await getOtpVersions()) || spec } -function getOSVersion() { +function getRunnerOSVersion(experimentalOTP) { const mapToUbuntuVersion = { ubuntu16: 'ubuntu-16.04', ubuntu18: 'ubuntu-18.04', From 2e57bfa4c53a2557ff95f7f3a635028df97490da Mon Sep 17 00:00:00 2001 From: Denis Kulicek Date: Thu, 29 Oct 2020 14:28:26 +0100 Subject: [PATCH 3/4] Update action.yml with experimental-otp input --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index b9444df..3970a7c 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,9 @@ inputs: description: Version range or exact version of Elixir to use otp-version: description: Version range or exact version of OTP to use + experimental-otp: + description: Whether to use experimental builds of OTP (images have not yet been fully tested include ubuntu-16.04, ubuntu-18.04, ubuntu-20.04) + default: false install-hex: description: Whether to install Hex default: true From 6c1b3125216c61f1a5a9344690d9a5adc6752393 Mon Sep 17 00:00:00 2001 From: Denis Kulicek Date: Thu, 29 Oct 2020 14:30:42 +0100 Subject: [PATCH 4/4] Update action.yml description --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 3970a7c..ec34bd5 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: otp-version: description: Version range or exact version of OTP to use experimental-otp: - description: Whether to use experimental builds of OTP (images have not yet been fully tested include ubuntu-16.04, ubuntu-18.04, ubuntu-20.04) + description: Whether to use experimental builds of OTP (images that have not yet been fully tested include ubuntu-16.04, ubuntu-18.04, ubuntu-20.04) default: false install-hex: description: Whether to install Hex