-
Notifications
You must be signed in to change notification settings - Fork 3
122 lines (107 loc) · 3.75 KB
/
Copy pathci.yml
File metadata and controls
122 lines (107 loc) · 3.75 KB
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
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.
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Sets the ENV `MIX_ENV` to `test` for running tests
env:
MIX_ENV: test
permissions:
contents: read
jobs:
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:
# minimum required versions
- otp: "27.2.4"
elixir: "1.17.3-otp-27"
- otp: "27.2.4"
elixir: "1.18.4-otp-27"
- otp: "28.3.1"
elixir: "1.18.4-otp-28"
- otp: "27.2.4"
elixir: "1.19.5-otp-27"
- otp: "28.3.1"
elixir: "1.19.5-otp-28"
- otp: "28.3.1"
elixir: "1.20.2-otp-28"
- otp: "29.0.1"
elixir: "1.20.2-otp-29"
lint: true
steps:
# 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}}
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v5
# Step: Define how to cache deps. Restores existing cache if present.
# Cache keys include the OTP and Elixir versions so matrix entries
# never share BEAMs compiled by a different toolchain.
- name: Cache deps
id: cache-deps
uses: actions/cache@v4
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-mix-deps-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-mix-deps-
# 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@v4
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-mix-build-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-mix-build-
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install dependencies
run: mix deps.get
# Step: Compile the project treating any warnings as errors.
- name: Compiles without warnings
run: mix compile --warnings-as-errors
# Step: Download the segmentation dictionaries the tests rely on.
- name: Download dictionaries
run: mix unicode.string.download.dictionaries
# Step: Check that the checked in code has already been formatted.
- name: Check Formatting
if: ${{ matrix.lint }}
run: mix format --check-formatted
# Step: Static code analysis.
- name: Run credo
if: ${{ matrix.lint }}
run: mix credo --strict
# Step: Execute the tests.
- name: Run tests
if: ${{ !matrix.lint }}
run: mix test
# Step: Execute the tests with coverage measurement on the lint entry.
- name: Run tests with coverage
if: ${{ matrix.lint }}
run: mix test --cover
# Step: Execute dialyzer. Runs on the lint entry only; a single
# analysis per change is sufficient and avoids rebuilding a PLT for
# every toolchain in the matrix.
- name: Run dialyzer
if: ${{ matrix.lint }}
run: mix dialyzer