@@ -4,9 +4,6 @@ name: Checks
4
4
# Sets the ENV `MIX_ENV` to `test` for running tests
5
5
env :
6
6
MIX_ENV : test
7
- # Artificially refresh the cache
8
- DEPENDENCIES_CACHE_VERSION : 1
9
- PLT_CACHE_VERSION : 1
10
7
11
8
permissions :
12
9
contents : read
59
56
cache-name : cache-elixir-deps
60
57
with :
61
58
path : deps
62
- key : ${{ runner.os }}-mix-${{ env.cache-name }-${{ env.DEPENDENCIES_CACHE_VERSION }}}-${{ hashFiles('**/mix.lock') }}
63
- restore-keys : |
64
- ${{ runner.os }}-mix-${{ env.cache-name }}-${{ env.DEPENDENCIES_CACHE_VERSION }}-
65
-
66
- # Step: Define how to cache the `_build` directory. After the first run,
67
- # this speeds up tests runs a lot. This includes not re-compiling our
68
- # project's downloaded deps every run.
69
- - name : Cache compiled build
70
- id : cache-build
71
- uses : actions/cache@v3
72
- env :
73
- cache-name : cache-compiled-build
74
- with :
75
- path : _build
76
- key : ${{ runner.os }}-mix-${{ env.cache-name }}-${{ env.DEPENDENCIES_CACHE_VERSION }}-${{ hashFiles('**/mix.lock') }}
77
- restore-keys : |
78
- ${{ runner.os }}-mix-${{ env.cache-name }}-${{ env.DEPENDENCIES_CACHE_VERSION }}-
79
- ${{ runner.os }}-mix-
80
-
81
- # Step: Conditionally bust the cache when job is re-run. Sometimes, we
82
- # may have issues with incremental builds that are fixed by doing a full
83
- # recompile. In order to not waste dev time on such trivial issues (while
84
- # also reaping the time savings of incremental builds for *most*
85
- # day-to-day development), force a full recompile only on builds that are
86
- # retried.
87
- - name : Clean to rule out incremental build as a source of flakiness
88
- if : github.run_attempt != '1'
89
- run : |
90
- mix deps.clean --all
91
- mix clean
92
- shell : sh
93
-
94
- # Step: Download project dependencies. If unchanged, uses the cached
95
- # version.
96
- - name : Install dependencies
97
- run : mix deps.get
98
-
99
- # Step: Compile the project treating any warnings as errors.
100
- - name : Compiles without warnings
101
- run : mix compile --warnings-as-errors
102
-
103
- # Step: Setup the database for the tests.
104
- - name : Setup db
105
- run : mix ecto.setup
106
-
107
- # Step: Execute the tests.
108
- - name : Run tests
109
- run : mix test
110
-
111
- ensure_code_consistency :
112
- runs-on : ubuntu-latest
113
- name : Test on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
114
- steps :
115
- # Step: Setup Elixir + Erlang image as the base.
116
- - name : Set up Elixir
117
- uses : erlef/setup-beam@v1
118
- with :
119
- otp-version : ${{matrix.otp}}
120
- elixir-version : ${{matrix.elixir}}
121
-
122
- # Step: Check out the code.
123
- - name : Checkout code
124
- uses : actions/checkout@v3
125
-
126
- # Step: Define how to cache deps. Restores existing cache if present.
127
- - name : Cache deps
128
- id : cache-deps
129
- uses : actions/cache@v3
130
- env :
131
- cache-name : cache-elixir-deps
132
- with :
133
- path : deps
134
- key : ${{ runner.os }}-mix-${{ env.cache-name }}-${{ env.DEPENDENCIES_CACHE_VERSION }}-${{ hashFiles('**/mix.lock') }}
59
+ key : ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
135
60
restore-keys : |
136
- ${{ runner.os }}-mix-${{ env.cache-name }}-${{ env.DEPENDENCIES_CACHE_VERSION }}-
61
+ ${{ runner.os }}-mix-${{ env.cache-name }}-
137
62
138
63
# Step: Define how to cache the `_build` directory. After the first run,
139
64
# this speeds up tests runs a lot. This includes not re-compiling our
161
86
run : |
162
87
mix deps.clean --all
163
88
mix clean
164
- shell : s
89
+ shell : sh
165
90
166
91
# Step: Download project dependencies. If unchanged, uses the cached
167
92
# version.
@@ -172,47 +97,18 @@ jobs:
172
97
- name : Compiles without warnings
173
98
run : mix compile --warnings-as-errors
174
99
175
- # Step: Check that the code has already been formatted.
100
+ # Step: Check that the checked in code has already been formatted.
176
101
- name : Check Formatting
177
102
run : mix format --check-formatted
178
103
179
- # Step: Check that the code complies with the credo rules.
104
+ # Step: Check that the checked in code complies with the credo rules.
180
105
- name : Check Credo
181
106
run : mix credo -A
182
107
183
- # Step: Check that the documentation and specs complies with the doctor rules.
184
- - name : Check Doctor
185
- run : mix doctor
186
-
187
- # Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
188
- # Cache key based on Elixir & Erlang version (also useful when running in matrix)
189
- - name : Restore PLT cache
190
- uses : actions/cache/restore@v4
191
- id : plt_cache
192
- with :
193
- key : |
194
- plt-${{ runner.os }}-${{ env.PLT_CACHE_VERSION }}
195
- restore-keys : |
196
- plt-${{ runner.os }}-${{ env.PLT_CACHE_VERSION }}
197
- path : |
198
- priv/plts
199
-
200
- # Create PLTs if no cache was found
201
- - name : Create PLTs
202
- if : steps.plt_cache.outputs.cache-hit != 'true'
203
- run : mix dialyzer --plt
204
-
205
- # By default, the GitHub Cache action will only save the cache if all steps in the job succeed,
206
- # so we separate the cache restore and save steps in case running dialyzer fails.
207
- - name : Save PLT cache
208
- uses : actions/cache/save@v4
209
- if : steps.plt_cache.outputs.cache-hit != 'true'
210
- id : plt_cache_save
211
- with :
212
- key : |
213
- plt-${{ runner.os }}-${{ env.PLT_CACHE_VERSION }}
214
- path : |
215
- priv/plts
108
+ # Step: Setup the database for the tests.
109
+ - name : Setup db
110
+ run : mix ecto.setup
216
111
217
- - name : Run dialyzer
218
- run : mix dialyzer --format raw
112
+ # Step: Execute the tests.
113
+ - name : Run tests
114
+ run : mix test
0 commit comments