8000 New option to work with one or more hex.pm mirrors by pguyot · Pull Request #197 · erlef/setup-beam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

New option to work with one or more hex.pm mirrors #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/hexpm-mirrors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: hexpm-mirrors

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-failing-first-mirror:
name: Test option hexpm-mirrors with a dummy first mirror
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-22.04', 'windows-2022']
otp-version: ['24']
elixir-version: ['v1.14', '']
install-rebar: [true, false]
install-hex: [true, false]
steps:
- uses: actions/checkout@v3
- name: Use erlef/setup-beam
id: setup-beam
uses: ./
with:
otp-version: ${{matrix.otp-version}}
elixir-version: ${{matrix.elixir-version}}
install-rebar: ${{matrix.install-rebar}}
install-hex: ${{matrix.install-hex}}
hexpm-mirrors: |
https://mirror.invalid
https://cdn.jsdelivr.net/hex
https://builds.hex.pm

test-invalid-mirror:
name: Test errors with mirror
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Use erlef/setup-beam
id: failing-setup-beam
uses: ./
continue-on-error: true
with:
otp-version: '24.3.4.6'
elixir-version: 'v1.13.4'
install-rebar: true
install-hex: true
hexpm-mirrors: https://mirror.invalid
- name: Report unexpected success
if: ${{ steps.failing-setup-beam.outcome == 'success' }}
run: |
echo "Action is expected to fail"
exit 1
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,47 @@ jobs:

**Note**: the `otp-version: false` input is only applicable when installing Gleam.

## Alternative hex.pm mirrors

It is possible to use alternative hex.pm mirror(s), in their declared order, with
option `hexpm-mirrors`. By default, the action will use `builds.hex.pm`.
To use other alternative mirrors, add one per line, as shown below.

```yaml
# create this in .github/workflows/ci.yml
on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: '25'
# Use `cdn.jsdelivr.net/hex` as an alternative to `builds.hex.pm`
hexpm-mirrors: https://cdn.jsdelivr.net/hex
```

Alternatively, you may try `cdn.jsdelivr.net/hex` if `builds.hex.pm` fails:

```yaml
# create this in .github/workflows/ci.yml
on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: '25'
hexpm-mirrors: |
https://builds.hex.pm
https://cdn.jsdelivr.net/hex
```

## Environment variables

Base installation folders (useful for e.g. fetching headers for NIFs) are available in the following
Expand Down
36 changes: 19 additions & 17 deletions __tests__/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,68 +102,69 @@ async function testOTPVersions() {
let expected
let spec
let osVersion
const hexMirrors = ['https://repo.hex.pm', 'https://cdn.jsdelivr.net/hex']

if (process.platform === 'linux') {
spec = '19.3.x'
osVersion = 'ubuntu-16.04'
expected = 'OTP-19.3.6.13'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '^19.3.6'
osVersion = 'ubuntu-16.04'
expected = 'OTP-19.3.6.13'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '^19.3'
osVersion = 'ubuntu-18.04'
expected = 'OTP-19.3.6.13'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '20'
osVersion = 'ubuntu-20.04'
expected = 'OTP-20.3.8.26'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '20.x'
osVersion = 'ubuntu-20.04'
expected = 'OTP-20.3.8.26'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '20.0'
osVersion = 'ubuntu-20.04'
expected = 'OTP-20.0.5'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '20.0.x'
osVersion = 'ubuntu-20.04'
expected = 'OTP-20.0.5'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
}

if (process.platform === 'win32') {
spec = '24.0.1'
osVersion = 'windows-latest'
expected = '24.0.1'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '23.2.x'
osVersion = 'windows-2016'
expected = '23.2.7'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '23.0'
osVersion = 'windows-2019'
expected = '23.0.4'
got = await setupBeam.getOTPVersion(spec, osVersion)
got = await setupBeam.getOTPVersion(spec, osVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
}
}
Expand All @@ -173,54 +174,55 @@ async function testElixirVersions() {
let expected
let spec
let otpVersion
const hexMirrors = ['https://repo.hex.pm']

spec = '1.1.x'
otpVersion = 'OTP-17'
expected = 'v1.1.1-otp-17'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '1.10.4'
otpVersion = 'OTP-23'
expected = 'v1.10.4-otp-23'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

spec = '1.12.1'
otpVersion = 'OTP-24.0.2'
expected = 'v1.12.1-otp-24'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)

simulateInput('version-type', 'strict')
spec = '1.14.0'
otpVersion = 'master'
expected = 'v1.14.0'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', 'loose')

simulateInput('version-type', 'strict')
spec = 'v1.11.0-rc.0'
otpVersion = 'OTP-23'
expected = 'v1.11.0-rc.0-otp-23'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', 'loose')

simulateInput('version-type', 'strict')
spec = 'v1.11.0'
otpVersion = '22.3.4.2'
expected = 'v1.11.0-otp-22'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', 'loose')

simulateInput('version-type', 'strict')
spec = 'main'
otpVersion = '23.1'
expected = 'main-otp-23'
got = await setupBeam.getElixirVersion(spec, otpVersion)
got = await setupBeam.getElixirVersion(spec, otpVersion, hexMirrors)
assert.deepStrictEqual(got, expected)
simulateInput('version-type', 'loose')
}
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ inputs:
version-file:
description: a versions file (e.g. as used by `asdf`), which defines inputs
default: ''
hexpm-mirrors:
description: mirror(s) for hex.pm, one per line
default: |
https://builds.hex.pm
outputs:
elixir-version:
description: Exact version of Elixir that was installed
Expand Down
Loading
0