Skip to content

Commit

Permalink
Simplify CI (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide authored Jun 18, 2024
1 parent a0246d5 commit f2ce356
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 42 deletions.
62 changes: 26 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,51 @@ on:

jobs:
test:
runs-on: ubuntu-22.04
name: Elixir ${{ matrix.elixir }}/OTP ${{ matrix.otp }}
runs-on: ${{ matrix.os }}
env:
MIX_ENV: test

strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: 1.14.2
otp: 25.0
lint: lint
# Latest supported versions.
- os: ubuntu-22.04
elixir: "1.17"
otp: "27.0"
lint: true

# This is a middle ground: it's old versions that we probably want to start
# requiring at some point, but technically we support older.
- os: ubuntu-20.04
elixir: "1.13"
otp: "22.3"

# Oldest supported versions.
- os: ubuntu-18.04
elixir: "1.7.4"
otp: "19.3.6.13"

steps:
- uses: actions/checkout@v2
- name: Check out this repository
uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
- name: Set up Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.pair.otp }}
elixir-version: ${{ matrix.pair.elixir }}
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}

- name: Install dependencies
run: mix do deps.get --only $MIX_ENV, deps.compile
run: mix deps.get --only $MIX_ENV

- name: Check that code is formatted
run: mix format --check-formatted
if: ${{ matrix.lint }}

- name: Check that there are no unused dependencies in mix.lock
run: mix deps.get && mix deps.unlock --check-unused
run: mix do deps.get, deps.unlock --check-unused
if: ${{ matrix.lint }}

- name: Compile with --warnings-as-errors
Expand All @@ -46,28 +61,3 @@ jobs:

- name: Run tests
run: mix test

test_older_elixir:
runs-on: ubuntu-18.04
env:
MIX_ENV: test
strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: 1.7.4
otp: 19.3.6.13
steps:
- uses: actions/checkout@v2

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.pair.otp }}
elixir-version: ${{ matrix.pair.elixir }}

- name: Install dependencies
run: mix do deps.get --only $MIX_ENV, deps.compile

- name: Run tests
run: mix test
23 changes: 17 additions & 6 deletions test/gen_stage_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ defmodule GenStageTest do
end
end

# TODO: remove this once we require OTP 26+. This is a workaround for changes
# in OTP 26 around returning {:stop, _} from start_link and friends. See the
# discussion in https://github.com/elixir-lang/gen_stage/pull/306.
defmacrop assert_exit_on_older_otp(reason) do
quote do
if System.otp_release() <= "25" do
assert_receive {:EXIT, _, unquote(reason)}
end
end
end

test "generates child_spec/1" do
assert Counter.child_spec([:hello]) == %{
id: Counter,
Expand Down Expand Up @@ -1256,9 +1267,9 @@ defmodule GenStageTest do
assert Counter.start_link(:ignore) == :ignore

assert Counter.start_link({:stop, :oops}) == {:error, :oops}
assert_receive {:EXIT, _, :oops}
assert_exit_on_older_otp(:oops)
assert Counter.start_link(:unknown) == {:error, {:bad_return_value, :unknown}}
assert_receive {:EXIT, _, {:bad_return_value, :unknown}}
assert_exit_on_older_otp({:bad_return_value, :unknown})

error = {:bad_opts, "expected :buffer_size to be equal to or greater than 0, got: -1"}
assert Counter.start_link({:producer, 0, buffer_size: -1}) == {:error, error}
Expand Down Expand Up @@ -1402,9 +1413,9 @@ defmodule GenStageTest do
assert Forwarder.start_link(:ignore) == :ignore

assert Forwarder.start_link({:stop, :oops}) == {:error, :oops}
assert_receive {:EXIT, _, :oops}
assert_exit_on_older_otp(:oops)
assert Forwarder.start_link(:unknown) == {:error, {:bad_return_value, :unknown}}
assert_receive {:EXIT, _, {:bad_return_value, :unknown}}
assert_exit_on_older_otp({:bad_return_value, :unknown})

assert Forwarder.start_link({:consumer, self(), unknown: :value}) ==
{:error, {:bad_opts, "unknown options [unknown: :value]"}}
Expand Down Expand Up @@ -1543,9 +1554,9 @@ defmodule GenStageTest do
assert Doubler.start_link(:ignore) == :ignore

assert Doubler.start_link({:stop, :oops}) == {:error, :oops}
assert_receive {:EXIT, _, :oops}
assert_exit_on_older_otp(:oops)
assert Doubler.start_link(:unknown) == {:error, {:bad_return_value, :unknown}}
assert_receive {:EXIT, _, {:bad_return_value, :unknown}}
assert_exit_on_older_otp({:bad_return_value, :unknown})

assert Doubler.start_link({:producer_consumer, self(), unknown: :value}) ==
{:error, {:bad_opts, "unknown options [unknown: :value]"}}
Expand Down

0 comments on commit f2ce356

Please sign in to comment.