ci: Surface lint and test results to comment

It's a bit annoying how you have to go to the workflow result to see the lint error and test results. This surfaces it to the comment in the PR.
This commit is contained in:
Nick Bolton 2025-08-06 12:16:16 +01:00
parent d7f882f0c4
commit cf1789545a
2 changed files with 24 additions and 7 deletions

View file

@ -65,8 +65,15 @@ runs:
) )
echo "$summary" >> $GITHUB_STEP_SUMMARY echo "$summary" >> $GITHUB_STEP_SUMMARY
file="ci_summary.md" pr_comment=$(cat <<EOF
echo "❌🛠️ \`clang-format\`: Lint errors, fix available." >> $file ### Lint result
$summary
EOF
)
file="ci-summary.md"
echo "$pr_comment" | tee $file
echo "file=$file" >> $GITHUB_OUTPUT echo "file=$file" >> $GITHUB_OUTPUT
shell: bash shell: bash

View file

@ -57,15 +57,25 @@ runs:
if [ -z "$table" ]; then if [ -z "$table" ]; then
echo "No test results found" | tee $GITHUB_STEP_SUMMARY >&2 echo "No test results found" | tee $GITHUB_STEP_SUMMARY >&2
exit 1 exit 1
else
echo "$table" > $GITHUB_STEP_SUMMARY
fi fi
count=$(echo "$table" | awk -v RS='' '{gsub(/[^❌]/, ""); print length}') echo "$table" > $GITHUB_STEP_SUMMARY
file="ci-summary.md"
count=$(echo "$table" | awk -v RS='' '{gsub(/[^❌]/, ""); print length}')
# Keep at this indentation level for heredoc.
fail_summary=$(cat <<EOF
### Test result
❌🔬 Tests failed: $count
$table
EOF
)
file="ci-summary.md"
if [ $count -gt 0 ]; then if [ $count -gt 0 ]; then
echo "❌🔬 Tests failed: $count" | tee $file echo "$fail_summary" | tee $file
echo "file=$file" >> $GITHUB_OUTPUT echo "file=$file" >> $GITHUB_OUTPUT
else else
# For debugging; don't send success to CI summary (reduce noise). # For debugging; don't send success to CI summary (reduce noise).