-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (62 loc) · 2.1 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
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
extract_versions:
name: Extract info from .tool-versions
runs-on: ubuntu-latest
outputs:
elixir-version: ${{ steps.set-versions.outputs.elixir_version }}
otp-version: ${{ steps.set-versions.outputs.otp_version }}
steps:
- name: Checkout .tool-versions file
uses: actions/checkout@v4
with:
sparse-checkout: |
.tool-versions
sparse-checkout-cone-mode: false
- name: Set Elixir, OTP, and Node.js versions as output
id: set-versions
run: |
elixir_version=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')
otp_version=$(grep -h erlang .tool-versions | awk '{ print $2 }')
echo "elixir_version=$elixir_version" >> $GITHUB_OUTPUT
echo "otp_version=$otp_version" >> $GITHUB_OUTPUT
test:
name: Test on OTP ${{ matrix.otp }} / Elixir ${{ matrix.elixir }}
runs-on: ubuntu-latest
needs: extract_versions
env:
otp-version: ${{ needs.extract_versions.outputs.otp-version }}
elixir-version: ${{ needs.extract_versions.outputs.elixir-version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.otp-version }}
elixir-version: ${{ env.elixir-version }}
- name: Cache deps
id: cache-deps
uses: actions/cache@v4
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 }}-
- name: Fetch dependencies
run: mix deps.get
- name: Check formatting
run: mix format --check-formatted
- name: Check for unused dependencies
run: mix deps.get && mix deps.unlock --check-unused
- name: Compile
run: mix compile --warnings-as-errors
- name: Test
run: mix test