Skip to content

Commit

Permalink
Merge pull request tweag#487 from tweag/add-job-summary
Browse files Browse the repository at this point in the history
CI: Add job summary
  • Loading branch information
mergify[bot] authored Mar 19, 2024
2 parents a2a3203 + 3248108 commit 809c4e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/build-and-test
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,36 @@ run_command() {
echo '::endgroup::'
}

write_summary() {
if [ -v GITHUB_STEP_SUMMARY ]; then
echo "$@" >> "$GITHUB_STEP_SUMMARY"
fi
}

for dir in "${build_dirs[@]}"; do
# bazel test //... fails in modules that don't define any test targets, use
# bazel build in those instead. Workaround for
# https://github.com/bazelbuild/bazel/issues/7291#issuecomment-1283970438
run_command build $dir
done

write_summary '### Test results'
write_summary '| Test | Result | Elapsed Time |'
write_summary '| ---- | :----: | -----------: |'

declare start elapsed failed
for dir in "${test_dirs[@]}"; do
start=$EPOCHSECONDS
failed=${#FAILURES[@]}
run_command test $dir
elapsed=$(( EPOCHSECONDS - start ))
if [[ "$failed" < "${#FAILURES[@]}" ]]; then
write_summary "| $dir | Fail :red_circle: | $( TZ=UTC0 printf '%(%H:%M:%S)T' $elapsed ) |"
else
write_summary "| $dir | Pass :white_check_mark: | $( TZ=UTC0 printf '%(%H:%M:%S)T' $elapsed ) |"
fi
done

# Local Variables:
# mode: sh
# End:
1 change: 1 addition & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
fi
nix-shell --pure \
--keep GITHUB_STEP_SUMMARY \
--keep GITHUB_REPOSITORY \
--keep BZLMOD_ENABLED \
--keep BAZEL_NIX_REMOTE \
Expand Down

0 comments on commit 809c4e0

Please sign in to comment.