Skip to content

Commit 5383ce2

Browse files
committed
chore: use nix for CI test
1 parent 63fdd22 commit 5383ce2

1 file changed

Lines changed: 28 additions & 65 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,50 @@
11
name: CI
22
on:
33
push:
4-
branches: [main, master]
4+
branches: [main]
55
pull_request:
6-
branches: [main, master]
7-
env:
8-
MIX_ENV: test
9-
ELIXIR_VERSION: '1.18'
10-
OTP_VERSION: '27.2'
6+
branches: [main]
7+
workflow_dispatch:
118
jobs:
129
test:
13-
name: Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }})
10+
name: Test on Elixir (via Nix)
1411
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
elixir: ['1.14', '1.15', '1.16', '1.17', '1.18']
18-
otp: ['25.0', '26.0', '27.0']
19-
exclude:
20-
# OTP 25 is not compatible with Elixir 1.17+
21-
- elixir: '1.17'
22-
otp: '25.0'
23-
- elixir: '1.18'
24-
otp: '25.0'
25-
# OTP 27 requires Elixir 1.17+
26-
- elixir: '1.14'
27-
otp: '27.0'
28-
- elixir: '1.15'
29-
otp: '27.0'
30-
- elixir: '1.16'
31-
otp: '27.0'
3212
steps:
3313
- name: Checkout code
3414
uses: actions/checkout@v4
35-
- name: Set up Elixir
36-
uses: erlef/setup-beam@v1
15+
- name: Install Nix
16+
uses: cachix/install-nix-action@v27
3717
with:
38-
elixir-version: ${{ matrix.elixir }}
39-
otp-version: ${{ matrix.otp }}
40-
- name: Restore dependencies cache
18+
nix_path: nixpkgs=channel:nixos-unstable
19+
extra_nix_config: |
20+
experimental-features = nix-command flakes
21+
- name: Cache Nix store
4122
uses: actions/cache@v4
4223
with:
4324
path: |
44-
deps
45-
_build
46-
key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
25+
~/.cache/nix
26+
/nix/store
27+
key: ${{ runner.os }}-nix-${{ hashFiles('flake.nix', 'flake.lock') }}
4728
restore-keys: |
48-
${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-
49-
- name: Install dependencies
50-
run: mix deps.get
51-
- name: Run tests
52-
run: mix test
53-
- name: Run Credo
54-
run: mix credo --strict
55-
dialyzer:
56-
name: Dialyzer
57-
runs-on: ubuntu-latest
58-
steps:
59-
- name: Checkout code
60-
uses: actions/checkout@v4
61-
- name: Set up Elixir
62-
uses: erlef/setup-beam@v1
63-
with:
64-
elixir-version: ${{ env.ELIXIR_VERSION }}
65-
otp-version: ${{ env.OTP_VERSION }}
66-
- name: Restore dependencies cache
29+
${{ runner.os }}-nix-
30+
- name: Cache Mix dependencies
6731
uses: actions/cache@v4
6832
with:
6933
path: |
7034
deps
7135
_build
72-
key: ${{ runner.os }}-mix-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }}
36+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
7337
restore-keys: |
74-
${{ runner.os }}-mix-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-
75-
- name: Restore PLT cache
76-
uses: actions/cache@v4
77-
with:
78-
path: priv/plts
79-
key: ${{ runner.os }}-plt-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }}
80-
restore-keys: |
81-
${{ runner.os }}-plt-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-
82-
- name: Install dependencies
83-
run: mix deps.get
84-
- name: Check formatting
85-
run: mix format --check-formatted
38+
${{ runner.os }}-mix-
39+
- name: Install Mix dependencies
40+
run: nix develop -c mix deps.get
41+
- name: Compile project
42+
run: nix develop -c mix compile --warnings-as-errors
43+
- name: Run tests
44+
run: nix develop -c mix test
45+
- name: Check code formatting
46+
run: nix develop -c mix format --check-formatted
47+
- name: Run Credo
48+
run: nix develop -c mix credo
8649
- name: Run Dialyzer
87-
run: mix dialyzer
50+
run: nix develop -c mix dialyzer

0 commit comments

Comments
 (0)