-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (144 loc) · 4.84 KB
/
Copy pathtest.yml
File metadata and controls
167 lines (144 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: [main]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
cpp-format:
name: C++ Format Check
runs-on: ubuntu-latest
container: mcr.microsoft.com/devcontainers/cpp:ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: apt-get update -qq && apt-get install -y --no-install-recommends clang-format
- name: Check C++ code formatting
run: |
# Find all C++ files
FILES=$(find . -name "*.cpp" -o -name "*.h" -o -name "*.hpp" | grep -v \.pio | grep -v build)
if [ -n "$FILES" ]; then
echo "Checking formatting for files:"
echo "$FILES"
clang-format --dry-run --Werror $FILES
else
echo "No C++ files found to check"
fi
markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DavidAnson/markdownlint-cli2-action@v22
with:
globs: "*.md"
mermaid-lint:
name: Mermaid Diagram Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install mermaid-cli
run: npm install -g @mermaid-js/mermaid-cli
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run Mermaid validation script
run: python scripts/validate_mermaid.py
unit-tests:
name: Host Unit Tests
runs-on: ubuntu-latest
container: mcr.microsoft.com/devcontainers/cpp:ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache CMake build directory
uses: actions/cache@v4
with:
path: .vscode/build
key: cmake-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'test/CMakeLists.txt') }}
restore-keys: |
cmake-${{ runner.os }}-
- name: Configure CMake
run: |
cmake -B .vscode/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-Wno-dev
- name: Build tests
run: cmake --build .vscode/build --target pedal_tests -j$(nproc)
- name: Run tests
run: |
mkdir -p test-results
.vscode/build/test/pedal_tests --gtest_output=xml:test-results/
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: test-results/*.xml
comment_mode: always
check_name: "GoogleTest Results"
- name: Upload test report artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: test-results/
retention-days: 30
# Coverage threshold (gcovr --fail-under-line 80) is intentionally CI-only.
# The local pre-commit hook (scripts/pre-commit) does NOT enforce it — running
# gcovr on every commit is too slow for an interactive workflow. A drop below
# 80% will fail this CI job, not the local commit. See TASK-321 closing notes.
coverage:
name: Code Coverage
runs-on: ubuntu-latest
container: mcr.microsoft.com/devcontainers/cpp:ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install gcovr
run: apt-get update -qq && apt-get install -y --no-install-recommends gcovr
- name: Configure CMake with coverage instrumentation
run: |
cmake -B .vscode/build-coverage \
-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \
-Wno-dev
- name: Build tests
run: cmake --build .vscode/build-coverage --target pedal_tests -j$(nproc)
- name: Run tests
run: .vscode/build-coverage/test/pedal_tests
- name: Generate coverage report (HTML + XML, enforce 80% threshold)
run: |
mkdir -p docs/coverage
gcovr \
--root . \
--filter='lib/PedalLogic/.*' \
--filter='lib/hardware/.*' \
--exclude='.*littlefs_file_system.*' \
--html-details docs/coverage/index.html \
--xml coverage.xml \
--print-summary \
--fail-under-line 80
- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-html
path: docs/coverage/
retention-days: 30
- name: Upload coverage XML
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-xml
path: coverage.xml
retention-days: 30