diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d6d2dff..09dc03e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -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 }} diff --git a/README.md b/README.md index e64a4dc..e68025c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 6e423d7..d8757d9 100644 --- a/action.yml +++ b/action.yml @@ -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) diff --git a/dist/index.js b/dist/index.js index 953bf01..57fe078 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4687,25 +4687,29 @@ 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 elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion) - if (elixirInstalled === true) { - const shouldMixRebar = core.getInput('install-rebar', { - required: false, - }) - await mix(shouldMixRebar, 'rebar') - const shouldMixHex = core.getInput('install-hex', { - required: false, - }) - await mix(shouldMixHex, 'hex') + 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, + }) + await mix(shouldMixRebar, 'rebar') + const shouldMixHex = core.getInput('install-hex', { + required: false, + }) + 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) } diff --git a/src/setup-beam.js b/src/setup-beam.js index 851d66b..4590662 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -15,25 +15,29 @@ 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 elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion) - if (elixirInstalled === true) { - const shouldMixRebar = core.getInput('install-rebar', { - required: false, - }) - await mix(shouldMixRebar, 'rebar') - const shouldMixHex = core.getInput('install-hex', { - required: false, - }) - await mix(shouldMixHex, 'hex') + 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, + }) + await mix(shouldMixRebar, 'rebar') + const shouldMixHex = core.getInput('install-hex', { + required: false, + }) + 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) } diff --git a/test-projects/gleam_gleam/.github/workflows/test.yml b/test-projects/gleam_gleam/.github/workflows/test.yml new file mode 100644 index 0000000..c6cd33b --- /dev/null +++ b/test-projects/gleam_gleam/.github/workflows/test.yml @@ -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 diff --git a/test-projects/gleam_gleam/.gitignore b/test-projects/gleam_gleam/.gitignore new file mode 100644 index 0000000..170cca9 --- /dev/null +++ b/test-projects/gleam_gleam/.gitignore @@ -0,0 +1,4 @@ +*.beam +*.ez +build +erl_crash.dump diff --git a/test-projects/gleam_gleam/README.md b/test-projects/gleam_gleam/README.md new file mode 100644 index 0000000..52ec1be --- /dev/null +++ b/test-projects/gleam_gleam/README.md @@ -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 +``` diff --git a/test-projects/gleam_gleam/gleam.toml b/test-projects/gleam_gleam/gleam.toml new file mode 100644 index 0000000..28af251 --- /dev/null +++ b/test-projects/gleam_gleam/gleam.toml @@ -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" diff --git a/test-projects/gleam_gleam/manifest.toml b/test-projects/gleam_gleam/manifest.toml new file mode 100644 index 0000000..3a8af1d --- /dev/null +++ b/test-projects/gleam_gleam/manifest.toml @@ -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" diff --git a/test-projects/gleam_gleam/src/gleam_gleam.gleam b/test-projects/gleam_gleam/src/gleam_gleam.gleam new file mode 100644 index 0000000..68aa094 --- /dev/null +++ b/test-projects/gleam_gleam/src/gleam_gleam.gleam @@ -0,0 +1,5 @@ +import gleam/io + +pub fn main() { + io.println("Hello from gleam_gleam!") +} diff --git a/test-projects/gleam_gleam/test/gleam_gleam_test.gleam b/test-projects/gleam_gleam/test/gleam_gleam_test.gleam new file mode 100644 index 0000000..3831e7a --- /dev/null +++ b/test-projects/gleam_gleam/test/gleam_gleam_test.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) +}