-
-
Notifications
You must be signed in to change notification settings - Fork 82
207 lines (179 loc) · 6.47 KB
/
elixir.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Elixir CI
# Define workflow that runs when changes are pushed to the
# `main` branch or pushed to a PR branch that targets the `main`
# branch. Change the branch name if your project uses a
# different name for the main branch like "master" or "production".
on:
push:
branches: ["main", "releases/**", "feat/**", "fix/**"] # adapt branch for project
pull_request:
branches: ["main"] # adapt branch for project
# Sets the ENV `MIX_ENV` to `test` for running tests
env:
MIX_ENV: test
# Default elixir and otp are the ones that we validate
# against. Formatting and types can change from version to version,
# so keeping credo, dialyzer and formatting checks in the matrix
# would create an impossible situation, as different versions would have
# different rules
DEFAULT_ELIXIR: 1.14.3-otp-25
DEFAULT_OTP: 25.3.2.4
permissions:
contents: read
jobs:
static_analysis:
runs-on: ubuntu-latest
name: Static analysis
steps:
# Step: Setup Elixir + Erlang image as the base
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.DEFAULT_OTP }}
elixir-version: ${{ env.DEFAULT_ELIXIR }}
version-type: "strict"
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v3
- name: Set Variables
id: set_mix_lock_hash
run: |
mix_lock_hash="${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}"
echo "mix_lock_hash=$mix_lock_hash" >> "$GITHUB_OUTPUT"
# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install and compile dependencies
run: |
mix deps.get
mix deps.compile --skip-umbrella-children
# Step: Check that the checked in code has already been formatted.
# This step fails if something was found unformatted.
# Customize this step as desired.
- name: Check Formatting
run: mix format --check-formatted
# Step: Run credo static code analysis
- name: Credo static analysis
run: mix credo
dialyzer:
runs-on: ubuntu-latest
name: Run Dialyzer
env:
project_mix_lock: ${{ format('{0}{1}', github.workspace, '/mix.lock') }}
projects_ex_blob: ${{ format('{0}{1}', github.workspace, '/projects/**/*.ex') }}
projects_locks_blob: ${{ format('{0}{1}', github.workspace, '/projects/*/mix.lock') }}
steps:
# Step: Setup Elixir + Erlang image as the base.
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.DEFAULT_OTP }}
elixir-version: ${{ env.DEFAULT_ELIXIR }}
version-type: "strict"
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v3
- name: Set Variables
id: set_mix_lock_hash
run: |
mix_lock_hash="${{ hashFiles(env.project_mix_lock) }}"
projects_hash="${{ hashFiles(env.project_ex_blob, env.projects_locks_blob) }}"
echo "mix_lock_hash=$mix_lock_hash::$projects_hash" >> "$GITHUB_OUTPUT"
# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Step: Create dialyzer .plt files if they're not present
- name: Cache dialyzer plt files
id: cache-plt
uses: actions/cache@v3
with:
path: "priv/plts"
key: lexical-plts-${{ env.DEFAULT_OTP }}-${{ env.DEFAULT_ELIXIR }}-${{ steps.set_mix_lock_hash.outputs.mix_lock_hash }}
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install and compile dependencies
run: |
mix deps.get
mix deps.compile --skip-umbrella-children
- name: Compile
run: make compile.all
- name: Maybe create plt files
if: steps.cache-plt.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
make dialyzer.plt.all
- name: Run dialyzer
run: |
mix compile.protocols
make dialyzer.all
test:
runs-on: ubuntu-latest
name: Test on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
# Specify the OTP and Elixir versions to use when building
# and running the workflow steps.
matrix:
include:
- elixir: "1.15.3-otp-25"
otp: "25.3"
- elixir: "1.14.5-otp-25"
otp: "25.3"
- elixir: "1.13.4-otp-25"
otp: "25.3"
steps:
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v3
# Step: Setup Elixir + Erlang image as the base.
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Set Variables
id: set_mix_lock_hash
run: |
mix_lock_hash="${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}"
echo "mix_lock_hash=$mix_lock_hash" >> "$GITHUB_OUTPUT"
# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install and compile the app
run: make compile.all
# Step: Execute the tests.
- name: Run tests
run: make test.all