-
Notifications
You must be signed in to change notification settings - Fork 0
342 lines (297 loc) · 8.57 KB
/
Copy patherror-cross-platform-ci.yml
File metadata and controls
342 lines (297 loc) · 8.57 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: Error Cross Platform CI
on:
push:
branches: [main, master, dev]
paths:
- ".github/workflows/error-cross-platform-ci.yml"
- "CMakeLists.txt"
- "cmake/**"
- "include/**"
- "src/**"
- "test/**"
- "README.md"
- "CHANGELOG.md"
- "vix.json"
pull_request:
branches: [main, master, dev]
paths:
- ".github/workflows/error-cross-platform-ci.yml"
- "CMakeLists.txt"
- "cmake/**"
- "include/**"
- "src/**"
- "test/**"
- "README.md"
- "CHANGELOG.md"
- "vix.json"
workflow_dispatch:
permissions:
contents: read
env:
BUILD_JOBS: 2
jobs:
build-and-test:
name: build and test (${{ matrix.os }} / ${{ matrix.compiler }} / ${{ matrix.build_type }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
compiler: gcc
cc: gcc
cxx: g++
build_type: Debug
- os: ubuntu-24.04
compiler: clang
cc: clang
cxx: clang++
build_type: Debug
- os: ubuntu-24.04
compiler: gcc
cc: gcc
cxx: g++
build_type: Release
- os: macos-14
compiler: clang
cc: clang
cxx: clang++
build_type: Debug
- os: macos-15-intel
compiler: clang
cc: clang
cxx: clang++
build_type: Release
- os: windows-2022
compiler: msvc
build_type: Debug
- os: windows-2022
compiler: msvc
build_type: Release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
ninja-build \
clang \
gcc \
g++ \
pkg-config \
cppcheck \
clang-tidy \
valgrind
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
set -euxo pipefail
brew update
brew install ninja cppcheck llvm || true
- name: Configure environment (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
echo "CC=${{ matrix.cc }}" >> "$GITHUB_ENV"
echo "CXX=${{ matrix.cxx }}" >> "$GITHUB_ENV"
- name: Configure
shell: bash
run: |
set -euxo pipefail
CMAKE_ARGS=(
-S .
-B build
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DVIX_ERROR_BUILD_TESTS=ON
-DCMAKE_INSTALL_PREFIX=$PWD/install
)
if [ "${{ runner.os }}" != "Windows" ]; then
CMAKE_ARGS+=(-G Ninja)
fi
cmake "${CMAKE_ARGS[@]}"
- name: Build
shell: bash
run: |
set -euxo pipefail
if [ "${{ runner.os }}" = "Windows" ]; then
cmake --build build --config ${{ matrix.build_type }} --parallel ${BUILD_JOBS}
else
cmake --build build --parallel ${BUILD_JOBS}
fi
- name: Run tests
shell: bash
run: |
set -euxo pipefail
if [ "${{ runner.os }}" = "Windows" ]; then
ctest --test-dir build -C ${{ matrix.build_type }} --output-on-failure
else
ctest --test-dir build --output-on-failure
fi
- name: Install
shell: bash
run: |
set -euxo pipefail
if [ "${{ runner.os }}" = "Windows" ]; then
cmake --install build --config ${{ matrix.build_type }}
else
cmake --install build
fi
- name: Verify installed package with find_package
shell: bash
run: |
set -euxo pipefail
mkdir -p smoke
cat > smoke/CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.20)
project(error_smoke LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(vix_error CONFIG REQUIRED)
add_executable(error_smoke main.cpp)
target_link_libraries(error_smoke PRIVATE vix::error)
EOF
cat > smoke/main.cpp <<'EOF'
#include <iostream>
int main()
{
std::cout << "vix::error package found\n";
return 0;
}
EOF
if [ "${{ runner.os }}" = "Windows" ]; then
cmake -S smoke -B smoke/build \
-DCMAKE_PREFIX_PATH="$PWD/install"
cmake --build smoke/build --config ${{ matrix.build_type }}
else
cmake -S smoke -B smoke/build \
-G Ninja \
-DCMAKE_PREFIX_PATH="$PWD/install"
cmake --build smoke/build
fi
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: error-logs-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}
path: |
build/CMakeCache.txt
build/CMakeFiles/CMakeOutput.log
build/CMakeFiles/CMakeError.log
build/CMakeFiles/CMakeConfigureLog.yaml
if-no-files-found: warn
static-analysis-linux:
name: static analysis (linux)
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
shell: bash
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
ninja-build \
clang \
cppcheck \
clang-tidy
- name: Configure
shell: bash
run: |
set -euxo pipefail
export CC=clang
export CXX=clang++
cmake -S . -B build-analyze -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DVIX_ERROR_BUILD_TESTS=ON
- name: Run clang-tidy
shell: bash
run: |
set +e
find src test -name '*.cpp' -print0 2>/dev/null | xargs -0 -r -n1 -P2 clang-tidy -p build-analyze
exit 0
- name: Run cppcheck
shell: bash
run: |
set +e
cppcheck \
--enable=all \
--std=c++20 \
--inconclusive \
--quiet \
--suppress=missingIncludeSystem \
include/ src/ test/
exit 0
valgrind-linux:
name: valgrind (linux)
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
shell: bash
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
ninja-build \
valgrind
- name: Configure
shell: bash
run: |
set -euxo pipefail
cmake -S . -B build-valgrind -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DVIX_ERROR_BUILD_TESTS=ON
- name: Build
shell: bash
run: |
set -euxo pipefail
cmake --build build-valgrind --parallel ${BUILD_JOBS}
- name: Run valgrind on test executable
shell: bash
run: |
set -euxo pipefail
test -x build-valgrind/test/vix_error_test
valgrind \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
build-valgrind/test/vix_error_test
summary:
name: error cross platform summary
needs:
- build-and-test
- static-analysis-linux
- valgrind-linux
runs-on: ubuntu-24.04
steps:
- name: Print summary
shell: bash
run: |
echo "Error cross-platform CI completed."
echo "- Linux build and test"
echo "- macOS build and test"
echo "- Windows build and test"
echo "- install verification"
echo "- find_package(vix_error) smoke test"
echo "- clang-tidy"
echo "- cppcheck"
echo "- valgrind"