Skip to content

Commit a1b01f0

Browse files
committed
CI housekeeping
List of changes: - add CI build matrix testing both Elixir 1.13/OTP 25 and 1.19/OTP 28 - bump GitHub Actions - bump deps to fix tests - move preferred_cli_env to cli/0 (Mix deprecation) - fix deprecated warns usage - fix test errors
1 parent cec1ec7 commit a1b01f0

File tree

10 files changed

+116
-93
lines changed

10 files changed

+116
-93
lines changed

.github/workflows/tests.yml

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,39 @@ on:
99
branches:
1010
- main
1111
env:
12-
ELIXIR_VERSION: "1.13.4"
13-
OTP_VERSION: "25.0.3"
12+
PRIMARY_ELIXIR_VERSION: "1.19"
13+
PRIMARY_OTP_VERSION: "28"
1414
jobs:
1515
build_test:
16-
name: Build Test
17-
runs-on: ubuntu-20.04
16+
name: Build Test (${{ matrix.elixir }}/${{ matrix.otp }})
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
include:
21+
- elixir: "1.13"
22+
otp: "25"
23+
- elixir: "1.19"
24+
otp: "28"
1825
env:
1926
MIX_ENV: test
2027
steps:
21-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v4
2229
- name: Set up Elixir
2330
uses: erlef/setup-beam@v1
2431
with:
25-
elixir-version: ${{ env.ELIXIR_VERSION }}
26-
otp-version: ${{ env.OTP_VERSION }}
32+
elixir-version: ${{ matrix.elixir }}
33+
otp-version: ${{ matrix.otp }}
34+
2735
- name: Cache deps
28-
uses: actions/cache@v2
36+
uses: actions/cache@v4
2937
with:
3038
path: deps
31-
key: ${{ runner.os }}-test-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
39+
key: ${{ runner.os }}-test-deps-v1-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
3240
- name: Cache _build
33-
uses: actions/cache@v2
41+
uses: actions/cache@v4
3442
with:
3543
path: _build
36-
key: ${{ runner.os }}-test-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
44+
key: ${{ runner.os }}-test-build-v1-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
3745
- name: Install dependencies
3846
run: mix deps.get
3947
working-directory: .
@@ -42,86 +50,93 @@ jobs:
4250
working-directory: .
4351
build_dev:
4452
name: Build Dev
45-
runs-on: ubuntu-20.04
53+
runs-on: ubuntu-latest
4654
env:
4755
MIX_ENV: dev
4856
steps:
49-
- uses: actions/checkout@v2
57+
- uses: actions/checkout@v4
5058
- name: Set up Elixir
5159
uses: erlef/setup-beam@v1
5260
with:
53-
elixir-version: ${{ env.ELIXIR_VERSION }}
54-
otp-version: ${{ env.OTP_VERSION }}
61+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
62+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
5563
- name: Cache deps
56-
uses: actions/cache@v2
64+
uses: actions/cache@v4
5765
with:
5866
path: deps
59-
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
67+
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock') }}
6068
- name: Cache _build
61-
uses: actions/cache@v2
69+
uses: actions/cache@v4
6270
with:
6371
path: _build
64-
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
72+
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock') }}
6573
- name: Install dependencies
6674
run: mix deps.get
6775
working-directory: .
6876
- name: Compile for dev
6977
run: mix compile --force --warnings-as-errors
7078
working-directory: .
7179
test:
72-
name: Test
80+
name: Test (${{ matrix.elixir }}/${{ matrix.otp }})
7381
needs: build_test
74-
runs-on: ubuntu-20.04
82+
runs-on: ubuntu-latest
83+
strategy:
84+
matrix:
85+
include:
86+
- elixir: "1.13"
87+
otp: "25"
88+
- elixir: "1.19"
89+
otp: "28"
7590
env:
7691
MIX_ENV: test
7792
steps:
78-
- uses: actions/checkout@v2
93+
- uses: actions/checkout@v4
7994
- name: Set up Elixir
8095
uses: erlef/setup-beam@v1
8196
with:
82-
elixir-version: ${{ env.ELIXIR_VERSION }}
83-
otp-version: ${{ env.OTP_VERSION }}
97+
elixir-version: ${{ matrix.elixir }}
98+
otp-version: ${{ matrix.otp }}
8499
- name: Cache deps
85-
uses: actions/cache@v2
100+
uses: actions/cache@v4
86101
with:
87102
path: deps
88-
key: ${{ runner.os }}-test-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
103+
key: ${{ runner.os }}-test-deps-v1-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
89104
- name: Cache _build
90-
uses: actions/cache@v2
105+
uses: actions/cache@v4
91106
with:
92107
path: _build
93-
key: ${{ runner.os }}-test-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
108+
key: ${{ runner.os }}-test-build-v1-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
94109
- name: Run tests
95110
run: mix test --color --warnings-as-errors
96111
working-directory: .
97112
credo_and_dialyxir:
98113
name: Credo + Dialyxir
99114
needs: build_test
100-
runs-on: ubuntu-20.04
115+
runs-on: ubuntu-latest
101116
env:
102117
MIX_ENV: test
103118
steps:
104-
- uses: actions/checkout@v2
119+
- uses: actions/checkout@v4
105120
- name: Set up Elixir
106121
uses: erlef/setup-beam@v1
107122
with:
108-
elixir-version: ${{ env.ELIXIR_VERSION }}
109-
otp-version: ${{ env.OTP_VERSION }}
123+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
124+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
110125
- name: Cache deps
111-
uses: actions/cache@v2
126+
uses: actions/cache@v4
112127
with:
113128
path: deps
114-
key: ${{ runner.os }}-test-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
129+
key: ${{ runner.os }}-test-deps-v1-${{ env.PRIMARY_ELIXIR_VERSION }}-${{ env.PRIMARY_OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}
115130
- name: Cache _build
116-
uses: actions/cache@v2
131+
uses: actions/cache@v4
117132
with:
118133
path: _build
119-
key: ${{ runner.os }}-test-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
134+
key: ${{ runner.os }}-test-build-v1-${{ env.PRIMARY_ELIXIR_VERSION }}-${{ env.PRIMARY_OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}
120135
- name: Cache PLTs
121-
uses: actions/cache@v2
136+
uses: actions/cache@v4
122137
with:
123138
path: priv/plts
124-
key: ${{ runner.os }}-test-dialyxir-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
139+
key: ${{ runner.os }}-test-dialyxir-v1-${{ hashFiles('**/mix.lock') }}
125140
- name: Credo
126141
run: mix credo --strict
127142
working-directory: .
@@ -131,26 +146,26 @@ jobs:
131146
audit:
132147
name: Audit
133148
needs: build_dev
134-
runs-on: ubuntu-20.04
149+
runs-on: ubuntu-latest
135150
env:
136151
MIX_ENV: dev
137152
steps:
138-
- uses: actions/checkout@v2
153+
- uses: actions/checkout@v4
139154
- name: Set up Elixir
140155
uses: erlef/setup-beam@v1
141156
with:
142-
elixir-version: ${{ env.ELIXIR_VERSION }}
143-
otp-version: ${{ env.OTP_VERSION }}
157+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
158+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
144159
- name: Cache deps
145-
uses: actions/cache@v2
160+
uses: actions/cache@v4
146161
with:
147162
path: deps
148-
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
163+
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock') }}
149164
- name: Cache _build
150-
uses: actions/cache@v2
165+
uses: actions/cache@v4
151166
with:
152167
path: _build
153-
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
168+
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock') }}
154169
- name: Check Elixir formatting
155170
run: mix format --check-formatted
156171
working-directory: .
@@ -167,24 +182,24 @@ jobs:
167182
- test
168183
- credo_and_dialyxir
169184
- audit
170-
runs-on: ubuntu-20.04
185+
runs-on: ubuntu-latest
171186
steps:
172-
- uses: actions/checkout@v2
187+
- uses: actions/checkout@v4
173188
- name: Set up Elixir
174189
uses: erlef/setup-beam@v1
175190
with:
176-
elixir-version: ${{ env.ELIXIR_VERSION }}
177-
otp-version: ${{ env.OTP_VERSION }}
191+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
192+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
178193
- name: Cache deps
179-
uses: actions/cache@v2
194+
uses: actions/cache@v4
180195
with:
181196
path: deps
182-
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
197+
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock') }}
183198
- name: Cache _build
184-
uses: actions/cache@v2
199+
uses: actions/cache@v4
185200
with:
186201
path: _build
187-
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
202+
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock') }}
188203
- name: Publish to Hex
189204
uses: synchronal/hex-publish-action@v1
190205
with:

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
elixir 1.13.4-otp-24
2-
erlang 25.0.3
1+
elixir 1.19.5-otp-28
2+
erlang 28.3

lib/absinthe/graphql_ws/client.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule Absinthe.GraphqlWS.Client do
7171
def handle_call({:subscribe, gql, variables, handler}, _from, %{listeners: listeners} = state) do
7272
id = Uuid.generate()
7373

74-
state.transport.ws_send(state.gun, {:text, Jason.encode!(make_message(id, gql, variables))})
74+
state.transport.ws_send(state.gun, state.gun_stream_ref, {:text, Jason.encode!(make_message(id, gql, variables))})
7575
listeners = Map.put(listeners, id, handler)
7676
state = Map.put(state, :listeners, listeners)
7777
{:reply, {:ok, id}, state}
@@ -168,7 +168,7 @@ defmodule Absinthe.GraphqlWS.Client do
168168

169169
defp send_and_cache(id, from, message, %{queries: queries} = state) do
170170
# IO.inspect(message, label: "OUTBOUND")
171-
state.transport.ws_send(state.gun, {:text, Jason.encode!(message)})
171+
state.transport.ws_send(state.gun, state.gun_stream_ref, {:text, Jason.encode!(message)})
172172
queries = Map.put(queries, id, from)
173173
state = Map.put(state, :queries, queries)
174174
{:noreply, state}
@@ -198,5 +198,5 @@ defmodule Absinthe.GraphqlWS.Client do
198198
end
199199

200200
# defp debug(msg), do: Logger.debug("[client@#{inspect(self())}] #{msg}")
201-
defp warn(msg), do: Logger.warn("[client@#{inspect(self())}] #{msg}")
201+
defp warn(msg), do: Logger.warning("[client@#{inspect(self())}] #{msg}")
202202
end

lib/absinthe/graphql_ws/transport.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule Absinthe.GraphqlWS.Transport do
2424
@type socket() :: Socket.t()
2525

2626
defmacrop debug(msg), do: quote(do: Logger.debug("[graph-socket@#{inspect(self())}] #{unquote(msg)}"))
27-
defmacrop warn(msg), do: quote(do: Logger.warn("[graph-socket@#{inspect(self())}] #{unquote(msg)}"))
27+
defmacrop warning(msg), do: quote(do: Logger.warning("[graph-socket@#{inspect(self())}] #{unquote(msg)}"))
2828

2929
@doc """
3030
Generally this will only receive `:pong` messages in response to our keepalive
@@ -37,7 +37,7 @@ defmodule Absinthe.GraphqlWS.Transport do
3737
def handle_control({_, opcode: :pong}, socket), do: {:ok, socket}
3838

3939
def handle_control(message, state) do
40-
warn(" unhandled control frame #{inspect(message)}")
40+
warning("unhandled control frame #{inspect(message)}")
4141
{:ok, state}
4242
end
4343

@@ -53,7 +53,7 @@ defmodule Absinthe.GraphqlWS.Transport do
5353
handle_inbound(json, socket)
5454

5555
{:error, reason} ->
56-
warn("JSON parse error: #{inspect(reason)}")
56+
warning("JSON parse error: #{inspect(reason)}")
5757
{:reply, :error, {:text, Message.Error.new("4400")}, socket}
5858
end
5959
end
@@ -169,7 +169,7 @@ defmodule Absinthe.GraphqlWS.Transport do
169169
do: {:reply, :ok, {:text, Message.Pong.new()}, socket}
170170

171171
def handle_inbound(msg, socket) do
172-
warn("unhandled message #{inspect(msg)}")
172+
warning("unhandled message #{inspect(msg)}")
173173
close(4400, "Unhandled message from client", socket)
174174
end
175175

mix.exs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ defmodule AbsintheGraphqlWS.MixProject do
1414
homepage_url: "https://github.com/geometerio/absinthe_graphql_ws",
1515
name: "AbsintheGrahqlWS",
1616
package: package(),
17-
preferred_cli_env: [credo: :test, dialyzer: :test],
1817
source_url: "https://github.com/geometerio/absinthe_graphql_ws",
1918
start_permanent: Mix.env() == :prod,
2019
version: @version
@@ -27,22 +26,26 @@ defmodule AbsintheGraphqlWS.MixProject do
2726
]
2827
end
2928

29+
def cli do
30+
[preferred_envs: [credo: :test, dialyzer: :test]]
31+
end
32+
3033
defp deps do
3134
[
3235
{:absinthe, "~> 1.6"},
3336
{:absinthe_phoenix, "> 0.0.0"},
3437
{:benchee, "> 0.0.0", only: [:bench]},
35-
{:credo, "~> 1.4", only: [:dev, :test], runtime: false},
36-
{:cowlib, "~> 2.8", only: :test, override: true},
38+
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
39+
{:cowlib, "~> 2.12", only: :test, override: true},
3740
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
3841
{:eljiffy, "> 0.0.0", only: [:bench]},
3942
{:ex_doc, "~> 0.24", only: :dev, runtime: false},
40-
{:gun, "~> 1.3", only: [:test]},
43+
{:gun, "~> 2.0", only: [:test]},
4144
{:jason, "~> 1.2", optional: true},
4245
{:markdown_formatter, "~> 0.5"},
4346
{:mix_audit, "~> 1.0", only: [:dev, :test], runtime: false},
4447
{:phoenix, "~> 1.5"},
45-
{:plug_cowboy, "~> 2.5", only: :test, override: true}
48+
{:plug_cowboy, "~> 2.7", only: :test, override: true}
4649
]
4750
end
4851

0 commit comments

Comments
 (0)