Merge pull request #46 from deniskulicek/parametrize-otp-os-version

96441ef · Jonathan Clem · 2020-11-17 13:26

6 files +45 -10
Message
{commit_body(@commit)}

Files changed

modified action.yml
+3 −0
@@ -9,6 +9,9 @@ inputs:
9 9 description: Version range or exact version of Elixir to use
10 10 otp-version:
11 11 description: Version range or exact version of OTP to use
12 + experimental-otp:
13 + 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)
14 + default: false
12 15 install-hex:
13 16 description: Whether to install Hex
14 17 default: true
modified dist/index.js
+20 −4
@@ -2955,9 +2955,9 @@ async function installElixir(version, otpMajor) {
2955 2955 *
2956 2956 * @param {string} version
2957 2957 */
2958 async function installOTP(version) {
2958 +async function installOTP(version, osVersion) {
2959 2959 if (process.platform === 'linux') {
2960 await exec(__webpack_require__.ab + "install-otp", [version])
2960 + await exec(__webpack_require__.ab + "install-otp", [version, osVersion])
2961 2961 return
2962 2962 }
2963 2963
@@ -3324,11 +3324,16 @@ async function main() {
3324 3324
3325 3325 let installHex = core.getInput('install-hex')
3326 3326 installHex = installHex == null ? 'true' : installHex
3327 +
3327 3328 let installRebar = core.getInput('install-rebar')
3328 3329 installRebar = installRebar == null ? 'true' : installRebar
3329 3330
3330 console.log(`##[group]Installing OTP ${otpVersion}`)
3331 await installOTP(otpVersion)
3331 + const experimentalOTP = core.getInput('experimental-otp')
3332 + const osVersion =
3333 + experimentalOTP === 'true' ? getRunnerOSVersion() : 'ubuntu-14.04'
3334 +
3335 + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`)
3336 + await installOTP(otpVersion, osVersion)
3332 3337 console.log(`##[endgroup]`)
3333 3338
3334 3339 console.log(`##[group]Installing Elixir ${elixirVersion}`)
@@ -3344,6 +3349,7 @@ async function main() {
3344 3349 console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
3345 3350 core.setOutput('otp-version', otpVersion)
3346 3351 core.setOutput('elixir-version', elixirVersion)
3352 + core.setOutput('osVersion', osVersion)
3347 3353 }
3348 3354
3349 3355 function checkPlatform() {
@@ -3357,6 +3363,16 @@ async function getOtpVersion(spec) {
3357 3363 return getVersionFromSpec(spec, await getOtpVersions()) || spec
3358 3364 }
3359 3365
3366 +function getRunnerOSVersion(experimentalOTP) {
3367 + const mapToUbuntuVersion = {
3368 + ubuntu16: 'ubuntu-16.04',
3369 + ubuntu18: 'ubuntu-18.04',
3370 + ubuntu20: 'ubuntu-20.04',
3371 + }
3372 +
3373 + return mapToUbuntuVersion[process.env.ImageOS] || 'ubuntu-18.04'
3374 +}
3375 +
3360 3376 exports.getElixirVersion = getElixirVersion
3361 3377
3362 3378 async function getElixirVersion(spec, otpVersion) {
modified dist/install-otp
+1 −1
@@ -4,7 +4,7 @@ set -eo pipefail
4 4
5 5 cd $RUNNER_TEMP
6 6
7 wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
7 +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/${2}/OTP-${1}.tar.gz
8 8 mkdir -p .setup-elixir/otp
9 9 tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
10 10 rm otp.tar.gz
modified src/install-otp
+1 −1
@@ -4,7 +4,7 @@ set -eo pipefail
4 4
5 5 cd $RUNNER_TEMP
6 6
7 wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
7 +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/${2}/OTP-${1}.tar.gz
8 8 mkdir -p .setup-elixir/otp
9 9 tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
10 10 rm otp.tar.gz
modified src/installer.js
+2 −2
@@ -22,9 +22,9 @@ async function installElixir(version, otpMajor) {
22 22 *
23 23 * @param {string} version
24 24 */
25 async function installOTP(version) {
25 +async function installOTP(version, osVersion) {
26 26 if (process.platform === 'linux') {
27 await exec(path.join(__dirname, 'install-otp'), [version])
27 + await exec(path.join(__dirname, 'install-otp'), [version, osVersion])
28 28 return
29 29 }
30 30
modified src/setup-elixir.js
+18 −2
@@ -26,11 +26,16 @@ async function main() {
26 26
27 27 let installHex = core.getInput('install-hex')
28 28 installHex = installHex == null ? 'true' : installHex
29 +
29 30 let installRebar = core.getInput('install-rebar')
30 31 installRebar = installRebar == null ? 'true' : installRebar
31 32
32 console.log(`##[group]Installing OTP ${otpVersion}`)
33 await installOTP(otpVersion)
33 + const experimentalOTP = core.getInput('experimental-otp')
34 + const osVersion =
35 + experimentalOTP === 'true' ? getRunnerOSVersion() : 'ubuntu-14.04'
36 +
37 + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`)
38 + await installOTP(otpVersion, osVersion)
34 39 console.log(`##[endgroup]`)
35 40
36 41 console.log(`##[group]Installing Elixir ${elixirVersion}`)
@@ -46,6 +51,7 @@ async function main() {
46 51 console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
47 52 core.setOutput('otp-version', otpVersion)
48 53 core.setOutput('elixir-version', elixirVersion)
54 + core.setOutput('osVersion', osVersion)
49 55 }
50 56
51 57 function checkPlatform() {
@@ -59,6 +65,16 @@ async function getOtpVersion(spec) {
59 65 return getVersionFromSpec(spec, await getOtpVersions()) || spec
60 66 }
61 67
68 +function getRunnerOSVersion(experimentalOTP) {
69 + const mapToUbuntuVersion = {
70 + ubuntu16: 'ubuntu-16.04',
71 + ubuntu18: 'ubuntu-18.04',
72 + ubuntu20: 'ubuntu-20.04',
73 + }
74 +
75 + return mapToUbuntuVersion[process.env.ImageOS] || 'ubuntu-18.04'
76 +}
77 +
62 78 exports.getElixirVersion = getElixirVersion
63 79
64 80 async function getElixirVersion(spec, otpVersion) {

Parents: 5841733 6c1b312