Skip to content

Commit 86d89ce

Browse files
committed
ci: add forbidden-paths guard to prevent build artifacts in git
1 parent 5d47006 commit 86d89ce

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: forbidden-paths
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, master]
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Check for forbidden tracked paths
14+
shell: bash
15+
run: |
16+
set -e
17+
# Patterns that should never be tracked (build outputs, scratch dirs)
18+
PATTERNS=(
19+
'bin/'
20+
'obj/'
21+
'build/'
22+
'build-debug/'
23+
'build_test/'
24+
'CMakeFiles/'
25+
'CMakeScratch/'
26+
'pkgRedirects/'
27+
'TestResults/'
28+
'_dev/'
29+
'_dump/'
30+
'_gauntlet/'
31+
'\.tlog$'
32+
'\.tlog/'
33+
'^tree\.txt$'
34+
'^\.claude/'
35+
)
36+
37+
FAIL=0
38+
for pat in "${PATTERNS[@]}"; do
39+
HITS=$(git ls-files | grep -E "$pat" || true)
40+
if [ -n "$HITS" ]; then
41+
echo "❌ Forbidden path pattern matched: $pat"
42+
echo "$HITS" | head -20
43+
echo ""
44+
FAIL=1
45+
fi
46+
done
47+
48+
if [ "$FAIL" -ne 0 ]; then
49+
echo "Build artifacts or scratch dirs are tracked in git."
50+
echo "Remove them with 'git rm -rf --cached <path>' and ensure .gitignore covers them."
51+
exit 1
52+
fi
53+
54+
echo "✅ No forbidden paths tracked."

0 commit comments

Comments
 (0)