-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (110 loc) · 3.77 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
name: Test and build
on:
push:
branches: ["main"]
jobs:
test:
name: "Run tests"
runs-on: ubuntu-latest
env:
MIX_ENV: test
steps:
- uses: actions/[email protected]
- name: Read .tool-versions
uses: marocchino/[email protected]
id: versions
- name: Set up Elixir ${{steps.versions.outputs.elixir}}
uses: erlef/setup-beam@v1
with:
elixir-version: ${{steps.versions.outputs.elixir}}
otp-version: ${{steps.versions.outputs.erlang}}
- name: Restore dependencies cache
uses: actions/[email protected]
with:
path: |
deps
_build
key: ${{ runner.os }}-mixv2-${{ hashFiles('**/mix.lock', 'config/*.exs') }}
restore-keys: ${{ runner.os }}-mixv2-
- name: Setup deps
run: |
mix deps.get
mix deps.unlock --check-unused
- name: Compile
run: mix compile --warnings-as-errors
- name: Check formatter
run: mix format --check-formatted
- name: Run tests
run: mix test --warnings-as-errors
- name: Cleanup
run: mix clean
dialyzer:
name: "Run Dialyzer"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Read .tool-versions
uses: marocchino/[email protected]
id: versions
- name: Set up Elixir ${{steps.versions.outputs.elixir}}
uses: erlef/setup-beam@v1
with:
elixir-version: ${{steps.versions.outputs.elixir}}
otp-version: ${{steps.versions.outputs.erlang}}
# 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
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Step: Define how to cache the `_build` directory. After the first run,
# this speeds up tests runs a lot. This includes not re-compiling our
# project's downloaded deps every run.
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
- name: Restore PLT cache
id: plt_cache
uses: actions/cache/restore@v3
with:
key: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-
path: |
priv/plts
- name: Setup deps
run: |
mix deps.get
mix deps.unlock --check-unused
- name: Compile
run: mix compile --warnings-as-errors
- name: Create PLTs
if: steps.plt_cache.outputs.cache-hit != 'true'
run: mix dialyzer --plt
- name: Save PLT cache
id: plt_cache_save
uses: actions/cache/save@v3
if: steps.plt_cache.outputs.cache-hit != 'true'
with:
key: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
path: |
priv/plts
- name: Run dialyzer
run: mix dialyzer --format github
- name: Cleanup
run: mix clean