neiam
/action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Make OTP installation optional (#81)
3179686 · Michał Łępicki · 2022-01-12 14:26
Files changed
modified
.github/workflows/ubuntu.yml
+17
−0
@@ -88,6 +88,12 @@ jobs:
| 88 | 88 | otp-version: '24' |
| 89 | 89 | rebar3-version: '3.16' |
| 90 | 90 | os: 'ubuntu-latest' |
| 91 | + - gleam-version: '0.19.0-rc3' | |
| 92 | + otp-version: '24' | |
| 93 | + os: 'ubuntu-latest' | |
| 94 | + - gleam-version: '0.19.0-rc3' | |
| 95 | + otp-version: false | |
| 96 | + os: 'ubuntu-latest' | |
| 91 | 97 | steps: |
| 92 | 98 | - uses: actions/checkout@v2 |
| 93 | 99 | - name: Use erlef/setup-beam |
@@ -101,6 +107,7 @@ jobs:
| 101 | 107 | version-type: ${{matrix.combo.version-type}} |
| 102 | 108 | - name: Erlang/OTP version (action) |
| 103 | 109 | run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}" |
| 110 | + if: ${{matrix.combo.otp-version}} | |
| 104 | 111 | - name: Elixir version (action) |
| 105 | 112 | run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}" |
| 106 | 113 | if: ${{matrix.combo.elixir-version}} |
@@ -132,3 +139,13 @@ jobs:
| 132 | 139 | cd test-projects/gleam_rebar3 |
| 133 | 140 | rebar3 eunit |
| 134 | 141 | if: ${{matrix.combo.gleam-version}} |
| 142 | + - name: Type check Gleam project (without installing Erlang/OTP) | |
| 143 | + run: | | |
| 144 | + cd test-projects/gleam_gleam | |
| 145 | + gleam check | |
| 146 | + if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }} | |
| 147 | + - name: Run Gleam project tests (without `rebar3`) | |
| 148 | + run: | | |
| 149 | + cd test-projects/gleam_gleam | |
| 150 | + gleam test | |
| 151 | + if: ${{ matrix.combo.gleam-version && matrix.combo.otp-version && !matrix.combo.rebar3-version }} |
modified
README.md
+32
−13
@@ -11,14 +11,14 @@
| 11 | 11 | This action sets up an Erlang/OTP environment for use in a GitHub Actions |
| 12 | 12 | workflow by: |
| 13 | 13 | |
| 14 | −- installing Erlang/OTP | |
| 15 | −- optionally, installing Elixir | |
| 16 | −- optionally, installing Gleam | |
| 17 | −- optionally, installing `rebar3` | |
| 18 | −- optionally, installing `hex` | |
| 14 | +- installing [Erlang/OTP](https://www.erlang.org/) | |
| 15 | +- optionally, installing [Elixir](https://elixir-lang.org/) | |
| 16 | +- optionally, installing [Gleam](https://gleam.run/) | |
| 17 | +- optionally, installing [`rebar3`](https://www.rebar3.org/) | |
| 18 | +- optionally, installing [`hex`](https://hex.pm/) | |
| 19 | 19 | - optionally, having |
| 20 | 20 | [problem matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) show |
| 21 | − warnings and errors on pull requests | |
| 21 | + warnings and errors on pull requestsotp-version: false) | |
| 22 | 22 | |
| 23 | 23 | **Note**: currently, this action only supports Actions' `ubuntu-` and `windows-` runtimes. |
| 24 | 24 |
@@ -147,7 +147,7 @@ jobs:
| 147 | 147 | - run: rebar3 ct |
| 148 | 148 | ``` |
| 149 | 149 | |
| 150 | −### Example (Gleam + `rebar3`, on Ubuntu) | |
| 150 | +### Example (Gleam on Ubuntu) | |
| 151 | 151 | |
| 152 | 152 | ```yaml |
| 153 | 153 | # create this in .github/workflows/ci.yml |
@@ -161,11 +161,30 @@ jobs:
| 161 | 161 | - uses: erlef/setup-beam@v1 |
| 162 | 162 | with: |
| 163 | 163 | otp-version: '24' |
| 164 | − gleam-version: '0.16' | |
| 165 | − rebar3-version: '3.16' | |
| 166 | − - run: rebar3 ct | |
| 164 | + gleam-version: '0.19.0-rc3' | |
| 165 | + - run: gleam test | |
| 166 | +``` | |
| 167 | + | |
| 168 | +### Example (Gleam on Ubuntu without OTP) | |
| 169 | + | |
| 170 | +```yaml | |
| 171 | +# create this in .github/workflows/ci.yml | |
| 172 | +on: push | |
| 173 | + | |
| 174 | +jobs: | |
| 175 | + test: | |
| 176 | + runs-on: ubuntu-latest | |
| 177 | + steps: | |
| 178 | + - uses: actions/checkout@v2 | |
| 179 | + - uses: erlef/setup-beam@v1 | |
| 180 | + with: | |
| 181 | + otp-version: false | |
| 182 | + gleam-version: '0.19.0-rc3' | |
| 183 | + - run: gleam check | |
| 167 | 184 | ``` |
| 168 | 185 | |
| 186 | +**Note**: the `otp-version: false` input is only applicable when installing Gleam. | |
| 187 | + | |
| 169 | 188 | ## Elixir Problem Matchers |
| 170 | 189 | |
| 171 | 190 | The Elixir Problem Matchers in this repository are adapted from |
@@ -180,9 +199,9 @@ See [MATCHER_NOTICE](MATCHER_NOTICE.md) for license details.
| 180 | 199 | - `@v1.8`: the latest in the `1.8.z` series (this tag is movable), |
| 181 | 200 | - `@v1.8.0`: release `1.8.0` (this tag is not movable). |
| 182 | 201 | |
| 183 | −To prevent issues in CI (unless you're OK with potential incompatibility between versions - we | |
| 184 | −make real a effort to not introduce those without bumping major) we suggest you to use `@vx.y.z`, | |
| 185 | −whenever possible. | |
| 202 | +We make a real effort to not introduce incompatibilities without changing the major | |
| 203 | +version number. To be extra safe against changes causing issues in your CI you should specify | |
| 204 | +an exact version with `@vx.y.z`. | |
| 186 | 205 | |
| 187 | 206 | ## License |
| 188 | 207 |
modified
action.yml
+8
−4
@@ -8,17 +8,21 @@ branding:
| 8 | 8 | color: blue |
| 9 | 9 | icon: code |
| 10 | 10 | inputs: |
| 11 | + otp-version: | |
| 12 | + description: Version range or exact version of Erlang/OTP to use, | |
| 13 | + or false when installing only Gleam without OTP | |
| 14 | + required: true | |
| 11 | 15 | elixir-version: |
| 12 | 16 | description: Version range or exact version of Elixir to use |
| 13 | − otp-version: | |
| 14 | − description: Version range or exact version of Erlang/OTP to use | |
| 15 | 17 | gleam-version: |
| 16 | 18 | description: Version range or exact version of Gleam to use |
| 17 | 19 | install-hex: |
| 18 | − description: Whether to install Hex (with Mix) | |
| 20 | + description: Whether to install Hex (with mix local.hex | |
| 21 | + when installing Elixir) | |
| 19 | 22 | default: true |
| 20 | 23 | install-rebar: |
| 21 | − description: Whether to install Rebar (with Mix) | |
| 24 | + description: Whether to install Rebar (with mix local.rebar | |
| 25 | + when installing Elixir) | |
| 22 | 26 | default: true |
| 23 | 27 | rebar3-version: |
| 24 | 28 | description: Version range or exact version of rebar3 to use (or nightly) |
modified
dist/index.js
+19
−15
@@ -4687,25 +4687,29 @@ async function main() {
| 4687 | 4687 | |
| 4688 | 4688 | const osVersion = getRunnerOSVersion() |
| 4689 | 4689 | const otpSpec = core.getInput('otp-version', { required: true }) |
| 4690 | − const otpVersion = await installOTP(otpSpec, osVersion) | |
| 4691 | − | |
| 4692 | 4690 | const elixirSpec = core.getInput('elixir-version', { required: false }) |
| 4693 | − const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion) | |
| 4694 | − if (elixirInstalled === true) { | |
| 4695 | − const shouldMixRebar = core.getInput('install-rebar', { | |
| 4696 | − required: false, | |
| 4697 | − }) | |
| 4698 | − await mix(shouldMixRebar, 'rebar') | |
| 4699 | − const shouldMixHex = core.getInput('install-hex', { | |
| 4700 | − required: false, | |
| 4701 | − }) | |
| 4702 | − await mix(shouldMixHex, 'hex') | |
| 4691 | + const gleamSpec = core.getInput('gleam-version', { required: false }) | |
| 4692 | + const rebar3Spec = core.getInput('rebar3-version', { required: false }) | |
| 4693 | + | |
| 4694 | + if (otpSpec !== 'false') { | |
| 4695 | + const otpVersion = await installOTP(otpSpec, osVersion) | |
| 4696 | + const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion) | |
| 4697 | + | |
| 4698 | + if (elixirInstalled === true) { | |
| 4699 | + const shouldMixRebar = core.getInput('install-rebar', { | |
| 4700 | + required: false, | |
| 4701 | + }) | |
| 4702 | + await mix(shouldMixRebar, 'rebar') | |
| 4703 | + const shouldMixHex = core.getInput('install-hex', { | |
| 4704 | + required: false, | |
| 4705 | + }) | |
| 4706 | + await mix(shouldMixHex, 'hex') | |
| 4707 | + } | |
| 4708 | + } else if (!gleamSpec) { | |
| 4709 | + throw new Error('otp-version=false is only available when installing Gleam') | |
| 4703 | 4710 | } |
| 4704 | 4711 | |
| 4705 | − const gleamSpec = core.getInput('gleam-version', { required: false }) | |
| 4706 | 4712 | await maybeInstallGleam(gleamSpec) |
| 4707 | − | |
| 4708 | − const rebar3Spec = core.getInput('rebar3-version', { required: false }) | |
| 4709 | 4713 | await maybeInstallRebar3(rebar3Spec) |
| 4710 | 4714 | } |
| 4711 | 4715 |
modified
src/setup-beam.js
+19
−15
@@ -15,25 +15,29 @@ async function main() {
| 15 | 15 | |
| 16 | 16 | const osVersion = getRunnerOSVersion() |
| 17 | 17 | const otpSpec = core.getInput('otp-version', { required: true }) |
| 18 | − const otpVersion = await installOTP(otpSpec, osVersion) | |
| 19 | − | |
| 20 | 18 | const elixirSpec = core.getInput('elixir-version', { required: false }) |
| 21 | − const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion) | |
| 22 | − if (elixirInstalled === true) { | |
| 23 | − const shouldMixRebar = core.getInput('install-rebar', { | |
| 24 | − required: false, | |
| 25 | − }) | |
| 26 | − await mix(shouldMixRebar, 'rebar') | |
| 27 | − const shouldMixHex = core.getInput('install-hex', { | |
| 28 | − required: false, | |
| 29 | − }) | |
| 30 | − await mix(shouldMixHex, 'hex') | |
| 19 | + const gleamSpec = core.getInput('gleam-version', { required: false }) | |
| 20 | + const rebar3Spec = core.getInput('rebar3-version', { required: false }) | |
| 21 | + | |
| 22 | + if (otpSpec !== 'false') { | |
| 23 | + const otpVersion = await installOTP(otpSpec, osVersion) | |
| 24 | + const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion) | |
| 25 | + | |
| 26 | + if (elixirInstalled === true) { | |
| 27 | + const shouldMixRebar = core.getInput('install-rebar', { | |
| 28 | + required: false, | |
| 29 | + }) | |
| 30 | + await mix(shouldMixRebar, 'rebar') | |
| 31 | + const shouldMixHex = core.getInput('install-hex', { | |
| 32 | + required: false, | |
| 33 | + }) | |
| 34 | + await mix(shouldMixHex, 'hex') | |
| 35 | + } | |
| 36 | + } else if (!gleamSpec) { | |
| 37 | + throw new Error('otp-version=false is only available when installing Gleam') | |
| 31 | 38 | } |
| 32 | 39 | |
| 33 | − const gleamSpec = core.getInput('gleam-version', { required: false }) | |
| 34 | 40 | await maybeInstallGleam(gleamSpec) |
| 35 | − | |
| 36 | − const rebar3Spec = core.getInput('rebar3-version', { required: false }) | |
| 37 | 41 | await maybeInstallRebar3(rebar3Spec) |
| 38 | 42 | } |
| 39 | 43 |
added
test-projects/gleam_gleam/.github/workflows/test.yml
+21
−0
Click to load diff…
added
test-projects/gleam_gleam/.gitignore
+4
−0
Click to load diff…
added
test-projects/gleam_gleam/README.md
+19
−0
Click to load diff…
added
test-projects/gleam_gleam/gleam.toml
+16
−0
Click to load diff…
added
test-projects/gleam_gleam/manifest.toml
+11
−0
Click to load diff…
added
test-projects/gleam_gleam/src/gleam_gleam.gleam
+5
−0
Click to load diff…
added
test-projects/gleam_gleam/test/gleam_gleam_test.gleam
+12
−0
Click to load diff…
Parents: 65219de