-
Notifications
You must be signed in to change notification settings - Fork 5
157 lines (141 loc) · 4.74 KB
/
ci.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
---
name: CI
on:
push:
paths:
- '.github/workflows/ci.yml'
- 'lib/**'
- 'mix.*'
- 'priv/**'
- 'test/**'
workflow_dispatch: # enables "click to run" button
env:
ELIXIR_VERSION_ON_WHICH_TO_CHECK_STYLE: '1.15' # Should be highest in matrix
ELIXIR_VERSIONS_ON_WHICH_TO_RUN_DIALYZER: "['1.12', '1.13', '1.14', '1.15']"
jobs:
ci:
name: >
Run CI with Elixir ${{matrix.elixir_vsn}}
runs-on: ${{matrix.os}}
strategy:
matrix:
elixir_vsn: [
'1.0',
'1.1',
'1.2',
'1.3',
'1.4',
'1.5',
'1.6',
'1.7',
'1.8',
'1.9',
'1.10',
'1.11',
'1.12',
'1.13',
'1.14',
'1.15'
]
os: [
'ubuntu-18.04',
'ubuntu-20.04'
]
exclude:
# Older Elixir versions run with OTP versions that require ubuntu 18.04
- elixir_vsn: '1.0'
os: 'ubuntu-20.04'
- elixir_vsn: '1.1'
os: 'ubuntu-20.04'
- elixir_vsn: '1.2'
os: 'ubuntu-20.04'
- elixir_vsn: '1.3'
os: 'ubuntu-20.04'
- elixir_vsn: '1.3'
os: 'ubuntu-20.04'
- elixir_vsn: '1.4'
os: 'ubuntu-20.04'
# More recent ones run with OTP versions that support ubuntu 20.04
- elixir_vsn: '1.5'
os: 'ubuntu-18.04'
- elixir_vsn: '1.6'
os: 'ubuntu-18.04'
- elixir_vsn: '1.7'
os: 'ubuntu-18.04'
- elixir_vsn: '1.8'
os: 'ubuntu-18.04'
- elixir_vsn: '1.9'
os: 'ubuntu-18.04'
- elixir_vsn: '1.10'
os: 'ubuntu-18.04'
- elixir_vsn: '1.11'
os: 'ubuntu-18.04'
- elixir_vsn: '1.12'
os: 'ubuntu-18.04'
- elixir_vsn: '1.13'
os: 'ubuntu-18.04'
- elixir_vsn: '1.14'
os: 'ubuntu-18.04'
- elixir_vsn: '1.15'
os: 'ubuntu-18.04'
steps:
- name: Checkout
uses: actions/checkout@v3
- id: elixir-version-to-otp-version
name: "Read %{Elixir version => OTP version} map"
uses: juliangruber/read-file-action@v1
with:
path: ./.github/workflows/elixir_version_to_otp_version.json
- id: setup-beam
name: Setup BEAM
uses: erlef/setup-beam@v1
with:
# otp-version: https://stackoverflow.com/a/64405821
otp-version: |
${{ fromJson(steps.elixir-version-to-otp-version.outputs.content)[matrix.elixir_vsn] }}
elixir-version: ${{matrix.elixir_vsn}}
env:
GITHUB_TOKEN: ${{github.token}}
- name: Set dynamic env (1)
run: |
echo "PREV_GITHUB_RUN_NR=$((${{github.run_number}} - 1))" >> "$GITHUB_ENV"
echo "BUILD_CACHE_PREFIX=build-cache-for-os-${{runner.os}}-elixir-${{steps.setup-beam.outputs.elixir-version}}-on-otp-${{steps.setup-beam.outputs.otp-version}}" >> "$GITHUB_ENV"
- name: Set dynamic env (2)
run: |
echo "BUILD_CACHE_PREFIX_WITH_HASH=${{env.BUILD_CACHE_PREFIX}}-hash-${{hashFiles('mix.lock')}}" >> "$GITHUB_ENV"
- name: Restore cached build artifacts
uses: actions/cache/restore@v3
with:
path: |
_build
deps
# Since the caching action doesn't support overwrite, we use a
# different key for every run while trying to restore cache using a
# previous run - this allows the cache to not stale.
key: ${{env.BUILD_CACHE_PREFIX_WITH_HASH}}-${{env.PREV_GITHUB_RUN_NR}}
restore-keys: |
${{env.BUILD_CACHE_PREFIX_WITH_HASH}}-
${{env.BUILD_CACHE_PREFIX}}-
- name: Refresh dependencies
run: mix do deps.get, deps.clean --unused
- name: Assert code is formatted
if: ${{matrix.elixir_vsn == env.ELIXIR_VERSION_ON_WHICH_TO_CHECK_STYLE}}
run: mix format --check-formatted
- name: Run Credo
if: ${{matrix.elixir_vsn == env.ELIXIR_VERSION_ON_WHICH_TO_CHECK_STYLE}}
run: mix credo --strict
- name: Run tests
run: mix test --cover
- name: Run Dialyzer
if: ${{contains(fromJson(env.ELIXIR_VERSIONS_ON_WHICH_TO_RUN_DIALYZER), matrix.elixir_vsn)}}
run: MIX_ENV=test mix dialyzer
- name: Save build artifacts to cache
# We always save to cache, even on failure, so that whatever artifacts
# took a long time to generate are kept (looking at you, Dialyzer PLT)
if: always()
uses: actions/cache/save@v3
with:
path: |
_build
deps
key: ${{env.BUILD_CACHE_PREFIX_WITH_HASH}}-${{github.run_number}}