-
Notifications
You must be signed in to change notification settings - Fork 2
190 lines (182 loc) · 6.15 KB
/
Copy pathcpp.yml
File metadata and controls
190 lines (182 loc) · 6.15 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: cpp
on:
push:
branches: [main]
paths:
- 'cpp/**'
- '.clang-format'
- '.github/workflows/cpp.yml'
pull_request:
branches: [main]
paths:
- 'cpp/**'
- '.clang-format'
- '.github/workflows/cpp.yml'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: cpp-${{ github.ref }}
cancel-in-progress: true
jobs:
format-check:
name: clang-format check
runs-on: ubuntu-latest
# Repo-wide format pass landed in commit e3590aa1; gate is now hard.
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check C++ source formatting
run: |
mapfile -t files < <(
find cpp/ \( -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' \) \
-not -path '*/Qt/*' \
-not -path '*/build*/*' \
-not -path '*moc_*' \
-not -path '*ui_*'
)
if [ "${#files[@]}" -eq 0 ]; then
echo "No C++ sources found."
exit 0
fi
echo "Checking ${#files[@]} files..."
clang-format --dry-run -Werror "${files[@]}"
build-and-test:
# Library subprojects: full build + GoogleTest run.
name: build & test
runs-on: ubuntu-latest
continue-on-error: true # initial pass: collect data without gating
strategy:
fail-fast: false
matrix:
subproject:
- s21_containers
- s21_matrix+
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libgtest-dev googletest \
lcov gcovr
# libgtest-dev ships sources only on older Ubuntu — make the
# canonical static libs available system-wide.
if [ ! -f /usr/lib/x86_64-linux-gnu/libgtest.a ]; then
( cd /usr/src/googletest && sudo cmake -B build && sudo cmake --build build && sudo cmake --install build )
fi
- name: Build & test
working-directory: cpp/${{ matrix.subproject }}/src
run: make test || true
- name: Coverage report (best-effort)
id: coverage
working-directory: cpp/${{ matrix.subproject }}/src
run: |
make gcov_report 2>/dev/null || true
info=$(find . -maxdepth 2 -name '*.info' -type f | head -1)
if [ -n "$info" ]; then
echo "info=$info" >> "$GITHUB_OUTPUT"
echo "Coverage tracefile: $info"
fi
continue-on-error: true
- name: Upload coverage to Codecov
if: steps.coverage.outputs.info != ''
uses: codecov/codecov-action@v4
with:
files: cpp/${{ matrix.subproject }}/src/${{ steps.coverage.outputs.info }}
flags: cpp-${{ matrix.subproject }}
name: cpp-${{ matrix.subproject }}-coverage
fail_ci_if_error: false
verbose: false
continue-on-error: true
apps-cpp-tests:
# GUI applications: only the C++-business-logic test target,
# which does not depend on Qt. The qmake-driven Qt GUI build runs
# in apps-qt-build below.
name: apps C++-only tests
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
subproject:
- 3DViewer_v2.0
- CPP5_3DViewer_v2.1
- CPP6_3DViewer_v2.2
- SmartCalc_v2.0
steps:
- uses: actions/checkout@v4
- name: Install dependencies (cached)
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: build-essential libgtest-dev googletest lcov gcovr
version: 1.0
- name: Build libgtest static lib if missing
run: |
if [ ! -f /usr/lib/x86_64-linux-gnu/libgtest.a ]; then
sudo cmake -S /usr/src/googletest -B /tmp/gtest-build
sudo cmake --build /tmp/gtest-build
sudo cmake --install /tmp/gtest-build
fi
- name: Run C++-only tests
working-directory: cpp/${{ matrix.subproject }}/src
run: |
# Try a 'test' Makefile target first, then fall back to a
# 'tests' target name some subprojects use.
if make -n test >/dev/null 2>&1; then
make test || true
elif make -n tests >/dev/null 2>&1; then
make tests || true
else
echo "no 'test' or 'tests' Makefile target — skipping"
fi
continue-on-error: true
apps-qt-build:
# Qt6 GUI build for the four C++ Qt apps.
# Uses jurplel/install-qt-action to provision Qt, then runs the
# subproject's own 'install' / 'all' Makefile target via xvfb.
name: apps Qt6 GUI build
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
subproject:
- 3DViewer_v2.0
- CPP5_3DViewer_v2.1
- CPP6_3DViewer_v2.2
- SmartCalc_v2.0
steps:
- uses: actions/checkout@v4
- name: Install Qt6
uses: jurplel/install-qt-action@v4
with:
version: '6.5.3'
host: 'linux'
target: 'desktop'
arch: 'linux_gcc_64'
cache: true
- name: Install build deps (cached)
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: build-essential xvfb libgl1-mesa-dev libglu1-mesa-dev libgtest-dev googletest
version: 1.0
- name: Build libgtest static lib if missing
run: |
if [ ! -f /usr/lib/x86_64-linux-gnu/libgtest.a ]; then
sudo cmake -S /usr/src/googletest -B /tmp/gtest-build
sudo cmake --build /tmp/gtest-build
sudo cmake --install /tmp/gtest-build
fi
- name: GUI build (xvfb-wrapped)
working-directory: cpp/${{ matrix.subproject }}/src
run: |
# Most Qt cpp/ apps use 'make install' as the canonical GUI
# build target. Wrap in xvfb-run for any post-build steps
# that need a display.
xvfb-run -a make install || true
continue-on-error: true