mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-23 07:06:07 +00:00
Make OTP installation optional (#81)
This commit is contained in:
@@ -88,6 +88,12 @@ jobs:
|
||||
otp-version: '24'
|
||||
rebar3-version: '3.16'
|
||||
os: 'ubuntu-latest'
|
||||
- gleam-version: '0.19.0-rc3'
|
||||
otp-version: '24'
|
||||
os: 'ubuntu-latest'
|
||||
- gleam-version: '0.19.0-rc3'
|
||||
otp-version: false
|
||||
os: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use erlef/setup-beam
|
||||
@@ -101,6 +107,7 @@ jobs:
|
||||
version-type: ${{matrix.combo.version-type}}
|
||||
- name: Erlang/OTP version (action)
|
||||
run: echo "Erlang/OTP ${{steps.setup-beam.outputs.otp-version}}"
|
||||
if: ${{matrix.combo.otp-version}}
|
||||
- name: Elixir version (action)
|
||||
run: echo "Elixir ${{steps.setup-beam.outputs.elixir-version}}"
|
||||
if: ${{matrix.combo.elixir-version}}
|
||||
@@ -132,3 +139,13 @@ jobs:
|
||||
cd test-projects/gleam_rebar3
|
||||
rebar3 eunit
|
||||
if: ${{matrix.combo.gleam-version}}
|
||||
- name: Type check Gleam project (without installing Erlang/OTP)
|
||||
run: |
|
||||
cd test-projects/gleam_gleam
|
||||
gleam check
|
||||
if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }}
|
||||
- name: Run Gleam project tests (without `rebar3`)
|
||||
run: |
|
||||
cd test-projects/gleam_gleam
|
||||
gleam test
|
||||
if: ${{ matrix.combo.gleam-version && matrix.combo.otp-version && !matrix.combo.rebar3-version }}
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
This action sets up an Erlang/OTP environment for use in a GitHub Actions
|
||||
workflow by:
|
||||
|
||||
- installing Erlang/OTP
|
||||
- optionally, installing Elixir
|
||||
- optionally, installing Gleam
|
||||
- optionally, installing `rebar3`
|
||||
- optionally, installing `hex`
|
||||
- installing [Erlang/OTP](https://www.erlang.org/)
|
||||
- optionally, installing [Elixir](https://elixir-lang.org/)
|
||||
- optionally, installing [Gleam](https://gleam.run/)
|
||||
- optionally, installing [`rebar3`](https://www.rebar3.org/)
|
||||
- optionally, installing [`hex`](https://hex.pm/)
|
||||
- optionally, having
|
||||
[problem matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) show
|
||||
warnings and errors on pull requests
|
||||
warnings and errors on pull requestsotp-version: false)
|
||||
|
||||
**Note**: currently, this action only supports Actions' `ubuntu-` and `windows-` runtimes.
|
||||
|
||||
@@ -147,7 +147,7 @@ jobs:
|
||||
- run: rebar3 ct
|
||||
```
|
||||
|
||||
### Example (Gleam + `rebar3`, on Ubuntu)
|
||||
### Example (Gleam on Ubuntu)
|
||||
|
||||
```yaml
|
||||
# create this in .github/workflows/ci.yml
|
||||
@@ -161,11 +161,30 @@ jobs:
|
||||
- uses: erlef/setup-beam@v1
|
||||
with:
|
||||
otp-version: '24'
|
||||
gleam-version: '0.16'
|
||||
rebar3-version: '3.16'
|
||||
- run: rebar3 ct
|
||||
gleam-version: '0.19.0-rc3'
|
||||
- run: gleam test
|
||||
```
|
||||
|
||||
### Example (Gleam on Ubuntu without OTP)
|
||||
|
||||
```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: false
|
||||
gleam-version: '0.19.0-rc3'
|
||||
- run: gleam check
|
||||
```
|
||||
|
||||
**Note**: the `otp-version: false` input is only applicable when installing Gleam.
|
||||
|
||||
## Elixir Problem Matchers
|
||||
|
||||
The Elixir Problem Matchers in this repository are adapted from
|
||||
@@ -180,9 +199,9 @@ See [MATCHER_NOTICE](MATCHER_NOTICE.md) for license details.
|
||||
- `@v1.8`: the latest in the `1.8.z` series (this tag is movable),
|
||||
- `@v1.8.0`: release `1.8.0` (this tag is not movable).
|
||||
|
||||
To prevent issues in CI (unless you're OK with potential incompatibility between versions - we
|
||||
make real a effort to not introduce those without bumping major) we suggest you to use `@vx.y.z`,
|
||||
whenever possible.
|
||||
We make a real effort to not introduce incompatibilities without changing the major
|
||||
version number. To be extra safe against changes causing issues in your CI you should specify
|
||||
an exact version with `@vx.y.z`.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
+8
-4
@@ -8,17 +8,21 @@ branding:
|
||||
color: blue
|
||||
icon: code
|
||||
inputs:
|
||||
otp-version:
|
||||
description: Version range or exact version of Erlang/OTP to use,
|
||||
or false when installing only Gleam without OTP
|
||||
required: true
|
||||
elixir-version:
|
||||
description: Version range or exact version of Elixir to use
|
||||
otp-version:
|
||||
description: Version range or exact version of Erlang/OTP to use
|
||||
gleam-version:
|
||||
description: Version range or exact version of Gleam to use
|
||||
install-hex:
|
||||
description: Whether to install Hex (with Mix)
|
||||
description: Whether to install Hex (with mix local.hex
|
||||
when installing Elixir)
|
||||
default: true
|
||||
install-rebar:
|
||||
description: Whether to install Rebar (with Mix)
|
||||
description: Whether to install Rebar (with mix local.rebar
|
||||
when installing Elixir)
|
||||
default: true
|
||||
rebar3-version:
|
||||
description: Version range or exact version of rebar3 to use (or nightly)
|
||||
|
||||
Vendored
+9
-5
@@ -4687,10 +4687,14 @@ async function main() {
|
||||
|
||||
const osVersion = getRunnerOSVersion()
|
||||
const otpSpec = core.getInput('otp-version', { required: true })
|
||||
const otpVersion = await installOTP(otpSpec, osVersion)
|
||||
|
||||
const elixirSpec = core.getInput('elixir-version', { required: false })
|
||||
const gleamSpec = core.getInput('gleam-version', { required: false })
|
||||
const rebar3Spec = core.getInput('rebar3-version', { required: false })
|
||||
|
||||
if (otpSpec !== 'false') {
|
||||
const otpVersion = await installOTP(otpSpec, osVersion)
|
||||
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion)
|
||||
|
||||
if (elixirInstalled === true) {
|
||||
const shouldMixRebar = core.getInput('install-rebar', {
|
||||
required: false,
|
||||
@@ -4701,11 +4705,11 @@ async function main() {
|
||||
})
|
||||
await mix(shouldMixHex, 'hex')
|
||||
}
|
||||
} else if (!gleamSpec) {
|
||||
throw new Error('otp-version=false is only available when installing Gleam')
|
||||
}
|
||||
|
||||
const gleamSpec = core.getInput('gleam-version', { required: false })
|
||||
await maybeInstallGleam(gleamSpec)
|
||||
|
||||
const rebar3Spec = core.getInput('rebar3-version', { required: false })
|
||||
await maybeInstallRebar3(rebar3Spec)
|
||||
}
|
||||
|
||||
|
||||
+9
-5
@@ -15,10 +15,14 @@ async function main() {
|
||||
|
||||
const osVersion = getRunnerOSVersion()
|
||||
const otpSpec = core.getInput('otp-version', { required: true })
|
||||
const otpVersion = await installOTP(otpSpec, osVersion)
|
||||
|
||||
const elixirSpec = core.getInput('elixir-version', { required: false })
|
||||
const gleamSpec = core.getInput('gleam-version', { required: false })
|
||||
const rebar3Spec = core.getInput('rebar3-version', { required: false })
|
||||
|
||||
if (otpSpec !== 'false') {
|
||||
const otpVersion = await installOTP(otpSpec, osVersion)
|
||||
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion)
|
||||
|
||||
if (elixirInstalled === true) {
|
||||
const shouldMixRebar = core.getInput('install-rebar', {
|
||||
required: false,
|
||||
@@ -29,11 +33,11 @@ async function main() {
|
||||
})
|
||||
await mix(shouldMixHex, 'hex')
|
||||
}
|
||||
} else if (!gleamSpec) {
|
||||
throw new Error('otp-version=false is only available when installing Gleam')
|
||||
}
|
||||
|
||||
const gleamSpec = core.getInput('gleam-version', { required: false })
|
||||
await maybeInstallGleam(gleamSpec)
|
||||
|
||||
const rebar3Spec = core.getInput('rebar3-version', { required: false })
|
||||
await maybeInstallRebar3(rebar3Spec)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: erlef/setup-beam@v1.9.0
|
||||
with:
|
||||
otp-version: "23.2"
|
||||
gleam-version: "0.19.0-rc3"
|
||||
- run: gleam format --check src test
|
||||
- run: gleam deps download
|
||||
- run: gleam test
|
||||
@@ -0,0 +1,4 @@
|
||||
*.beam
|
||||
*.ez
|
||||
build
|
||||
erl_crash.dump
|
||||
@@ -0,0 +1,19 @@
|
||||
# gleam_gleam
|
||||
|
||||
A Gleam project
|
||||
|
||||
## Quick start
|
||||
|
||||
```sh
|
||||
gleam run # Run the project
|
||||
gleam test # Run the tests
|
||||
gleam shell # Run an Erlang shell
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
If available on Hex this package can be added to your Gleam project.
|
||||
|
||||
```sh
|
||||
gleam add gleam_gleam
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
name = "gleam_gleam"
|
||||
version = "0.1.0"
|
||||
|
||||
# Fill out these fields if you intend to generate HTML documentation or publish
|
||||
# your project to the Hex package manager.
|
||||
#
|
||||
# licences = ["Apache-2.0"]
|
||||
# description = "A Gleam library..."
|
||||
# repository = { type = "github", user = "username", repo = "project" }
|
||||
# links = [{ title = "Website", href = "https://gleam.run" }]
|
||||
|
||||
[dependencies]
|
||||
gleam_stdlib = "~> 0.18"
|
||||
|
||||
[dev-dependencies]
|
||||
gleeunit = "~> 0.5"
|
||||
@@ -0,0 +1,11 @@
|
||||
# This file was generated by Gleam
|
||||
# You typically do not need to edit this file
|
||||
|
||||
packages = [
|
||||
{ name = "gleam_stdlib", version = "0.19.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "FFA79EA12369F122B68885E694E097D6810402A2F86BFF48AAE9E40ACE654F4C" },
|
||||
{ name = "gleeunit", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "77701A5E5A565727E1EEAC9196FB878D544049B6331CD0305B5A69699135EA1C" },
|
||||
]
|
||||
|
||||
[requirements]
|
||||
gleam_stdlib = "~> 0.18"
|
||||
gleeunit = "~> 0.5"
|
||||
@@ -0,0 +1,5 @@
|
||||
import gleam/io
|
||||
|
||||
pub fn main() {
|
||||
io.println("Hello from gleam_gleam!")
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import gleeunit
|
||||
import gleeunit/should
|
||||
|
||||
pub fn main() {
|
||||
gleeunit.main()
|
||||
}
|
||||
|
||||
// gleeunit test functions end in `_test`
|
||||
pub fn hello_world_test() {
|
||||
1
|
||||
|> should.equal(1)
|
||||
}
|
||||
Reference in New Issue
Block a user