8000 Improve warning message for missing ImageOS env. variable (self-hosted runners) by paulo-ferraz-oliveira · Pull Request #59 · erlef/setup-beam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve warning message for missing ImageOS env. variable (self-hosted runners) #59

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 ema 8000 ils.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2021
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
20 changes: 16 additions & 4 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: 12
- run: npm install -g npm
- run: npm install
- run: npm run build
Expand All @@ -31,12 +31,24 @@ jobs:
- name: Check if build left artifacts
run: git diff --exit-code

unit_test:
name: Unit tests
unit_tests_ubuntu:
name: Unit tests (Ubuntu)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with: {node-version: '12'}
with:
node-version: 12
- run: npm ci
- run: npm test

unit_tests_windows:
name: Unit tests (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install --production
- run: npm test
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,35 @@ and Erlang/OTP.

**Note** *: prior to 23, Windows builds are only available for minor versions, e.g. 21.0, 21.3, 22.0, etc.

### Self-hosted runners

Self-hosted runners need to set env. variable `ImageOS` to one of the following, since the action
uses that to download assets:

| ImageOS | Operating system
|- |-
| ubuntu16 | ubuntu-16.04
| ubuntu18 | ubuntu-18.04
| ubuntu20 | ubuntu-20.04
| win16 | windows-2016
| win19 | windows-2019

as per the following example:

```yaml
...

jobs:
test:
runs-on: self-hosted
env:
ImageOS: ubuntu20 # equivalent to runs-on ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
...
```

### Basic example (Erlang/OTP + Elixir, on Ubuntu)

```yaml
Expand Down
2 changes: 1 addition & 1 deletion __tests__/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async function testOTPVersions() {

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

Expand Down
13 changes: 12 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5001,8 +5001,19 @@ function getRunnerOSVersion() {
win16: 'windows-2016',
win19: 'windows-2019',
}
const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS]

return ImageOSToContainer[process.env.ImageOS]
if (!containerFromEnvImageOS) {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS', but failed. If you're using a " +
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example output:

Tried to map a target OS from env. variable 'ImageOS', but failed. If you're using a self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: ['ubuntu16', 'ubuntu18', 'ubuntu20', 'win16', 'win19']

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this way the list will be as updated as the constant definition)

"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
`${Object.keys(ImageOSToContainer).join("', '")}` +
"']",
)
}

return containerFromEnvImageOS
}

async function get(url0, pageIdxs) {
Expand Down
13 changes: 12 additions & 1 deletion src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,19 @@ function getRunnerOSVersion() {
win16: 'windows-2016',
win19: 'windows-2019',
}
const containerFromEnvImageOS = ImageOSToContainer[process.env.ImageOS]

return ImageOSToContainer[process.env.ImageOS]
if (!containerFromEnvImageOS) {
throw new Error(
"Tried to map a target OS from env. variable 'ImageOS', but failed. If you're using a " +
"self-hosted runner, you should set 'env': 'ImageOS': ... to one of the following: " +
"['" +
`${Object.keys(ImageOSToContainer).join("', '")}` +
"']",
)
}

return containerFromEnvImageOS
}

async function get(url0, pageIdxs) {
Expand Down
0