Skip to content

Commit 87bbb95

Browse files
committed
[ci] Display TODO errors in GitHub PR UI
gherrit-pr-id: I2d944fc641d1b3d122cf39ac5410718ecbce699c
1 parent 146e382 commit 87bbb95

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

ci/check_todo.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ set -euo pipefail
1616
# would mean that we couldn't use XODO comments in this script.
1717
KEYWORD=$(echo XODO | sed -e 's/X/T/')
1818

19+
# TODO
20+
1921
# Make sure `rg` is installed (if this fails, `set -e` above will cause the
2022
# script to exit).
2123
rg --version >/dev/null
@@ -29,6 +31,26 @@ if [ -n "$output" ]; then
2931
echo "Found $KEYWORD markers in the codebase." >&2
3032
echo "$KEYWORD is used for tasks that should be done before merging a PR; if you want to leave a message in the codebase, use FIXME." >&2
3133
echo "" >&2
32-
echo "$output" >&2
34+
if [ "${GITHUB_ACTIONS:-false}" == "true" ]; then
35+
echo "$output" | while IFS= read -r output; do
36+
# Parse format `file:line: message`
37+
file=$(echo "$output" | cut -d : -f 1)
38+
line=$(echo "$output" | cut -d : -f 2)
39+
message=$(echo "$output" | cut -d : -f 3-)
40+
41+
# Escape message for workflow command: % -> %25, \r -> %0D, \n -> %0A
42+
message="${message//'%'/'%25'}"
43+
message="${message//$'\r'/'%0D'}"
44+
message="${message//$'\n'/'%0A'}"
45+
46+
# Output the workflow command for GitHub Actions annotations. Use `::notice`
47+
# rather than `::error` so that the output is less visually distracting (the
48+
# `exit 1` below will still ensure that this causes CI to fail).
49+
echo "::notice file=${file},line=${line},endLine=${line},title=$KEYWORD Found::${message}"
50+
done
51+
else
52+
echo "$output" >&2
53+
fi
54+
3355
exit 1
3456
fi

0 commit comments

Comments
 (0)