Merge pull request #12 from actions/install-in-tmp

811b4b8 · Jonathan Clem · 2019-12-04 18:58

3 files +52 -29
Message
{commit_body(@commit)}

Files changed

modified src/install-elixir
+2 −0
@@ -2,6 +2,8 @@
2 2
3 3 set -eo pipefail
4 4
5 +cd /tmp
6 +
5 7 wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
6 8 unzip -d .setup-elixir/elixir ${1}${2}.zip
7 9 rm ${1}${2}.zip
modified src/install-otp
+2 −0
@@ -2,6 +2,8 @@
2 2
3 3 set -eo pipefail
4 4
5 +cd /tmp
6 +
5 7 wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
6 8 mkdir -p .setup-elixir/otp
7 9 tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
modified src/setup-elixir.js
+48 −29
@@ -15,7 +15,10 @@ async function main() {
15 15 const otpSpec = core.getInput('otp-version', {required: true})
16 16 const elixirSpec = core.getInput('elixir-version', {required: true})
17 17 const otpVersion = await getOtpVersion(otpSpec)
18 const [elixirVersion, otpMajor] = await getElixirVersion(elixirSpec, otpVersion)
18 + const [elixirVersion, otpMajor] = await getElixirVersion(
19 + elixirSpec,
20 + otpVersion
21 + )
19 22
20 23 let installHex = core.getInput('install-hex')
21 24 installHex = installHex == null ? true : installHex
@@ -30,12 +33,13 @@ async function main() {
30 33 await installElixir(elixirVersion, otpMajor)
31 34 console.log(`##[endgroup]`)
32 35
33 process.env.PATH = `${process.cwd()}/.setup-elixir/elixir/bin:${process.env.PATH}`
36 + process.env.PATH = `/tmp/.setup-elixir/elixir/bin:${process.env.PATH}`
37 +
34 38 if (installRebar) await exec('mix local.rebar --force')
35 39 if (installHex) await exec('mix local.hex --force')
36 40
37 const matchersPath = path.join(__dirname, '..', '.github');
38 console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`);
41 + const matchersPath = path.join(__dirname, '..', '.github')
42 + console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
39 43 }
40 44
41 45 function checkPlatform() {
@@ -53,10 +57,9 @@ async function getElixirVersion(spec, otpVersion) {
53 57 const versions = await getElixirVersions()
54 58 const semverRegex = /^v(\d+\.\d+\.\d+)/
55 59
56 const semverVersions =
57 Array.from(versions.keys())
58 .filter(str => str.match(semverRegex))
59 .map(str => str.match(semverRegex)[1])
60 + const semverVersions = Array.from(versions.keys())
61 + .filter(str => str.match(semverRegex))
62 + .map(str => str.match(semverRegex)[1])
60 63
61 64 const version = getVersionFromSpec(spec, semverVersions)
62 65 const gitRef = version ? `v${version}` : spec
@@ -71,7 +74,7 @@ async function getElixirVersion(spec, otpVersion) {
71 74
72 75 function getVersionFromSpec(spec, versions) {
73 76 if (versions.includes(spec)) {
74 return spec;
77 + return spec
75 78 } else {
76 79 const range = semver.validRange(spec)
77 80 return semver.maxSatisfying(versions, range)
@@ -79,28 +82,38 @@ function getVersionFromSpec(spec, versions) {
79 82 }
80 83
81 84 async function getOtpVersions() {
82 const result = await get("https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table")
83
84 return result.trim().split('\n').map(line => {
85 const [_, version] = line.match(/^OTP-([\.\d]+)/)
86 return version
87 })
85 + const result = await get(
86 + 'https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table'
87 + )
88 +
89 + return result
90 + .trim()
91 + .split('\n')
92 + .map(line => {
93 + const [_, version] = line.match(/^OTP-([\.\d]+)/)
94 + return version
95 + })
88 96 }
89 97
90 98 async function getElixirVersions() {
91 const result = await get("https://repo.hex.pm/builds/elixir/builds.txt")
99 + const result = await get('https://repo.hex.pm/builds/elixir/builds.txt')
92 100 const map = new Map()
93 101
94 result.trim().split('\n').forEach(line => {
95 const match = line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) || line.match(/^([^-]+)-otp-(\d+)/)
96
97 if (match) {
98 const [_, version, otp] = match
99 const array = (map.get(version) || [])
100 array.push(otp)
101 map.set(version, array)
102 }
103 })
102 + result
103 + .trim()
104 + .split('\n')
105 + .forEach(line => {
106 + const match =
107 + line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) ||
108 + line.match(/^([^-]+)-otp-(\d+)/)
109 +
110 + if (match) {
111 + const [_, version, otp] = match
112 + const array = map.get(version) || []
113 + array.push(otp)
114 + map.set(version, array)
115 + }
116 + })
104 117
105 118 return map
106 119 }
@@ -111,10 +124,16 @@ function get(url) {
111 124
112 125 req.on('response', res => {
113 126 let data = ''
114 res.on('data', (chunk) => { data += chunk })
115 res.on('end', () => { resolve(data) })
127 + res.on('data', chunk => {
128 + data += chunk
129 + })
130 + res.on('end', () => {
131 + resolve(data)
132 + })
116 133 })
117 134
118 req.on('error', err => { reject(err) })
135 + req.on('error', err => {
136 + reject(err)
137 + })
119 138 })
120 139 }

Parents: 8bdf2bb 8a6d70b