|
1 | 1 | name: C++ Code Style and Static Analysis |
2 | 2 |
|
3 | | -on: [pull_request] |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, ready_for_review] |
4 | 6 |
|
5 | 7 | jobs: |
6 | 8 | cpp-checks: |
7 | 9 | runs-on: ubuntu-latest |
8 | | - container: ghcr.io/myusername/cpp-ci:latest # Use the custom container |
| 10 | + container: ghcr.io/kpi-rover/kpi-rover-bbb-check:latest |
9 | 11 | steps: |
10 | 12 | - name: Checkout Code |
11 | 13 | uses: actions/checkout@v3 |
12 | 14 |
|
13 | 15 | - name: Configure CMake |
14 | | - run: | |
15 | | - mkdir -p build |
16 | | - cd build |
17 | | - cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 16 | + run: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B build/check |
| 17 | + |
| 18 | + - name: Verify compile_commands.json exists |
| 19 | + run: ls build/check/compile_commands.json |
18 | 20 |
|
19 | 21 | - name: Run Clang-Format |
20 | | - run: clang-format --dry-run --Werror $(find src/ -name "*.cpp" -o -name "*.h") |
| 22 | + id: clang-format |
| 23 | + continue-on-error: true |
| 24 | + run: find src/kpi_rover_ecu/ -name '*.cpp' -o -name '*.h' | xargs --no-run-if-empty clang-format --dry-run --Werror |
21 | 25 |
|
| 26 | + - name: Separator |
| 27 | + run: echo "===============================================================" |
| 28 | + |
22 | 29 | - name: Run Clang-Tidy |
23 | | - run: clang-tidy -p=build -extra-arg=-v $(find src/ -name "*.cpp" -o -name "*.h") |
| 30 | + id: clang-tidy |
| 31 | + run: find src/kpi_rover_ecu/ -name '*.cpp' -o -name '*.h' | xargs --no-run-if-empty clang-tidy -p=build/check --warnings-as-errors='*' |
24 | 32 |
|
25 | | - - name: Check Clang-Tidy Version |
26 | | - run: clang-tidy --version |
| 33 | + - name: Report Status |
| 34 | + if: always() |
| 35 | + uses: actions/github-script@v6 |
| 36 | + with: |
| 37 | + script: | |
| 38 | + const formatStatus = ${{ steps.clang-format.outcome == 'success' }}; |
| 39 | + const tidyStatus = ${{ steps.clang-tidy.outcome == 'success' }}; |
| 40 | + const conclusion = (formatStatus && tidyStatus) ? 'success' : 'failure'; |
| 41 | + |
| 42 | + let summary = ''; |
| 43 | + if (formatStatus) { |
| 44 | + summary += '✅ Clang-Format check passed\n'; |
| 45 | + } else { |
| 46 | + summary += '❌ Clang-Format check failed\n'; |
| 47 | + } |
| 48 | + |
| 49 | + if (tidyStatus) { |
| 50 | + summary += '✅ Clang-Tidy check passed\n'; |
| 51 | + } else { |
| 52 | + summary += '❌ Clang-Tidy check failed\n'; |
| 53 | + } |
| 54 | + |
| 55 | + github.rest.checks.create({ |
| 56 | + owner: context.repo.owner, |
| 57 | + repo: context.repo.repo, |
| 58 | + name: 'Code Style Check', |
| 59 | + head_sha: context.payload.pull_request.head.sha, |
| 60 | + status: 'completed', |
| 61 | + conclusion: conclusion, |
| 62 | + output: { |
| 63 | + title: 'C++ Code Style Results', |
| 64 | + summary: summary |
| 65 | + } |
| 66 | + }); |
0 commit comments