Skip to content

Commit 73c1e32

Browse files
authored
add todos check (#14367)
* add todos check * change target branch * fix: no merge base * add FIXME
1 parent e2cd299 commit 73c1e32

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/todos-check.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Check TODOs and FIXMEs in Changed Files
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
- 'rel/*'
8+
- "rc/*"
9+
paths-ignore:
10+
- 'docs/**'
11+
- 'site/**'
12+
# allow manually run the action:
13+
workflow_dispatch:
14+
15+
jobs:
16+
todo-check:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Check for TODOs and FIXMEs in changed files
24+
run: |
25+
# Fetch the target branch
26+
git fetch origin $GITHUB_BASE_REF
27+
28+
# Check if there is a common ancestor
29+
if git merge-base --is-ancestor origin/$GITHUB_BASE_REF HEAD; then
30+
# Get the diff of the changes
31+
DIFF=$(git diff origin/$GITHUB_BASE_REF...HEAD)
32+
else
33+
# If no common ancestor, compare with the initial commit
34+
DIFF=$(git diff $(git hash-object -t tree /dev/null) HEAD)
35+
fi
36+
37+
# Check the diff for TODOs
38+
if echo "$DIFF" | grep -Eq '^\+.*(TODO|FIXME)'; then
39+
echo "TODO found in the changes. Please resolve it before merging."
40+
exit 1
41+
else
42+
echo "No TODOs found in changed content."
43+
fi

0 commit comments

Comments
 (0)