Skip to content

Commit

Permalink
Add job summary
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv committed Nov 27, 2023
1 parent 3a98972 commit ecd698f
Showing 1 changed file with 23 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 | Pass :red_circle: | $( TZ=UTC0 printf '%(%H:%M:%S)T' $elapsed ) |"
else
write_summary "| $dir | Fail :white_check_mark: | $( TZ=UTC0 printf '%(%H:%M:%S)T' $elapsed ) |"
fi
done

# Local Variables:
# mode: sh
# End:

0 comments on commit ecd698f

Please sign in to comment.