neiam
/action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Improve warning message for missing ImageOS env. variable (self-hosted runners) (#59)
9283f85 · Paulo F. Oliveira · 2021-07-12 17:35
Files changed
modified
.github/workflows/action.yml
+16
−4
@@ -17,7 +17,7 @@ jobs:
| 17 | 17 | - uses: actions/checkout@v2 |
| 18 | 18 | - uses: actions/setup-node@v1 |
| 19 | 19 | with: |
| 20 | − node-version: '12' | |
| 20 | + node-version: 12 | |
| 21 | 21 | - run: npm install -g npm |
| 22 | 22 | - run: npm install |
| 23 | 23 | - run: npm run build |
@@ -31,12 +31,24 @@ jobs:
| 31 | 31 | - name: Check if build left artifacts |
| 32 | 32 | run: git diff --exit-code |
| 33 | 33 | |
| 34 | − unit_test: | |
| 35 | − name: Unit tests | |
| 34 | + unit_tests_ubuntu: | |
| 35 | + name: Unit tests (Ubuntu) | |
| 36 | 36 | runs-on: ubuntu-latest |
| 37 | 37 | steps: |
| 38 | 38 | - uses: actions/checkout@v2 |
| 39 | 39 | - uses: actions/setup-node@v1 |
| 40 | − with: {node-version: '12'} | |
| 40 | + with: | |
| 41 | + node-version: 12 | |
| 41 | 42 | - run: npm ci |
| 42 | 43 | - run: npm test |
| 44 | + | |
| 45 | + unit_tests_windows: | |
| 46 | + name: Unit tests (Windows) | |
| 47 | + runs-on: windows-latest | |
| 48 | + steps: | |
| 49 | + - uses: actions/checkout@v2 | |
| 50 | + - uses: actions/setup-node@v1 | |
| 51 | + with: | |
| 52 | + node-version: 12 | |
| 53 | + - run: npm install --production | |
| 54 | + - run: npm test |
modified
README.md
+29
−0
@@ -53,6 +53,35 @@ and Erlang/OTP.
| 53 | 53 | |
| 54 | 54 | **Note** *: prior to 23, Windows builds are only available for minor versions, e.g. 21.0, 21.3, 22.0, etc. |
| 55 | 55 | |
| 56 | +### Self-hosted runners | |
| 57 | + | |
| 58 | +Self-hosted runners need to set env. variable `ImageOS` to one of the following, since the action | |
| 59 | +uses that to download assets: | |
| 60 | + | |
| 61 | +| ImageOS | Operating system | |
| 62 | +|- |- | |
| 63 | +| ubuntu16 | ubuntu-16.04 | |
| 64 | +| ubuntu18 | ubuntu-18.04 | |
| 65 | +| ubuntu20 | ubuntu-20.04 | |
| 66 | +| win16 | windows-2016 | |
| 67 | +| win19 | windows-2019 | |
| 68 | + | |
| 69 | +as per the following example: | |
| 70 | + | |
| 71 | +```yaml | |
| 72 | +... | |
| 73 | + | |
| 74 | +jobs: | |
| 75 | + test: | |
| 76 | + runs-on: self-hosted | |
| 77 | + env: | |
| 78 | + ImageOS: ubuntu20 # equivalent to runs-on ubuntu-20.04 | |
| 79 | + steps: | |
| 80 | + - uses: actions/checkout@v2 | |
| 81 | + - uses: erlef/setup-beam@v1 | |
| 82 | + ... | |
| 83 | +``` | |
| 84 | + | |
| 56 | 85 | ### Basic example (Erlang/OTP + Elixir, on Ubuntu) |
| 57 | 86 | |
| 58 | 87 | ```yaml |
modified
__tests__/setup-beam.test.js
+1
−1
@@ -136,7 +136,7 @@ async function testOTPVersions() {
| 136 | 136 | |
| 137 | 137 | spec = '23.2.x' |
| 138 | 138 | osVersion = 'windows-2016' |
| 139 | − expected = '23.2.7.4' | |
| 139 | + expected = '23.2.7' | |
| 140 | 140 | got = await setupBeam.getOTPVersion(spec, osVersion) |
| 141 | 141 | assert.deepStrictEqual(got, expected) |
| 142 | 142 |
modified
dist/index.js
+12
−1
@@ -5001,8 +5001,19 @@ function getRunnerOSVersion() {
| 5001 | 5001 | win16: 'windows-2016', |
| 5002 | 5002 | win19: 'windows-2019', |
| 5003 | 5003 | } |
| 5004 | + const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] | |
| 5004 | 5005 | |
| 5005 | − return ImageOSToContainer[process.env.ImageOS] | |
| 5006 | + if (!containerFromEnvImageOS) { | |
| 5007 | + throw new Error( | |
| 5008 | + "Tried to map a target OS from env. variable 'ImageOS', but failed. If you're using a " + | |
| 5009 | + "self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " + | |
| 5010 | + "['" + | |
| 5011 | + `${Object.keys(ImageOSToContainer).join("', '")}` + | |
| 5012 | + "']", | |
| 5013 | + ) | |
| 5014 | + } | |
| 5015 | + | |
| 5016 | + return containerFromEnvImageOS | |
| 5006 | 5017 | } |
| 5007 | 5018 | |
| 5008 | 5019 | async function get(url0, pageIdxs) { |
modified
src/setup-beam.js
+12
−1
@@ -345,8 +345,19 @@ function getRunnerOSVersion() {
| 345 | 345 | win16: 'windows-2016', |
| 346 | 346 | win19: 'windows-2019', |
| 347 | 347 | } |
| 348 | + const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS] | |
| 348 | 349 | |
| 349 | − return ImageOSToContainer[process.env.ImageOS] | |
| 350 | + if (!containerFromEnvImageOS) { | |
| 351 | + throw new Error( | |
| 352 | + "Tried to map a target OS from env. variable 'ImageOS', but failed. If you're using a " + | |
| 353 | + "self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " + | |
| 354 | + "['" + | |
| 355 | + `${Object.keys(ImageOSToContainer).join("', '")}` + | |
| 356 | + "']", | |
| 357 | + ) | |
| 358 | + } | |
| 359 | + | |
| 360 | + return containerFromEnvImageOS | |
| 350 | 361 | } |
| 351 | 362 | |
| 352 | 363 | async function get(url0, pageIdxs) { |
Parents: 8306425