Skip to content

Commit 6965937

Browse files
committed
Add CI checks against todo comments without issues
1 parent a3eaacf commit 6965937

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

.github/workflows/minimal-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ env:
1212
# Don't use more features like "gdnative_bindings_generator/debug" to keep CI truly minimal
1313
GDRUST_FEATURES: "gdnative/async,gdnative/serde"
1414

15+
RIPGREP_VERSION: "13.0.0"
16+
1517
on:
1618
pull_request:
1719
branches:
@@ -52,6 +54,19 @@ jobs:
5254
- name: "Check clippy"
5355
run: cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
5456

57+
check-todo:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v3
61+
- name: "Install ripgrep"
62+
run: |
63+
cd /tmp
64+
wget --no-verbose https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz -O ripgrep.tar.gz
65+
tar -zxvf ripgrep.tar.gz
66+
sudo mv ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/rg /usr/bin
67+
- name: "Look for TODO comments without issue numbers attached to them"
68+
run: bash tools/detect-todo.sh
69+
5570
unit-test:
5671
runs-on: ubuntu-latest
5772
steps:

tools/detect-todo.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/bash
2+
3+
# Small utility to detect todo comments
4+
# Used by godot-rust developers
5+
6+
REGEX='(?<!clippy::)(TODO|FIXME)(?!!\(\)|[a-zA-Z]|\((#|(\w+/)+)\d+\))'
7+
8+
# Self test
9+
10+
TEST_OUTPUT=$(rg -i --pcre2 "$REGEX" <<EOF
11+
# Should hit - Naive
12+
13+
todo
14+
TODO
15+
fixme
16+
FiXmE
17+
reallytodo
18+
trulyfixme
19+
20+
# Should hit - Malformed
21+
22+
todo123
23+
fixme123
24+
TODO(123)
25+
TODO(/////)
26+
TODO(T123)
27+
28+
# Should not hit - With issue numbers
29+
30+
todo(#123)
31+
todo(foo/bar/123)
32+
fixme(#123)
33+
fixme(foo/bar/123)
34+
35+
# Should not hit - Other uses of the words
36+
37+
clippy::todo
38+
todo!()
39+
40+
# Should not hit - Words merely containing the keywords
41+
42+
mastodon
43+
ictodosaur
44+
EOF
45+
)
46+
47+
diff -u --color <(printf '%s\n' "$TEST_OUTPUT") <(cat <<EOF
48+
todo
49+
TODO
50+
fixme
51+
FiXmE
52+
reallytodo
53+
trulyfixme
54+
todo123
55+
fixme123
56+
TODO(123)
57+
TODO(/////)
58+
TODO(T123)
59+
EOF
60+
)
61+
62+
if [[ $? -ne 0 ]]
63+
then
64+
echo 'Test run of detection regex failed.'
65+
exit 1
66+
fi
67+
68+
# Actual run
69+
70+
rg -iTh -Tsh --pcre2 "$REGEX"
71+
if [[ $? -eq 0 ]]
72+
then
73+
echo 'Found TODO comments without issue numbers.'
74+
exit 1
75+
fi

0 commit comments

Comments
 (0)