Skip to content

Commit 0aac2f9

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 0aac2f9

File tree

10 files changed

+143
-111
lines changed

10 files changed

+143
-111
lines changed

.github/workflows/tests.yml

Lines changed: 75 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,119 +9,140 @@ 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: .
48+
- name: Compile deps
49+
run: mix deps.compile
50+
working-directory: .
4051
- name: Compile for test
4152
run: mix compile --force --warnings-as-errors
4253
working-directory: .
4354
build_dev:
4455
name: Build Dev
45-
runs-on: ubuntu-20.04
56+
runs-on: ubuntu-latest
4657
env:
4758
MIX_ENV: dev
4859
steps:
49-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@v4
5061
- name: Set up Elixir
5162
uses: erlef/setup-beam@v1
5263
with:
53-
elixir-version: ${{ env.ELIXIR_VERSION }}
54-
otp-version: ${{ env.OTP_VERSION }}
64+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
65+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
5566
- name: Cache deps
56-
uses: actions/cache@v2
67+
uses: actions/cache@v4
5768
with:
5869
path: deps
59-
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
70+
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock') }}
6071
- name: Cache _build
61-
uses: actions/cache@v2
72+
uses: actions/cache@v4
6273
with:
6374
path: _build
64-
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
75+
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock') }}
6576
- name: Install dependencies
6677
run: mix deps.get
6778
working-directory: .
79+
- name: Compile deps
80+
run: mix deps.compile
81+
working-directory: .
6882
- name: Compile for dev
6983
run: mix compile --force --warnings-as-errors
7084
working-directory: .
7185
test:
72-
name: Test
86+
name: Test (${{ matrix.elixir }}/${{ matrix.otp }})
7387
needs: build_test
74-
runs-on: ubuntu-20.04
88+
runs-on: ubuntu-latest
89+
strategy:
90+
matrix:
91+
include:
92+
- elixir: "1.13"
93+
otp: "25"
94+
- elixir: "1.19"
95+
otp: "28"
7596
env:
7697
MIX_ENV: test
7798
steps:
78-
- uses: actions/checkout@v2
99+
- uses: actions/checkout@v4
79100
- name: Set up Elixir
80101
uses: erlef/setup-beam@v1
81102
with:
82-
elixir-version: ${{ env.ELIXIR_VERSION }}
83-
otp-version: ${{ env.OTP_VERSION }}
103+
elixir-version: ${{ matrix.elixir }}
104+
otp-version: ${{ matrix.otp }}
84105
- name: Cache deps
85-
uses: actions/cache@v2
106+
uses: actions/cache@v4
86107
with:
87108
path: deps
88-
key: ${{ runner.os }}-test-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
109+
key: ${{ runner.os }}-test-deps-v1-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
89110
- name: Cache _build
90-
uses: actions/cache@v2
111+
uses: actions/cache@v4
91112
with:
92113
path: _build
93-
key: ${{ runner.os }}-test-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
114+
key: ${{ runner.os }}-test-build-v1-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
94115
- name: Run tests
95116
run: mix test --color --warnings-as-errors
96117
working-directory: .
97118
credo_and_dialyxir:
98119
name: Credo + Dialyxir
99120
needs: build_test
100-
runs-on: ubuntu-20.04
121+
runs-on: ubuntu-latest
101122
env:
102123
MIX_ENV: test
103124
steps:
104-
- uses: actions/checkout@v2
125+
- uses: actions/checkout@v4
105126
- name: Set up Elixir
106127
uses: erlef/setup-beam@v1
107128
with:
108-
elixir-version: ${{ env.ELIXIR_VERSION }}
109-
otp-version: ${{ env.OTP_VERSION }}
129+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
130+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
110131
- name: Cache deps
111-
uses: actions/cache@v2
132+
uses: actions/cache@v4
112133
with:
113134
path: deps
114-
key: ${{ runner.os }}-test-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
135+
key: ${{ runner.os }}-test-deps-v1-${{ env.PRIMARY_ELIXIR_VERSION }}-${{ env.PRIMARY_OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}
115136
- name: Cache _build
116-
uses: actions/cache@v2
137+
uses: actions/cache@v4
117138
with:
118139
path: _build
119-
key: ${{ runner.os }}-test-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
140+
key: ${{ runner.os }}-test-build-v1-${{ env.PRIMARY_ELIXIR_VERSION }}-${{ env.PRIMARY_OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}
120141
- name: Cache PLTs
121-
uses: actions/cache@v2
142+
uses: actions/cache@v4
122143
with:
123144
path: priv/plts
124-
key: ${{ runner.os }}-test-dialyxir-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
145+
key: ${{ runner.os }}-test-dialyxir-v1-${{ hashFiles('**/mix.lock') }}
125146
- name: Credo
126147
run: mix credo --strict
127148
working-directory: .
@@ -131,26 +152,26 @@ jobs:
131152
audit:
132153
name: Audit
133154
needs: build_dev
134-
runs-on: ubuntu-20.04
155+
runs-on: ubuntu-latest
135156
env:
136157
MIX_ENV: dev
137158
steps:
138-
- uses: actions/checkout@v2
159+
- uses: actions/checkout@v4
139160
- name: Set up Elixir
140161
uses: erlef/setup-beam@v1
141162
with:
142-
elixir-version: ${{ env.ELIXIR_VERSION }}
143-
otp-version: ${{ env.OTP_VERSION }}
163+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
164+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
144165
- name: Cache deps
145-
uses: actions/cache@v2
166+
uses: actions/cache@v4
146167
with:
147168
path: deps
148-
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
169+
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock') }}
149170
- name: Cache _build
150-
uses: actions/cache@v2
171+
uses: actions/cache@v4
151172
with:
152173
path: _build
153-
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
174+
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock') }}
154175
- name: Check Elixir formatting
155176
run: mix format --check-formatted
156177
working-directory: .
@@ -167,24 +188,24 @@ jobs:
167188
- test
168189
- credo_and_dialyxir
169190
- audit
170-
runs-on: ubuntu-20.04
191+
runs-on: ubuntu-latest
171192
steps:
172-
- uses: actions/checkout@v2
193+
- uses: actions/checkout@v4
173194
- name: Set up Elixir
174195
uses: erlef/setup-beam@v1
175196
with:
176-
elixir-version: ${{ env.ELIXIR_VERSION }}
177-
otp-version: ${{ env.OTP_VERSION }}
197+
elixir-version: ${{ env.PRIMARY_ELIXIR_VERSION }}
198+
otp-version: ${{ env.PRIMARY_OTP_VERSION }}
178199
- name: Cache deps
179-
uses: actions/cache@v2
200+
uses: actions/cache@v4
180201
with:
181202
path: deps
182-
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
203+
key: ${{ runner.os }}-dev-deps-v1-${{ hashFiles('**/mix.lock') }}
183204
- name: Cache _build
184-
uses: actions/cache@v2
205+
uses: actions/cache@v4
185206
with:
186207
path: _build
187-
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock', '.tool-versions') }}
208+
key: ${{ runner.os }}-dev-build-v1-${{ hashFiles('**/mix.lock') }}
188209
- name: Publish to Hex
189210
uses: synchronal/hex-publish-action@v1
190211
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)