Skip to content

Commit 1f08975

Browse files
committed
Fix Message.authenticate/2 typespec. Update CI
1 parent 4df3729 commit 1f08975

File tree

4 files changed

+88
-34
lines changed

4 files changed

+88
-34
lines changed

.github/workflows/ci.yml

Lines changed: 77 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,87 @@
1+
name: CI
2+
13
on: push
24

3-
jobs:
4-
lint:
5-
runs-on: ubuntu-latest
6-
name: lint OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
7-
strategy:
8-
matrix:
9-
otp: ['26']
10-
elixir: ['1.16']
11-
steps:
12-
- uses: actions/checkout@v2
13-
- uses: erlef/setup-beam@v1
14-
with:
15-
otp-version: ${{matrix.otp}}
16-
elixir-version: ${{matrix.elixir}}
17-
- run: mix deps.get
18-
- run: mix credo
19-
- run: mix dialyzer
20-
- run: mix format --check-formatted
21-
- run: mix docs 2>&1 | (! grep -q "warning:")
5+
env:
6+
MIX_ENV: test
7+
8+
permissions:
9+
contents: read
2210

11+
jobs:
2312
test:
2413
runs-on: ubuntu-latest
25-
name: test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
14+
name: CI on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
2615
strategy:
2716
matrix:
2817
otp: ['26']
2918
elixir: ['1.16']
30-
env:
31-
MIX_ENV: test
3219
steps:
33-
- uses: actions/checkout@v2
34-
- uses: erlef/setup-beam@v1
35-
with:
36-
otp-version: ${{matrix.otp}}
37-
elixir-version: ${{matrix.elixir}}
38-
- run: mix deps.get
39-
- run: mix coveralls.json
40-
- uses: codecov/codecov-action@v3
20+
- name: Set up Elixir
21+
uses: erlef/setup-beam@v1
22+
with:
23+
otp-version: ${{matrix.otp}}
24+
elixir-version: ${{matrix.elixir}}
25+
26+
- name: Checkout the code
27+
uses: actions/checkout@v4
28+
29+
- name: Cache dependencies
30+
uses: actions/cache@v4
31+
with:
32+
path: deps
33+
key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-mix-deps-
36+
37+
- name: Cache compiled build
38+
uses: actions/cache@v4
39+
with:
40+
path: _build
41+
key: ${{ runner.os }}-mix-build-${{ hashFiles('**/mix.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-mix-build-
44+
${{ runner.os }}-mix-
45+
46+
- name: Cache dialyzer artifacts
47+
uses: actions/cache@v4
48+
with:
49+
path: _dialyzer
50+
key: ${{ runner.os }}-dialyzer-${{ hashFiles('**/mix.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-dialyzer-
53+
54+
- name: Install dependencies
55+
run: mix deps.get
56+
57+
- name: Compile without warnings
58+
id: compile
59+
run: mix compile --warnings-as-errors
60+
61+
- name: Check formatting
62+
if: ${{ !cancelled() && steps.compile.outcome == 'success' }}
63+
run: mix format --check-formatted
64+
65+
- name: Check with credo
66+
if: ${{ !cancelled() && steps.compile.outcome == 'success' }}
67+
run: mix credo
68+
69+
- name: Check with dialyzer
70+
if: ${{ !cancelled() && steps.compile.outcome == 'success' }}
71+
run: mix dialyzer
72+
73+
- name: Check docs
74+
if: ${{ !cancelled() && steps.compile.outcome == 'success' }}
75+
run: mix docs 2>&1 | (! grep -q "warning:")
76+
77+
- name: Run tests and check test coverage
78+
if: ${{ !cancelled() && steps.compile.outcome == 'success' }}
79+
id: test
80+
run: mix coveralls.json
81+
82+
- name: Upload test coverage results to Codecov
83+
if: ${{ !cancelled() && steps.test.outcome == 'success' }}
84+
uses: codecov/codecov-action@v4
85+
with:
86+
fail_ci_if_error: true,
87+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ ex_stun-*.tar
2424

2525
# Temporary files, for example, from tests.
2626
/tmp/
27+
28+
# Localy stored dialyzer artifacts
29+
/_dialyzer/

lib/ex_stun/message.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ defmodule ExSTUN.Message do
239239
Depending on the authentication method and its context (client/server side),
240240
user has to perform those checks on their own.
241241
"""
242-
@spec authenticate(t(), binary()) ::
243-
:ok | {:error, :no_message_integrity, :no_matching_message_integrity | atom()}
242+
@spec authenticate(t(), binary()) :: :ok | {:error, atom()}
244243
def authenticate(msg, key) do
245244
case get_message_integrity(msg) do
246245
{:ok, %MessageIntegrity{} = msg_int} ->
@@ -264,8 +263,7 @@ defmodule ExSTUN.Message do
264263
end
265264
end
266265

267-
@spec check_fingerprint(t()) ::
268-
:ok | {:error, :no_fingerprint | :no_matching_fingerprint | atom()}
266+
@spec check_fingerprint(t()) :: :ok | {:error, atom()}
269267
def check_fingerprint(%__MODULE__{} = msg) do
270268
case get_attribute(msg, Fingerprint) do
271269
{:ok, %Fingerprint{} = fingerprint} ->

mix.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ defmodule ExSTUN.MixProject do
1818
docs: docs(),
1919
source_url: @source_url,
2020

21+
# dialyzer
22+
dialyzer: [
23+
plt_local_path: "_dialyzer",
24+
plt_core_path: "_dialyzer"
25+
],
26+
2127
# code coverage
2228
test_coverage: [tool: ExCoveralls],
2329
preferred_cli_env: [

0 commit comments

Comments
 (0)