-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (31 loc) · 1.33 KB
/
Copy pathcheck-todos.yml
File metadata and controls
38 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Check TODOs
on:
pull_request:
branches: ["main"]
jobs:
check-todos:
name: Check for unauthorized TODOs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for TODOs
run: |
echo "Checking for TODOs in the new committed code..."
# Ensure the base branch is fetched for comparison
git fetch origin ${{ github.base_ref }}
# Compare the PR branch against the base branch.
# The triple-dot diff (base...HEAD) finds the common ancestor and compares it with HEAD,
# ensuring we see all changes introduced in the PR, regardless of the number of commits.
# We exclude the workflow file itself and filter for added lines starting with '+'.
MATCHES=$(git diff -U0 origin/${{ github.base_ref }}...HEAD -- . ':(exclude).github/workflows/check-todos.yml' | grep -E "^\+.*TODO" | grep -E -v "TODO\s*\(long-term\)" || true)
if [ -n "$MATCHES" ]; then
echo "::error title=Unauthorized TODOs found::Please remove TODOs or mark them as 'TODO (long-term)' if they should be kept."
echo "Matches found:"
echo "$MATCHES"
exit 1
else
echo "No unauthorized TODOs found."
fi