Skip to content

Issue #10: Test code style check DO NOT MERGE #4

Issue #10: Test code style check DO NOT MERGE

Issue #10: Test code style check DO NOT MERGE #4

name: C++ Code Style and Static Analysis
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
cpp-checks:
runs-on: ubuntu-latest
container: ghcr.io/kpi-rover/kpi-rover-bbb-check:latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Configure CMake
run: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B build/check
- name: Verify compile_commands.json exists
run: ls build/check/compile_commands.json
- name: Run Clang-Format
id: clang-format
continue-on-error: true
run: find src/kpi_rover_ecu/ -name '*.cpp' -o -name '*.h' | xargs --no-run-if-empty clang-format --dry-run --Werror
- name: Separator
run: echo "==============================================================="
- name: Run Clang-Tidy
id: clang-tidy
run: find src/kpi_rover_ecu/ -name '*.cpp' -o -name '*.h' | xargs --no-run-if-empty clang-tidy -p=build/check --warnings-as-errors='*'
- name: Report Status
if: always()
uses: actions/github-script@v6
with:
script: |
const formatStatus = ${{ steps.clang-format.outcome == 'success' }};
const tidyStatus = ${{ steps.clang-tidy.outcome == 'success' }};
const conclusion = (formatStatus && tidyStatus) ? 'success' : 'failure';
let summary = '';
if (formatStatus) {
summary += '✅ Clang-Format check passed\n';
} else {
summary += '❌ Clang-Format check failed\n';
}
if (tidyStatus) {
summary += '✅ Clang-Tidy check passed\n';
} else {
summary += '❌ Clang-Tidy check failed\n';
}
github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Code Style Check',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: conclusion,
output: {
title: 'C++ Code Style Results',
summary: summary
}
});