Repository navigation
383 lines (373 loc) · 13.8 KB
/
Copy pathcpp.yml
File metadata and controls
383 lines (373 loc) · 13.8 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
name: C++
on:
push:
paths:
- 'cpp/**'
- 'conformance/**'
- 'formats/**'
- 'rust/**'
- '.github/workflows/cpp.yml'
pull_request:
paths:
- 'cpp/**'
- 'conformance/**'
- 'formats/**'
- 'rust/**'
- '.github/workflows/cpp.yml'
permissions:
contents: read
concurrency:
group: cpp-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# The test, msvc and sanitizers jobs run ctest, whose conformance tests run
# the whole suite through the driver with the runner in rust/, so each needs
# Rust. The builder round trip and differential jobs need it too; lint and
# fuzz do not.
jobs:
test:
name: Test (${{ matrix.compiler }})
strategy:
fail-fast: false
matrix:
include:
- compiler: GCC 14
os: ubuntu-24.04
packages: g++-14
cxx: g++-14
# Clang compiles against GCC 14's libstdc++.
- compiler: Clang 20
os: ubuntu-24.04
packages: clang-20 g++-14
cxx: clang++-20
- compiler: Apple Clang
os: macos-latest
cxx: clang++
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: cpp
steps:
- uses: actions/checkout@v7
- name: Install compiler
if: matrix.packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ${{ matrix.packages }}
- uses: dtolnay/rust-toolchain@stable
- uses: astral-sh/setup-uv@v7
- name: Install CMake and Ninja
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool dir --bin >> "$GITHUB_PATH"
- name: Cache Cargo artifacts
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-${{ hashFiles('rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-
- name: Show compiler
run: ${{ matrix.cxx }} --version
- name: Configure
env:
CXX: ${{ matrix.cxx }}
run: cmake --preset dev
- name: Build
run: cmake --build --preset dev
- name: Test
run: ctest --preset dev
msvc:
name: Test (MSVC)
runs-on: windows-latest
defaults:
run:
# PowerShell, as Git Bash's link.exe would shadow the MSVC linker.
shell: pwsh
working-directory: cpp
steps:
# The conformance cases compare bytes, so check them out with LF.
- name: Keep line endings
working-directory: .
run: git config --global core.autocrlf false
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: astral-sh/setup-uv@v7
- name: Install CMake and Ninja
shell: bash
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool dir --bin >> "$GITHUB_PATH"
- uses: ilammy/msvc-dev-cmd@v1
- name: Cache Cargo artifacts
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-${{ hashFiles('rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-
- name: Configure
env:
CXX: cl
run: cmake --preset dev
- name: Build
run: cmake --build --preset dev
- name: Test
run: ctest --preset dev
sanitizers:
name: Sanitizers (${{ matrix.preset }}, ${{ matrix.compiler }})
strategy:
fail-fast: false
matrix:
include:
- preset: asan
compiler: Clang 20
packages: clang-20 libclang-rt-20-dev g++-14
cxx: clang++-20
# GCC links the TSan runtime as a shared library, so the memory
# test's operator new replaces the runtime's. Clang links it
# statically on Linux, where the two definitions clash.
- preset: tsan
compiler: GCC 14
packages: g++-14
cxx: g++-14
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
working-directory: cpp
steps:
- uses: actions/checkout@v7
- name: Install compiler
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ${{ matrix.packages }}
# TSan's shadow memory needs fewer random bits in mmap addresses than
# the runner's kernel uses.
- name: Reduce mmap randomization
if: matrix.preset == 'tsan'
run: sudo sysctl vm.mmap_rnd_bits=28
- uses: dtolnay/rust-toolchain@stable
- uses: astral-sh/setup-uv@v7
- name: Install CMake and Ninja
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool dir --bin >> "$GITHUB_PATH"
- name: Cache Cargo artifacts
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-${{ hashFiles('rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-
# The conformance tests run the sanitized driver.
- name: Configure
env:
CXX: ${{ matrix.cxx }}
run: cmake --preset ${{ matrix.preset }}
- name: Build
run: cmake --build --preset ${{ matrix.preset }}
- name: Test
run: ctest --preset ${{ matrix.preset }}
lint:
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
- name: Install compiler and Doxygen
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang-20 g++-14 doxygen
- uses: astral-sh/setup-uv@v7
- name: Install CMake and Ninja
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool dir --bin >> "$GITHUB_PATH"
- name: Check formatting
run: git ls-files 'cpp/*.hpp' 'cpp/*.cpp' | xargs uvx clang-format==22.1.8 --dry-run --Werror
# clang-tidy needs only compile_commands.json, which configuring writes.
- name: Configure
working-directory: cpp
env:
CXX: clang++-20
run: cmake --preset dev -DIRIS_CONFORMANCE_TESTS=OFF
- name: Lint
run: git ls-files 'cpp/*.cpp' | xargs uvx clang-tidy==22.1.8 -p cpp/build/dev --quiet
- name: Build the API reference
run: cmake --build cpp/build/dev --target iris-docs
# Generates a C++ builder program for every accepted corpus spec, checks it
# with clang-format and clang-tidy, builds it with the warnings as errors,
# and compares the spec it prints with the original. Then checks the
# generated views of every format with the same tools, which ctest runs
# without them.
builder-round-trip:
name: Builder round trip (${{ matrix.compiler }})
strategy:
fail-fast: false
matrix:
include:
- compiler: GCC 14
packages: g++-14
cxx: g++-14
- compiler: Clang 20
packages: clang-20 g++-14
cxx: clang++-20
runs-on: ubuntu-24.04
timeout-minutes: 60
defaults:
run:
shell: bash
working-directory: rust
steps:
- uses: actions/checkout@v7
- name: Install compiler
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ${{ matrix.packages }}
- uses: dtolnay/rust-toolchain@stable
- uses: astral-sh/setup-uv@v7
- name: Install CMake, Ninja, clang-format and clang-tidy
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool install clang-format==22.1.8
uv tool install clang-tidy==22.1.8
uv tool dir --bin >> "$GITHUB_PATH"
- name: Cache Cargo artifacts
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-${{ hashFiles('rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
cpp-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-
- name: Round-trip the corpus
env:
CXX: ${{ matrix.cxx }}
CMAKE_GENERATOR: Ninja
run: |
IRIS_CLANG_FORMAT="$(command -v clang-format)" \
IRIS_CLANG_TIDY="$(command -v clang-tidy)" \
cargo test --locked -p gecode-iris --test builder_round_trip_cpp -- --ignored --nocapture
- name: Check the generated views
env:
CXX: ${{ matrix.cxx }}
CMAKE_GENERATOR: Ninja
run: |
IRIS_CLANG_FORMAT="$(command -v clang-format)" \
IRIS_CLANG_TIDY="$(command -v clang-tidy)" \
cargo test --locked -p gecode-iris --test cpp_views -- --ignored --nocapture
fuzz:
name: Fuzz (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
target: [parse, read]
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
shell: bash
working-directory: cpp
steps:
- uses: actions/checkout@v7
# libFuzzer ships in libclang-rt; Clang uses GCC 14's libstdc++.
- name: Install compiler
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang-20 libclang-rt-20-dev g++-14
- uses: astral-sh/setup-uv@v7
- name: Install CMake and Ninja
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool dir --bin >> "$GITHUB_PATH"
- name: Configure
env:
CXX: clang++-20
run: cmake --preset fuzz
- name: Build
run: cmake --build --preset fuzz --target iris-fuzz-${{ matrix.target }}
- name: Write seed corpora
working-directory: .
run: python3 -I rust/fuzz/seed-corpus.py
- name: Fuzz ${{ matrix.target }} for two minutes
run: |
mkdir -p build/fuzz/corpus/${{ matrix.target }} build/fuzz/artifacts/${{ matrix.target }}
build/fuzz/fuzz/iris-fuzz-${{ matrix.target }} \
build/fuzz/corpus/${{ matrix.target }} ../rust/fuzz/corpus/${{ matrix.target }} \
-dict=fuzz/iris.dict -max_total_time=120 -max_len=8192 -timeout=60 \
-artifact_prefix=build/fuzz/artifacts/${{ matrix.target }}/
- name: Upload failing inputs
if: failure()
uses: actions/upload-artifact@v6
with:
name: cpp-fuzz-${{ matrix.target }}-artifacts
path: cpp/build/fuzz/artifacts/
# Generates and mutates cases and fails on any difference between the
# Rust driver and the sanitized C++ driver.
differential:
name: Differential (Rust and C++)
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
shell: bash
working-directory: rust
steps:
- uses: actions/checkout@v7
- name: Install compiler
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang-20 libclang-rt-20-dev g++-14
- uses: dtolnay/rust-toolchain@stable
- uses: astral-sh/setup-uv@v7
- name: Install CMake and Ninja
run: |
uv tool install cmake==4.4.4
uv tool install ninja==1.13.0
uv tool dir --bin >> "$GITHUB_PATH"
- name: Cache Cargo artifacts
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: cpp-differential-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-${{ hashFiles('rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
cpp-differential-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust/rust-toolchain.toml') }}-
- name: Build the Rust driver and the runner
run: cargo build --release --locked -p iris-driver -p gecode-iris-conformance
- name: Configure the sanitized C++ driver
working-directory: cpp
env:
CXX: clang++-20
run: cmake --preset asan -DIRIS_CONFORMANCE_TESTS=OFF
- name: Build the sanitized C++ driver
working-directory: cpp
run: cmake --build --preset asan --target iris-driver
# Without abort_on_error a sanitizer report exits 1, the protocol's
# status for a language error.
- name: Compare for five minutes
env:
ASAN_OPTIONS: abort_on_error=1
UBSAN_OPTIONS: print_stacktrace=1:abort_on_error=1
run: |
target/release/iris-conformance differential \
--driver "\"$PWD/target/release/iris-driver\"" \
--driver "\"$PWD/../cpp/build/asan/iris-driver\"" \
--seed "$GITHUB_RUN_ID" --duration 300 --jobs "$(nproc)" \
--keep "$RUNNER_TEMP/differential" \
../conformance/cases/0.1 ../formats
- name: Upload reproducers
if: failure()
uses: actions/upload-artifact@v6
with:
name: cpp-differential-reproducers
path: ${{ runner.temp }}/differential/