@@ -3,8 +3,16 @@ name: Syntax Check
33on :
44 push :
55 branches : [ "master" ]
6+ paths :
7+ - " **/*.py"
8+ - " **/*.cpp"
9+ - " **/*.c"
610 pull_request :
711 branches : [ "master" ]
12+ paths :
13+ - " **/*.py"
14+ - " **/*.cpp"
15+ - " **/*.c"
816
917jobs :
1018 syntax-check :
1422 - name : Checkout code
1523 uses : actions/checkout@v4
1624
25+ # --- Python Syntax Check ---
1726 - name : Set up Python
1827 uses : actions/setup-python@v5
1928 with :
2635
2736 - name : Lint Python Files
2837 run : |
29- # E999, F821, F822, F823 catch syntax, undefined names, and name errors
38+ # Only checks syntax and severe errors
3039 flake8 . --count --select=E999,F821,F822,F823 --show-source --statistics
3140
41+ # --- C/C++ Syntax Check ---
3242 - name : Install C/C++ Compiler (GCC)
3343 run : |
3444 sudo apt-get update
@@ -39,26 +49,25 @@ jobs:
3949 echo "Checking C and C++ files for syntax errors..."
4050 errors=0
4151
42- # Find and check all .c files
43- find . -name "*.c" | while read -r file; do
52+ # Using redirect loops to properly catch errors without subshell issues
53+ while read -r file; do
54+ if [ -z "$file" ]; then continue; fi
4455 echo "Checking $file"
45- # -fsyntax-only checks syntax without compiling/linking an executable
4656 if ! gcc -fsyntax-only "$file"; then
47- echo " Syntax error in $file"
57+ echo "Syntax error in $file"
4858 errors=$((errors + 1))
4959 fi
50- done
60+ done < <(find . -name "*.c")
5161
52- # Find and check all .cpp files
53- find . -name "*.cpp" | while read -r file; do
62+ while read -r file; do
63+ if [ -z "$file" ]; then continue; fi
5464 echo "Checking $file"
5565 if ! g++ -fsyntax-only "$file"; then
56- echo "Syntax error in $file"
66+ echo "syntax error in $file"
5767 errors=$((errors + 1))
5868 fi
59- done
69+ done < <(find . -name "*.cpp")
6070
61- # If any errors were found, fail the workflow
6271 if [ $errors -ne 0 ]; then
6372 echo "$errors file(s) failed syntax verification."
6473 exit 1
0 commit comments