|
1 | 1 | name: CI |
2 | 2 | on: |
3 | 3 | push: |
4 | | - branches: [main, master] |
| 4 | + branches: [main] |
5 | 5 | 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: |
11 | 8 | jobs: |
12 | 9 | test: |
13 | | - name: Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }}) |
| 10 | + name: Test on Elixir (via Nix) |
14 | 11 | 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' |
32 | 12 | steps: |
33 | 13 | - name: Checkout code |
34 | 14 | 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 |
37 | 17 | 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 |
41 | 22 | uses: actions/cache@v4 |
42 | 23 | with: |
43 | 24 | 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') }} |
47 | 28 | 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 |
67 | 31 | uses: actions/cache@v4 |
68 | 32 | with: |
69 | 33 | path: | |
70 | 34 | deps |
71 | 35 | _build |
72 | | - key: ${{ runner.os }}-mix-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }} |
| 36 | + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} |
73 | 37 | 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 |
86 | 49 | - name: Run Dialyzer |
87 | | - run: mix dialyzer |
| 50 | + run: nix develop -c mix dialyzer |
0 commit comments