Add error handling to ci build job
This commit is contained in:
parent
b8f968dc23
commit
3ec3fb9416
1 changed files with 19 additions and 8 deletions
23
.github/workflows/build-systems.yaml
vendored
23
.github/workflows/build-systems.yaml
vendored
|
@ -28,21 +28,32 @@ jobs:
|
|||
- name: Build systems
|
||||
id: build
|
||||
run: |
|
||||
echo "## Builds succeeded" >> $GITHUB_STEP_SUMMARY
|
||||
echo "## Building" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Host | Out path |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| ---- | -------- |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| | Host | Out path |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| --- | ---- | -------- |" >> $GITHUB_STEP_SUMMARY
|
||||
any_failed=false
|
||||
for host in $(nix flake show . --json | jq ".nixosConfigurations|keys[]" -r); do
|
||||
echo "::group::Building ${host}"
|
||||
drv=".#nixosConfigurations.$host.config.system.build.toplevel"
|
||||
build_cmd="nix build ${drv}"
|
||||
#cachix watch-exec chaos-jetzt-nixfiles -- $build_cmd
|
||||
$build_cmd
|
||||
failed=false
|
||||
$build_cmd --show-trace || { failed=true; any_failed=true; }
|
||||
echo "::endgroup::"
|
||||
if ! $failed; then
|
||||
symbol="✅"
|
||||
out_path=$($build_cmd --print-out-paths)
|
||||
out_path="\`${out_path}\`"
|
||||
echo -e "\x1b[32;1mSuccessfully built .#nixosConfigurations.${host}\x1b[0m"
|
||||
echo "| ${host} | \`${out_path}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
symbol="❌"
|
||||
out_path="_build failed_"
|
||||
echo -e "\x1b[31;1mFailed to build .#nixosConfigurations.${host}\x1b[0m"
|
||||
fi
|
||||
echo "| $symbol | ${host} | ${out_path} |" >> $GITHUB_STEP_SUMMARY
|
||||
done
|
||||
# Set return-code to 1 if any failed
|
||||
! $any_failed
|
||||
- name: Diff closures
|
||||
# Still would like to see the changes for the non-failing hosts
|
||||
if: ${{ success() }} || ${{ failure() }}
|
||||
|
|
Loading…
Reference in a new issue