@@ -16,6 +16,10 @@ set -euo pipefail
16
16
# would mean that we couldn't use XODO comments in this script.
17
17
KEYWORD=$( echo XODO | sed -e ' s/X/T/' )
18
18
19
+ # Make sure `rg` is installed (if this fails, `set -e` above will cause the
20
+ # script to exit).
21
+ rg --version > /dev/null
22
+
19
23
# -H: Print filename (default for multiple files/recursive)
20
24
# -n: Print line number
21
25
# -w: Match whole words
@@ -25,6 +29,26 @@ if [ -n "$output" ]; then
25
29
echo " Found $KEYWORD markers in the codebase." >&2
26
30
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
27
31
echo " " >&2
28
- echo " $output " >&2
32
+ if [ " ${GITHUB_ACTIONS:- false} " == " true" ]; then
33
+ echo " $output " | while IFS= read -r line; do
34
+ # Parse format `file:line: message`
35
+ file=$( echo " $line " | cut -d : -f 1)
36
+ line=$( echo " $line " | cut -d : -f 2)
37
+ message=$( echo " $line " | cut -d : -f 3-)
38
+
39
+ # Escape message for workflow command: % -> %25, \r -> %0D, \n -> %0A
40
+ message=" ${message// ' %' / ' %25' } "
41
+ message=" ${message// $' \r ' / ' %0D' } "
42
+ message=" ${message// $' \n ' / ' %0A' } "
43
+
44
+ # Output the workflow command for GitHub Actions annotations. Use `::notice`
45
+ # rather than `::error` so that the output is less visually distracting (the
46
+ # `exit 1` below will still ensure that this causes CI to fail).
47
+ echo " ::notice file=${file} ,line=${line} ,endLine=${line} ,title=$KEYWORD Found::${message} "
48
+ done
49
+ else
50
+ echo " $output " >&2
51
+ fi
52
+
29
53
exit 1
30
54
fi
0 commit comments