-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (79 loc) · 3.01 KB
/
elixir.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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Elixir CI
env:
MIX_ENV: test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
actions: write
contents: read
jobs:
dupe_check:
name: check for duplicate tasks
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths_ignore: '["**.md", "docs/**"]'
cancel_others: true
run_checks:
name: Run checks
runs-on: ubuntu-latest
needs: dupe_check
if: needs.dupe_check.outputs.should_skip != 'true'
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: Restore dependencies cache
id: deps-cache
uses: actions/cache@v4
with:
path: |
deps
_build
priv/plts
.nix-mix
.nix-hex
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/flake.*')) }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.*')) }}
restore-keys: |
${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/flake.*')) }}
${{ runner.os }}-mix-
- name: Build dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
# nix flake check # BUG: https://github.com/cachix/git-hooks.nix/issues/466
mkdir -p priv/plts
nix develop -c mix local.hex --force
nix develop -c mix deps.get
nix develop -c mix dialyzer --plt
nix develop -c mix compile
- name: Run pre-commit checks
run: |
nix develop -c pre-commit run --show-diff-on-failure --hook-stage=pre-merge-commit --color=always --all-files
# # NOTE: the above runs on all files regardless of if they changed. What would be better would be checking only the files in a P.R. that changed.
# # However, my attempt below to do so raises an error saying "unknown revision or path 'main..dev'" and I don't know how to fix it.
# - name: Run pre-commit checks
# env:
# HEAD_REF: ${{ github.head_ref }}
# BASE_REF: ${{ github.base_ref }}
# run: |
# if [[ -n "$HEAD_REF" && -n "$BASE_REF" ]]; then
# git fetch --depth=1 origin "$BASE_REF"
# git fetch --depth=1 origin "$HEAD_REF"
# nix develop -c pre-commit run --show-diff-on-failure --color=always --to-ref "$BASE_REF" --from-ref "$HEAD_REF"
# else
# nix develop -c pre-commit run --show-diff-on-failure --hook-stage=pre-merge-commit --color=always --all-files
# fi