23 Commits

Author SHA1 Message Date
Jonathan Clem
811b4b88e8 Merge pull request #12 from actions/install-in-tmp
Install Elixir/OTP in /tmp
2019-12-04 13:58:29 -05:00
Jonathan Clem
8a6d70bfc0 Install Elixir/OTP in /tmp 2019-12-04 13:54:33 -05:00
Jonathan Clem
8bdf2bbb33 Merge pull request #10 from ericmj/emj/hex
Install from hex
2019-12-04 13:50:09 -05:00
Jonathan Clem
fa3dc4b442 Merge branch 'master' into emj/hex 2019-12-04 13:49:24 -05:00
Jonathan Clem
1a3c64091d Update version in README 2019-12-02 14:18:45 -05:00
Jonathan Clem
5ce583baa3 Merge pull request #11 from mijailr/error-matchers
Add error matchers for known warning or error strings
2019-12-02 14:16:32 -05:00
Mijail Rondon
c1ab867da9 Add error and warning matchers 2019-11-27 13:46:21 -05:00
Mijail Rondon
dfb9431cd0 Problem matcher elixir 2019-11-26 23:32:07 -05:00
Eric Meadows-Jönsson
a12d5327a9 Check exact version match 2019-11-19 22:03:23 +01:00
Eric Meadows-Jönsson
71a9eee041 Support elixir branches 2019-11-18 00:03:58 +01:00
Eric Meadows-Jönsson
14bacb3367 Install from hex 2019-11-17 21:07:10 +01:00
Jonathan Clem
ca25180aa6 Update Elixir versions
This includes 1.9.4 _preemptively_
2019-11-05 12:16:23 -05:00
Jonathan Clem
289ac7af73 Add more Erlang OTP versions in 22.1.x 2019-11-05 12:15:23 -05:00
Jonathan Clem
721ee4860a Merge pull request #5 from aai/erlang
Add Erlang 22.1 to versions
2019-11-05 12:14:16 -05:00
Nathan Youngman
788bbdde77 Add Erlang 22.1 to versions 2019-10-03 15:48:39 -06:00
Jonathan Clem
5731c77a8e Update README.md 2019-08-28 23:00:30 -04:00
Jonathan Clem
b52a81afa4 Add Phoenix example to README 2019-08-28 17:59:49 -04:00
Jonathan Clem
78abf8c5c2 Merge pull request #1 from actions/licensed-workflow
Add a licensed workflow
2019-08-28 17:43:18 -04:00
Jonathan Clem
cf30cd9eeb Curl to file 2019-08-28 17:41:54 -04:00
Jonathan Clem
d8384307ce Use Licensed without Ruby 2019-08-28 17:35:24 -04:00
Jonathan Clem
7242b20bce Merge branch 'master' into licensed-workflow 2019-08-28 17:31:35 -04:00
Jonathan Clem
8b75b3d52e Use Ruby 2.x 2019-08-28 17:27:18 -04:00
Jonathan Clem
c8c376ebbb Add a licensed workflow 2019-08-28 17:25:36 -04:00
13 changed files with 211 additions and 228 deletions

31
.github/elixir.json vendored Normal file
View File

@@ -0,0 +1,31 @@
{
"problemMatcher": [
{
"owner": "elixir",
"pattern": [
{
"regexp": "^(\\*\\* \\(.*\\) )?((.:)?[^:]*):(\\d+)(:(\\d+))?: (.*)$",
"file": 2,
"line": 4,
"column": 6,
"message": 7
}
]
},
{
"owner": "elixir-warning",
"pattern": [
{
"regexp": "^(warning: (.*))$",
"message": 2
},
{
"regexp": "^( )((.:)?[^:]*):(\\d+)(:(\\d+))?$",
"file": 2,
"line": 4,
"column": 6
}
]
}
]
}

19
.github/workflows/licensed.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Licensed
on:
push: {branches: master}
pull_request: {branches: master}
repository_dispatch:
jobs:
test:
runs-on: ubuntu-latest
name: Check licenses
steps:
- uses: actions/checkout@v1.0.0
- run: |-
cd /tmp
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.3.2/licensed-2.3.2-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed
- run: licensed status

View File

@@ -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

View File

@@ -1,6 +1,7 @@
# setup-elixir
[![](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:
@@ -28,7 +29,8 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-elixir@v1.0.0
- uses: actions/checkout@v1.0.0
- uses: actions/setup-elixir@v1.1.0
with:
otp-version: 22.x
elixir-version: 1.9.x
@@ -50,7 +52,8 @@ jobs:
otp: [20.x, 21.x, 22.x]
elixir: [1.8.x, 1.9.x]
steps:
- uses: actions/setup-elixir@v1.0.0
- uses: actions/checkout@v1.0.0
- uses: actions/setup-elixir@v1.1.0
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
@@ -58,6 +61,35 @@ jobs:
- run: mix test
```
### Phoenix example
```yaml
on: push
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:11
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v1.0.0
- uses: actions/setup-elixir@v1.1.0
with:
otp-version: 22.x
elixir-version: 1.9.x
- run: mix deps.get
- run: mix test
```
## License
The scripts and documentation in this project are released under the [MIT license](LICENSE.md).

View File

@@ -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

View File

@@ -1,21 +0,0 @@
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

View File

@@ -1,137 +0,0 @@
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

10
src/install-elixir Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
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
echo "::add-path::$(pwd)/.setup-elixir/elixir/bin"

View File

@@ -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

12
src/install-otp Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
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
rm otp.tar.gz
.setup-elixir/otp/Install -minimal $(pwd)/.setup-elixir/otp
echo "::add-path::$(pwd)/.setup-elixir/otp/bin"

View File

@@ -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

View File

@@ -8,14 +8,12 @@ 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])
const otpString = otpMajor ? `-otp-${otpMajor}` : ''
await exec(path.join(__dirname, 'install-elixir'), [version, otpString])
}
}
@@ -26,7 +24,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
}

View File

@@ -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,13 +14,10 @@ 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(
const otpVersion = await getOtpVersion(otpSpec)
const [elixirVersion, otpMajor] = await getElixirVersion(
elixirSpec,
path.join(__dirname, 'elixir-versions.txt')
otpVersion
)
let installHex = core.getInput('install-hex')
@@ -33,11 +30,16 @@ 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 = `/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')}`)
}
function checkPlatform() {
@@ -47,9 +49,91 @@ function checkPlatform() {
)
}
async function getVersion(spec, versionFile) {
const range = semver.validRange(spec)
const versions = (await readFile(versionFile)).toString().split('\n')
const version = semver.maxSatisfying(versions, range)
return version || spec
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(gitRef).includes(otpMajor)) {
return [gitRef, otpMajor]
} else {
return [gitRef, null]
}
}
function getVersionFromSpec(spec, versions) {
if (versions.includes(spec)) {
return spec
} else {
const range = semver.validRange(spec)
return semver.maxSatisfying(versions, range)
}
}
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+)/) ||
line.match(/^([^-]+)-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)
})
})
}