Skip to content

Commit f2ce356

Browse files
authored
Simplify CI (#306)
1 parent a0246d5 commit f2ce356

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,51 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ubuntu-22.04
11+
name: Elixir ${{ matrix.elixir }}/OTP ${{ matrix.otp }}
12+
runs-on: ${{ matrix.os }}
1213
env:
1314
MIX_ENV: test
1415

1516
strategy:
1617
fail-fast: false
1718
matrix:
1819
include:
19-
- pair:
20-
elixir: 1.14.2
21-
otp: 25.0
22-
lint: lint
20+
# Latest supported versions.
21+
- os: ubuntu-22.04
22+
elixir: "1.17"
23+
otp: "27.0"
24+
lint: true
25+
26+
# This is a middle ground: it's old versions that we probably want to start
27+
# requiring at some point, but technically we support older.
28+
- os: ubuntu-20.04
29+
elixir: "1.13"
30+
otp: "22.3"
31+
32+
# Oldest supported versions.
33+
- os: ubuntu-18.04
34+
elixir: "1.7.4"
35+
otp: "19.3.6.13"
2336

2437
steps:
25-
- uses: actions/checkout@v2
38+
- name: Check out this repository
39+
uses: actions/checkout@v4
2640

27-
- uses: erlef/setup-beam@v1
41+
- name: Set up Erlang and Elixir
42+
uses: erlef/setup-beam@v1
2843
with:
29-
otp-version: ${{ matrix.pair.otp }}
30-
elixir-version: ${{ matrix.pair.elixir }}
44+
otp-version: ${{ matrix.otp }}
45+
elixir-version: ${{ matrix.elixir }}
3146

3247
- name: Install dependencies
33-
run: mix do deps.get --only $MIX_ENV, deps.compile
48+
run: mix deps.get --only $MIX_ENV
3449

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

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

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

4762
- name: Run tests
4863
run: mix test
49-
50-
test_older_elixir:
51-
runs-on: ubuntu-18.04
52-
env:
53-
MIX_ENV: test
54-
strategy:
55-
fail-fast: false
56-
matrix:
57-
include:
58-
- pair:
59-
elixir: 1.7.4
60-
otp: 19.3.6.13
61-
steps:
62-
- uses: actions/checkout@v2
63-
64-
- uses: erlef/setup-beam@v1
65-
with:
66-
otp-version: ${{ matrix.pair.otp }}
67-
elixir-version: ${{ matrix.pair.elixir }}
68-
69-
- name: Install dependencies
70-
run: mix do deps.get --only $MIX_ENV, deps.compile
71-
72-
- name: Run tests
73-
run: mix test

test/gen_stage_test.exs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,17 @@ defmodule GenStageTest do
300300
end
301301
end
302302

303+
# TODO: remove this once we require OTP 26+. This is a workaround for changes
304+
# in OTP 26 around returning {:stop, _} from start_link and friends. See the
305+
# discussion in https://github.com/elixir-lang/gen_stage/pull/306.
306+
defmacrop assert_exit_on_older_otp(reason) do
307+
quote do
308+
if System.otp_release() <= "25" do
309+
assert_receive {:EXIT, _, unquote(reason)}
310+
end
311+
end
312+
end
313+
303314
test "generates child_spec/1" do
304315
assert Counter.child_spec([:hello]) == %{
305316
id: Counter,
@@ -1256,9 +1267,9 @@ defmodule GenStageTest do
12561267
assert Counter.start_link(:ignore) == :ignore
12571268

12581269
assert Counter.start_link({:stop, :oops}) == {:error, :oops}
1259-
assert_receive {:EXIT, _, :oops}
1270+
assert_exit_on_older_otp(:oops)
12601271
assert Counter.start_link(:unknown) == {:error, {:bad_return_value, :unknown}}
1261-
assert_receive {:EXIT, _, {:bad_return_value, :unknown}}
1272+
assert_exit_on_older_otp({:bad_return_value, :unknown})
12621273

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

14041415
assert Forwarder.start_link({:stop, :oops}) == {:error, :oops}
1405-
assert_receive {:EXIT, _, :oops}
1416+
assert_exit_on_older_otp(:oops)
14061417
assert Forwarder.start_link(:unknown) == {:error, {:bad_return_value, :unknown}}
1407-
assert_receive {:EXIT, _, {:bad_return_value, :unknown}}
1418+
assert_exit_on_older_otp({:bad_return_value, :unknown})
14081419

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

15451556
assert Doubler.start_link({:stop, :oops}) == {:error, :oops}
1546-
assert_receive {:EXIT, _, :oops}
1557+
assert_exit_on_older_otp(:oops)
15471558
assert Doubler.start_link(:unknown) == {:error, {:bad_return_value, :unknown}}
1548-
assert_receive {:EXIT, _, {:bad_return_value, :unknown}}
1559+
assert_exit_on_older_otp({:bad_return_value, :unknown})
15491560

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

0 commit comments

Comments
 (0)