-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (119 loc) · 4.69 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Test
on:
push:
# ignore branches where the release workflow runs as it already calls this one
branches-ignore:
- main
- dev
pull_request:
workflow_call:
permissions:
contents: read
jobs:
# ignore the push event trigger if a PR is open for the current branch
prevent_duplicate_checks:
runs-on: ubuntu-latest
steps:
- uses: insurgent-lab/is-in-pr-action@3e01b38aa0d2a0e51bbc84540300303ec850e80d # v0.1.5
id: isInPR
outputs:
should-run: ${{ !(steps.isInPR.outputs.result == 'true' && github.event_name == 'push') }}
test_matrix:
name: Test (Elixir ${{matrix.elixir}} | OTP ${{matrix.otp}})
runs-on: ${{ matrix.os }}
timeout-minutes: 10
needs: prevent_duplicate_checks
if: ${{ needs.prevent_duplicate_checks.outputs.should-run == 'true' }}
strategy:
fail-fast: false
matrix:
include:
- elixir: 1.12.x
otp: 22
os: ubuntu-20.04
- elixir: 1.13.x
otp: 23
os: ubuntu-20.04
- elixir: 1.14.x
otp: 24
os: ubuntu-22.04
- elixir: 1.15.x
otp: 25
os: ubuntu-22.04
- elixir: 1.16.x
otp: 26
os: ubuntu-latest
env:
MIX_ENV: test
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up BEAM
id: setup-beam
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Restore dependencies cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: deps
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
restore-keys: |
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}
path: |
deps
_build
- name: Install dependencies
run: |
mix local.hex --force
mix do deps.get, deps.compile
- name: Check formatting
run: mix format --check-formatted
- name: Compile code (without warning)
run: mix compile --warnings-as-errors
- name: Run tests
run: mix test
# Dialyzer
- name: Restore PLTs cache
id: restore_plts_cache
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: plts
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
restore-keys: |
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}
path: priv/plts
- name: Create PLTs
if: steps.restore_plts_cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts/core.plt
mix dialyzer --plt
- name: Save PLTs cache
uses: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: plts
if: steps.restore_plts_cache.outputs.cache-hit != 'true'
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
path: priv/plts
- name: Run dialyzer
run: mix dialyzer --format github
# separate job to set as required status check in branch protection
required_check:
runs-on: ubuntu-latest
needs:
- prevent_duplicate_checks
- test_matrix
if: ${{ !cancelled() && needs.prevent_duplicate_checks.outputs.should-run == 'true' }}
steps:
- name: All required jobs and matrix versions passed
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Some required jobs or matrix versions failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1