-
Notifications
You must be signed in to change notification settings - Fork 12
/
ci.sh
executable file
·57 lines (52 loc) · 1.14 KB
/
ci.sh
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
#!/usr/bin/env bash
set -euo pipefail
args=(
"$@"
--accept-flake-config
--gc-roots-dir gc-root
--max-memory-size "12000"
--option allow-import-from-derivation false
--show-trace
--workers 4
./ci.nix
)
if [[ -n "${GITHUB_STEP_SUMMARY-}" ]]; then
log() {
echo "$*" >> "$GITHUB_STEP_SUMMARY"
}
else
log() {
echo "$*"
}
fi
error=0
for job in $(nix-eval-jobs "${args[@]}" | jq -r '. | @base64'); do
job=$(echo "$job" | base64 -d)
attr=$(echo "$job" | jq -r .attr)
echo "### $attr"
error=$(echo "$job" | jq -r .error)
if [[ $error != null ]]; then
log "### ❌ $attr"
log
log "<details><summary>Eval error:</summary><pre>"
log "$error"
log "</pre></details>"
error=1
else
drvPath=$(echo "$job" | jq -r .drvPath)
if ! nix-store --realize "$drvPath" 2>&1 | tee build-log.txt; then
log "### ❌ $attr"
log
log "<details><summary>Build error:</summary>last 50 lines:<pre>"
log "$(tail -n 50 build-log.txt)"
log "</pre></details>"
error=1
else
log "### ✅ $attr"
fi
log
rm build-log.txt
fi
done
# TODO: improve the reporting
# exit "$error"