bench : Clean up and consolidate the core benchmarking framework used… #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Syntax Check | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| paths: | |
| - "**/*.py" | |
| - "**/*.cpp" | |
| - "**/*.c" | |
| pull_request: | |
| branches: [ "master" ] | |
| paths: | |
| - "**/*.py" | |
| - "**/*.cpp" | |
| - "**/*.c" | |
| jobs: | |
| syntax-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # --- Python Syntax Check --- | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Python Linter | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 | |
| - name: Lint Python Files | |
| run: | | |
| # Only checks syntax and severe errors | |
| flake8 . --count --select=E999,F821,F822,F823 --show-source --statistics | |
| # --- C/C++ Syntax Check --- | |
| - name: Install C/C++ Compiler (GCC) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc g++ | |
| - name: Check C/C++ Syntax | |
| run: | | |
| echo "Checking C and C++ files for syntax errors..." | |
| errors=0 | |
| # Using redirect loops to properly catch errors without subshell issues | |
| while read -r file; do | |
| if [ -z "$file" ]; then continue; fi | |
| echo "Checking $file" | |
| if ! gcc -fsyntax-only "$file"; then | |
| echo "Syntax error in $file" | |
| errors=$((errors + 1)) | |
| fi | |
| done < <(find . -name "*.c") | |
| while read -r file; do | |
| if [ -z "$file" ]; then continue; fi | |
| echo "Checking $file" | |
| if ! g++ -fsyntax-only "$file"; then | |
| echo "syntax error in $file" | |
| errors=$((errors + 1)) | |
| fi | |
| done < <(find . -name "*.cpp") | |
| if [ $errors -ne 0 ]; then | |
| echo "$errors file(s) failed syntax verification." | |
| exit 1 | |
| fi | |
| echo "All C, C++, and Python files passed syntax checks!" |