Skip to content

Commit 747b7c4

Browse files
authored
feat: surface evaluation warnings in CI (#457)
Capture stderr from `nix eval` during the CI eval job and emit GitHub Actions warning annotations when evaluation warnings are detected. The step also fails so the `build` job is blocked, making warnings impossible to miss on PRs. Closes #274 ## What changed - Refactored the eval loop into an `eval_host` function - Stderr is captured separately from stdout - Any `evaluation warning:` in stderr triggers a `::warning::` annotation (visible in the PR checks summary) and fails the step - Multi-line warnings are encoded with `%0A` so the full text appears in the annotation - All hosts are checked before exiting, so all warnings are reported in a single run ## Verify Check that a config with an evaluation warning causes the eval job to fail and shows the warning text as an annotation on the PR.
1 parent e3b99ed commit 747b7c4

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@ jobs:
1515
github_access_token: ${{ secrets.GITHUB_TOKEN }}
1616
- name: Check all configurations evaluate
1717
run: |
18-
for host in glyph spore zeta; do
18+
eval_host() {
19+
local host="$1"
20+
local expr="$2"
1921
echo "Evaluating $host..."
20-
nix eval .#nixosConfigurations.$host.config.system.build.toplevel.drvPath
22+
stderr=$(nix eval "$expr" 2>&1 >/dev/null)
23+
if [ -n "$stderr" ]; then
24+
echo "$stderr"
25+
if echo "$stderr" | grep -q "evaluation warning:"; then
26+
encoded=$(printf '%s' "$stderr" | python3 -c "import sys; print(sys.stdin.read().replace('%','%25').replace('\n','%0A').replace('\r','%0D'))")
27+
echo "::warning title=Evaluation warnings ($host)::${encoded}"
28+
fi
29+
fi
30+
}
31+
for host in glyph spore zeta; do
32+
eval_host "$host" ".#nixosConfigurations.$host.config.system.build.toplevel.drvPath"
2133
done
22-
echo "Evaluating Rhizome..."
23-
nix eval .#darwinConfigurations.Rhizome.system.drvPath
34+
eval_host "Rhizome" ".#darwinConfigurations.Rhizome.system.drvPath"
2435
2536
build:
2637
needs: eval

0 commit comments

Comments
 (0)