-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (121 loc) · 4.3 KB
/
check.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
name: Check
on: # yamllint disable-line rule:truthy
push:
permissions:
contents: read
jobs:
get-derivations:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8
- id: get-derivations
run: |
nix flake show --json \
github:${{
github.repository
}}/${{
github.event.pull_request.head.sha || github.sha
}} |
jq \
--argjson changed_files "$(
if ${{ github.event_name == 'pull_request' }}; then
git diff --name-only HEAD~1 HEAD
else
git diff --name-only \
${{ github.event.before }} ${{ github.event.after }}
fi |
jq --raw-input --raw-output --slurp 'split("\n")[:-1]'
)" \
--raw-output \
'
def format_output($arch; $type):
{
arch: $arch,
key: .,
os: (
if $arch == "x86_64-linux" then
"ubuntu-24.04"
else
"macos-14"
end
),
type: $type
};
[
["x86_64-linux", "x86_64-darwin"][] as $arch |
(.checks[$arch] | keys) as $checks |
(.packages[$arch] | keys) as $packages |
(($checks - $packages)[] | format_output($arch; "checks")),
($packages[] | format_output($arch; "packages"))
] as $derivations |
# Keep everything when touching critical files.
if (
$changed_files |
any(
. == "flake.lock" or (. | startswith(".github/workflows/"))
)
) then
$derivations
else
$derivations |
map(
select(
if .key == "nix-flake-check" then
($changed_files | any(. == "flake.nix"))
elif .key == "docs" then
($changed_files | any(startswith("docs/")))
elif .key == "palette-generator" then
($changed_files | any(startswith("palette-generator/")))
elif (.key | test("^testbed-[^-]+-")) then
(
.key | capture("^testbed-(?<module>[^-]+)") | .module
) as $module |
(
$changed_files |
any(startswith("modules/\($module)/"))
)
# Always keep the git-hooks derivation.
elif .key == "git-hooks" then
true
else
error(
"Derivation must be handled or explicitly ignored: " +
.key
)
end
)
)
end |
"derivations=\(.)"
' >>$GITHUB_OUTPUT
outputs:
derivations: ${{ steps.get-derivations.outputs.derivations }}
check:
runs-on: ${{ matrix.check.os }}
name: ${{ matrix.check.key }} on ${{ matrix.check.arch }}
needs: get-derivations
strategy:
fail-fast: false
matrix:
check: ${{ fromJSON(needs.get-derivations.outputs.derivations) }}
steps:
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: |
nix build --no-update-lock-file --print-build-logs \
github:${{
github.repository
}}/${{
github.event.pull_request.head.sha || github.sha
}}#${{
matrix.check.type
}}.${{
matrix.check.arch
}}.${{
matrix.check.key
}}