Skip to content

Commit 83b08ff

Browse files
committed
Implement CI for static check
1 parent caa873e commit 83b08ff

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed
Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,66 @@
11
name: C++ Code Style and Static Analysis
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
46

57
jobs:
68
cpp-checks:
79
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
911
steps:
1012
- name: Checkout Code
1113
uses: actions/checkout@v3
1214

1315
- 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
1820

1921
- 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
2125

26+
- name: Separator
27+
run: echo "==============================================================="
28+
2229
- 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='*'
2432

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

Comments
 (0)