fix tasks #20
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: Code Quality | |
| on: | |
| push: | |
| branches: [main, "sa/*", "dev/*"] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| clang-format: | |
| runs-on: ubuntu-latest | |
| name: clang-format check | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install clang-format | |
| run: sudo apt-get install -y clang-format | |
| - name: Check formatting (user code) | |
| run: | | |
| # Check user-written source files under Core/User/ (excludes CubeMX-generated code) | |
| FILES=$(find . -path "*/Core/User/*" \( -name "*.c" -o -name "*.h" \) 2>/dev/null) | |
| if [ -z "$FILES" ]; then | |
| echo "No user source files found to check." | |
| exit 0 | |
| fi | |
| FAILED=0 | |
| for f in $FILES; do | |
| if ! clang-format --dry-run --Werror "$f" 2>/dev/null; then | |
| echo "::error file=$f::Formatting violation in $f" | |
| FAILED=1 | |
| fi | |
| done | |
| if [ "$FAILED" -eq 1 ]; then | |
| echo "" | |
| echo "Run 'clang-format -i <file>' to fix formatting, or use your editor's format-on-save." | |
| exit 1 | |
| fi | |
| cppcheck: | |
| runs-on: ubuntu-latest | |
| name: cppcheck ${{ matrix.project }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| project: [BMS, PCU, DASH, LVPDB, DART, DCU, Sensor_Nodes] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Check if project has source code | |
| id: check | |
| run: | | |
| if [ ! -d "${{ matrix.project }}/Core" ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "::warning::${{ matrix.project }} has no Core/ directory, skipping cppcheck." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Install cppcheck | |
| if: steps.check.outputs.skip != 'true' | |
| run: sudo apt-get install -y cppcheck | |
| - name: Run cppcheck | |
| if: steps.check.outputs.skip != 'true' | |
| working-directory: ${{ matrix.project }} | |
| run: | | |
| cppcheck \ | |
| --enable=warning,performance,portability \ | |
| --suppress=missingIncludeSystem \ | |
| --suppress=unmatchedSuppression \ | |
| --error-exitcode=1 \ | |
| --inline-suppr \ | |
| -i Drivers \ | |
| -i Middlewares \ | |
| Core/ \ | |
| 2>&1 |