Repository navigation
285 lines (240 loc) · 10.8 KB
/
Copy pathbindings.yml
File metadata and controls
285 lines (240 loc) · 10.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
name: CI-bindings
# Full validation of the package components (docs/tasks/0311, decision B5): every JSON
# binding and the Boost big-integer adapter, on Linux under the sanitizers, MSVC with the
# static CRT, Apple Clang, a system (b2-built) Boost, and an install consumed through every
# component. The default jobs test only the nlohmann_json binding and the toy traits, so this
# runs on pull requests that touch the bindings or the contract they implement, nightly on
# master, and on demand. The merge steward checks the nightly status before stacking a train.
# The ASan job also runs the parity corpus with Reflect views of the contexts (docs/tasks/0322).
on:
pull_request:
branches:
- master
- main
paths:
- 'bindings/**'
- 'include/jinja2cpp/json_adapter.h'
- 'include/jinja2cpp/reflected_value.h'
- 'include/jinja2cpp/big_int_backend.h'
- 'test/binding/**'
- 'test/package/**'
- 'test/parity/parity_test.cpp'
- 'test/parity/divergences/reflect.txt'
- 'cmake/public/**'
- 'thirdparty/**'
- 'CMakeLists.txt'
- '.github/workflows/bindings.yml'
schedule:
- cron: '41 2 * * *'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
TEST_BINDINGS: nlohmann_json;boost_json
# The binding tests: the conformance suite on every binding and the toys, the per-binding
# rows and the big-integer adapter
BINDING_TESTS: '*Json*:*BigInt*'
jobs:
sanitizers:
name: bindings ${{ matrix.sanitizer }} (${{ matrix.compiler }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
# Lifetimes of reflected items (docs/tasks/0125), with the Boost backend built in
- { compiler: gcc-14, sanitizer: address+undefined, bigint: boost }
# The conformance suite's concurrent renders of one borrowed view
- { compiler: clang-18, sanitizer: thread, bigint: none }
env:
ASAN_OPTIONS: detect_leaks=1:strict_string_checks=1:detect_stack_use_after_return=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
TSAN_OPTIONS: halt_on_error=1:second_deadlock_stack=1
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Install toolchain
uses: ./.github/actions/install-toolchain
with:
compiler: ${{ matrix.compiler }}
- uses: ./.github/actions/setup-ccache
with:
key: bindings-${{ matrix.compiler }}-${{ matrix.sanitizer }}
# As in linux-build.yml: sanitizer instrumentation makes GCC emit false-positive
# -Wstringop-overflow (also inside boost::json); warnings are enforced elsewhere
- name: Configure
run: |
cmake -S . -B .build -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DJINJA2CPP_DEPS_MODE=internal \
-DJINJA2CPP_CXX_STANDARD=17 \
-DJINJA2CPP_WITH_SANITIZERS=${{ matrix.sanitizer }} \
"-DJINJA2CPP_TEST_BINDINGS=${TEST_BINDINGS}" \
-DJINJA2CPP_WITH_BIGINT=${{ matrix.bigint }} \
-DJINJA2CPP_STRICT_WARNINGS=OFF
- name: Build
run: cmake --build .build --parallel --target jinja2cpp_tests
- name: Test
run: .build/jinja2cpp_tests "--gtest_filter=${BINDING_TESTS}"
# The parity corpus with every context as views of the document instead of copies
# (docs/tasks/0322): a wide check of the view adapters and, under ASan, of the owner
# chain of every item a template reaches. Not in the per-PR matrix.
- name: Parity corpus through Reflect
if: matrix.sanitizer == 'address+undefined'
env:
JINJA2CPP_PARITY_CONTEXT: reflect
run: .build/jinja2cpp_tests "--gtest_filter=ParityReflect/*:ParityRegistry.*"
msvc:
name: bindings MSVC C++17 Release /MT static
runs-on: windows-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: x64
- uses: ./.github/actions/setup-ccache
with:
key: bindings-windows-msvc
- name: Build
shell: cmd
run: |
cmake -S . -B .build -G Ninja -DCMAKE_POLICY_DEFAULT_CMP0141=NEW -DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded -DCMAKE_BUILD_TYPE=Release -DJINJA2CPP_MSVC_RUNTIME_TYPE=/MT -DJINJA2CPP_DEPS_MODE=internal -DJINJA2CPP_BUILD_SHARED=FALSE -DJINJA2CPP_CXX_STANDARD=17 "-DJINJA2CPP_TEST_BINDINGS=%TEST_BINDINGS%"
cmake --build .build --config Release --parallel --target jinja2cpp_tests
- name: Test
shell: cmd
run: .build\jinja2cpp_tests.exe "--gtest_filter=%BINDING_TESTS%"
macos:
name: bindings macos-15 AppleClang C++17 Release
runs-on: macos-15
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Install Ninja
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
command -v ninja >/dev/null || brew install ninja
ninja --version
- uses: ./.github/actions/setup-ccache
with:
key: bindings-macos-15
max-size: 500M
- name: Configure
run: |
cmake -S . -B .build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DJINJA2CPP_DEPS_MODE=internal \
-DJINJA2CPP_CXX_STANDARD=17 \
"-DJINJA2CPP_TEST_BINDINGS=${TEST_BINDINGS}"
- name: Build
run: cmake --build .build --parallel --target jinja2cpp_tests
- name: Test
run: .build/jinja2cpp_tests "--gtest_filter=${BINDING_TESTS}"
# Boost and nlohmann_json from Ubuntu (Boost.JSON built by b2, not by Boost's CMake), then
# the install consumed through every component, by find_package and by pkg-config (shared:
# a static library's pkg-config file lists its private dependencies only in internal mode)
system-deps-and-package:
name: bindings system Boost and nlohmann_json, package components (gcc-14)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Install toolchain
uses: ./.github/actions/install-toolchain
with:
compiler: gcc-14
- uses: ./.github/actions/setup-ccache
with:
key: bindings-system-gcc-14
- name: System dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libboost-dev libboost-json-dev libboost-container-dev nlohmann-json3-dev
- name: fmt, expected-lite and fast_float
run: |
git clone --depth 1 --branch 12.2.0 https://github.com/fmtlib/fmt.git "$RUNNER_TEMP/fmt"
# PIC: the shared jinja2cpp links this static fmt
cmake -S "$RUNNER_TEMP/fmt" -B "$RUNNER_TEMP/fmt/build" -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DFMT_TEST=OFF -DFMT_DOC=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build "$RUNNER_TEMP/fmt/build"
sudo cmake --install "$RUNNER_TEMP/fmt/build"
git clone --depth 1 --branch v0.10.0 https://github.com/nonstd-lite/expected-lite.git "$RUNNER_TEMP/expected-lite"
cmake -S "$RUNNER_TEMP/expected-lite" -B "$RUNNER_TEMP/expected-lite/build" -G Ninja \
-DEXPECTED_LITE_OPT_BUILD_TESTS=OFF -DEXPECTED_LITE_OPT_BUILD_EXAMPLES=OFF
sudo cmake --install "$RUNNER_TEMP/expected-lite/build"
git clone --depth 1 --branch v8.2.10 https://github.com/fastfloat/fast_float.git "$RUNNER_TEMP/fast_float"
cmake -S "$RUNNER_TEMP/fast_float" -B "$RUNNER_TEMP/fast_float/build" -G Ninja
sudo cmake --install "$RUNNER_TEMP/fast_float/build"
- name: Configure
run: |
cmake -S . -B .build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DJINJA2CPP_DEPS_MODE=external \
-DJINJA2CPP_BUILD_SHARED=ON \
"-DJINJA2CPP_TEST_BINDINGS=${TEST_BINDINGS}" \
-DJINJA2CPP_STRICT_WARNINGS=ON \
-DCMAKE_CXX_FLAGS=-Wno-error=maybe-uninitialized
- name: Build
run: cmake --build .build --parallel --target jinja2cpp_tests
- name: Test
run: .build/jinja2cpp_tests "--gtest_filter=${BINDING_TESTS}"
- name: Installed package, every component
run: |
cmake -DBUILD_DIR=.build -DPREFIX="$RUNNER_TEMP/jinja2cpp" -DCONFIG=Release \
-DCONSUMER_STD=17 -DEXPECT_SHARED=ON \
"-DCOMPONENTS=nlohmann_json;boost_json;boost_multiprecision" \
-P test/package/check_package.cmake
# clang-tidy on the changed lines of the components and their tests, in a configuration
# that gives every component its include path (the clang-tidy workflow has nlohmann only)
clang-tidy:
name: bindings clang-tidy (changed lines)
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
env:
CLANG_TIDY_VERSION: 22.1.8
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
fetch-depth: 0
- name: Install toolchain
uses: ./.github/actions/install-toolchain
with:
compiler: clang-18
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version-file: .python-version
- name: Install clang-tidy
run: |
python -m pip install "clang-tidy==${CLANG_TIDY_VERSION}" pyyaml==6.0.3
bin="$(python -c 'import clang_tidy, os; print(os.path.join(os.path.dirname(clang_tidy.__file__), "data", "bin"))')"
echo "TIDY_BIN=$bin" >> "$GITHUB_ENV"
echo "CLANG_TIDY=$(command -v clang-tidy)" >> "$GITHUB_ENV"
- name: Configure
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DJINJA2CPP_DEPS_MODE=internal \
-DJINJA2CPP_CXX_STANDARD=17 \
"-DJINJA2CPP_TEST_BINDINGS=${TEST_BINDINGS}" \
-DJINJA2CPP_WITH_BIGINT=boost
- name: clang-tidy on changed lines
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
set -o pipefail
status=0
# The big-integer adapter on its own borrows flags without Multiprecision's include
# path; test/big_int_test.cpp, which includes it, covers it (docs/tasks/0272)
git diff -U0 --no-color "$BASE_SHA" -- bindings test/binding ':!bindings/boost_multiprecision/*' \
| python "$TIDY_BIN/clang-tidy-diff.py" -p1 -path build -j "$(nproc)" -quiet \
-clang-tidy-binary "$CLANG_TIDY" \
-extra-arg=-Wno-unknown-warning-option \
-extra-arg=-I"$GITHUB_WORKSPACE/build/generated/include" \
| tee tidy.log || status=$?
grep -E '^/[^ ]+:[0-9]+:[0-9]+: (warning|error): ' tidy.log | sort -u \
| sed -E "s#^$GITHUB_WORKSPACE/##; s#^([^:]+):([0-9]+):([0-9]+): (warning|error): (.*)#::\4 file=\1,line=\2,col=\3::\5#" || true
exit "$status"