-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (141 loc) · 4.94 KB
/
main.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
on:
push:
branches:
- main
pull_request:
env:
MIX_ENV: test
jobs:
lint:
name: Lint
runs-on: ubuntu-20.04
env:
ELIXIR_VERSION: "1.15"
OTP_VERSION: "26.1"
steps:
- name: Check out this repository
uses: actions/checkout@v4
- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}
- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-
- name: Install dependencies
run: mix deps.get
- name: Check for unused dependencies
run: mix deps.unlock --check-unused
- name: Check for formatted code
run: mix format --check-formatted
dialyzer:
name: Dialyze
runs-on: ubuntu-20.04
env:
ELIXIR_VERSION: "1.15"
OTP_VERSION: "26.1"
steps:
- name: Check out this repository
uses: actions/checkout@v4
- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}
- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old
# ones. Cache key based on Elixir and Erlang version (also useful when running in matrix).
- name: Cache Dialyzer's PLT
uses: actions/cache@v3
id: cache-plt
with:
path: plts
key: |
plt-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
plt-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-
- name: Install dependencies
run: mix deps.get
# Create PLTs if no cache was found
- name: Create PLTs
if: steps.cache-plt.outputs.cache-hit != 'true'
run: |
mkdir -p plts
mix dialyzer --plt
- name: Run Dialyzer
run: mix dialyzer --format github
test:
name: Test (Erlang ${{ matrix.otp }}, Elixir ${{ matrix.elixir }}, Toxiproxy ${{ matrix.toxiproxy }})
runs-on: ubuntu-20.04
strategy:
matrix:
toxiproxy:
- "2.6.0"
- "2.5.0"
- "2.1.2"
elixir:
- "1.15"
otp:
- "26.1"
include:
# Oldest supported version pair.
- otp: "23.3"
elixir: "1.10.4-otp-23"
toxiproxy: "2.1.2"
env:
TOXIPROXY_VERSION: ${{ matrix.toxiproxy }}
steps:
- name: Check out this repository
uses: actions/checkout@v4
- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
version-type: strict
- name: Install Toxiproxy
run: |
curl -v -L --fail https://github.com/Shopify/toxiproxy/releases/download/v${TOXIPROXY_VERSION}/toxiproxy-server-linux-amd64 -o ./toxiproxy-server
chmod +x ./toxiproxy-server
- name: Start Toxiproxy
run: nohup bash -c "./toxiproxy-server > ./toxiproxy.log 2>&1 &"
- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ matrix.elixir }}-otp${{ matrix.otp }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ matrix.elixir }}-otp${{ matrix.otp }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ matrix.elixir }}-otp${{ matrix.otp }}-${{ hashFiles('mix.lock') }}-
- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test
- name: Dump Toxiproxy logs on failure
if: failure()
run: cat ./toxiproxy.log