From 3ec3fb9416a936b0e37468663e4e6ca34fe0d7c6 Mon Sep 17 00:00:00 2001 From: Moritz 'e1mo' Fromm Date: Sat, 5 Aug 2023 13:49:10 +0200 Subject: [PATCH] Add error handling to ci build job --- .github/workflows/build-systems.yaml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-systems.yaml b/.github/workflows/build-systems.yaml index ff7f63d..9ba73a1 100644 --- a/.github/workflows/build-systems.yaml +++ b/.github/workflows/build-systems.yaml @@ -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::" - out_path=$($build_cmd --print-out-paths) - echo -e "\x1b[32;1mSuccessfully built .#nixosConfigurations.${host}\x1b[0m" - echo "| ${host} | \`${out_path}\` |" >> $GITHUB_STEP_SUMMARY + 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" + 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() }}