-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (35 loc) · 1.08 KB
/
check-python-prints.yml
File metadata and controls
42 lines (35 loc) · 1.08 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
39
40
41
42
name: Check for print() in Python files
permissions:
contents: read
on:
pull_request:
branches:
- master
jobs:
check-prints:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Look for print() in Python files
run: |
echo "🔍 Scanning for 'print(' in Python files..."
# Find all added/modified Python files in the PR
git fetch --unshallow
git fetch origin master
changed_files=$(git diff --name-only origin/master...HEAD -- '*.py')
if [ -z "$changed_files" ]; then
echo "✅ No Python files changed."
exit 0
fi
echo "Changed Python files:"
echo "$changed_files"
# Search for 'print(' in changed files
found=$(grep -nH -E '(^|[^a-zA-Z0-9_])print\s*\(' $changed_files || true)
if [ -n "$found" ]; then
echo "❌ Found print statements:"
echo "$found"
exit 1
else
echo "✅ No print statements found."
fi