Repository navigation
313 lines (283 loc) · 12.2 KB
/
Copy pathtests.yml
File metadata and controls
313 lines (283 loc) · 12.2 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
name: Run Tests
on:
push:
branches: [master, staging]
pull_request:
branches: [master, staging]
workflow_dispatch:
# A new push to the same branch/PR cancels the still-running previous run.
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
env:
# Cap apt timeouts so an unreachable Azure mirror costs seconds, not 20 minutes.
APT_OPTS: -o Acquire::Retries=2 -o Acquire::http::Timeout=10
jobs:
# ──────────────────────────────────────────────
# Core matrix: OS/arch × SQLite. Builds the library,
# the tests, and the sample on every cell.
# ──────────────────────────────────────────────
tests:
name: ${{ matrix.os }} sqlite=${{ matrix.sqlite }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm, macos-15, windows-2022, windows-2025]
sqlite: [OFF, ON]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install dependencies (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get $APT_OPTS update
sudo apt-get $APT_OPTS install -y --no-install-recommends \
libcurl4-openssl-dev libssl-dev
- name: Configure
run: cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_BUILD_SAMPLE=ON -DCOUNTLY_USE_SQLITE=${{ matrix.sqlite }} -B build .
- name: Build
run: cmake --build build --config Release -j 4
- name: Run tests
shell: bash
run: |
if [ -f build/Release/countly-tests.exe ]; then
./build/Release/countly-tests.exe
else
./build/countly-tests
fi
# ──────────────────────────────────────────────
# Build-option flavors and toolchains (Linux).
# One job per flavor via matrix include.
# ──────────────────────────────────────────────
flavors:
name: ${{ matrix.name }}
runs-on: ubuntu-24.04
timeout-minutes: 45
# TSAN detects known threading issues tracked for future refactor.
# It runs for visibility but does not block the pipeline.
continue-on-error: ${{ matrix.experimental == true }}
strategy:
fail-fast: false
matrix:
include:
- name: sanitizer-asan
flags: -DCOUNTLY_USE_SQLITE=ON -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address"
- name: sanitizer-ubsan
flags: -DCOUNTLY_USE_SQLITE=ON -DCMAKE_CXX_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=undefined" -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=undefined"
- name: sanitizer-tsan
flags: -DCOUNTLY_USE_SQLITE=ON -DCMAKE_CXX_FLAGS="-fsanitize=thread" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread" -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=thread"
experimental: true
- name: static-custom-http
flags: -DCOUNTLY_USE_SQLITE=ON -DBUILD_SHARED_LIBS=OFF -DCOUNTLY_USE_CUSTOM_HTTP=ON
- name: static-builtin-http
flags: -DCOUNTLY_USE_SQLITE=ON -DBUILD_SHARED_LIBS=OFF
- name: system-json
flags: -DCOUNTLY_USE_SQLITE=ON -DCOUNTLY_USE_SYSTEM_JSON=ON
apt: nlohmann-json3-dev
- name: custom-sha256
flags: -DCOUNTLY_USE_SQLITE=ON -DCOUNTLY_USE_CUSTOM_SHA256=ON
- name: system-sqlite
flags: -DCOUNTLY_USE_SQLITE=ON -DCOUNTLY_USE_SYSTEM_SQLITE=ON
apt: libsqlite3-dev
- name: cpp17
flags: -DCOUNTLY_USE_SQLITE=ON -DCMAKE_CXX_STANDARD=17
- name: cpp20
flags: -DCOUNTLY_USE_SQLITE=ON -DCMAKE_CXX_STANDARD=20
- name: clang
flags: -DCOUNTLY_USE_SQLITE=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
apt: clang
env:
ASAN_OPTIONS: "detect_leaks=1"
UBSAN_OPTIONS: "print_stacktrace=1"
TSAN_OPTIONS: "second_deadlock_stack=1"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install dependencies
run: |
sudo apt-get $APT_OPTS update
sudo apt-get $APT_OPTS install -y --no-install-recommends \
libcurl4-openssl-dev libssl-dev ${{ matrix.apt }}
- name: Configure
run: cmake ${{ matrix.flags }} -DCOUNTLY_BUILD_TESTS=1 -B build .
- name: Build
run: cmake --build build -j 4
- name: Run tests
run: ./build/countly-tests
# ──────────────────────────────────────────────
# Oldest supported CMake (3.13, as documented).
# Catches accidental use of newer CMake features.
# ──────────────────────────────────────────────
min-cmake:
name: cmake-3.13
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install dependencies
run: |
sudo apt-get $APT_OPTS update
sudo apt-get $APT_OPTS install -y --no-install-recommends \
libcurl4-openssl-dev libssl-dev
- name: Install CMake 3.13
run: |
curl -sSL -o cmake.tar.gz https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.tar.gz
tar -xzf cmake.tar.gz
echo "$PWD/cmake-3.13.5-Linux-x86_64/bin" >> "$GITHUB_PATH"
- name: Configure and build with CMake 3.13
run: |
cmake --version
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_BUILD_SAMPLE=ON -DCOUNTLY_USE_SQLITE=ON -B build .
cmake --build build -j 4
- name: Run tests
run: ./build/countly-tests
# ──────────────────────────────────────────────
# Installed SDK: an app that sees only the install
# prefix finds it with find_package and runs.
# ──────────────────────────────────────────────
install:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- name: install-shared
os: ubuntu-24.04
shared: ON
sqlite: OFF
- name: install-static
os: ubuntu-24.04
shared: OFF
sqlite: OFF
- name: install-static-sqlite
os: ubuntu-24.04
shared: OFF
sqlite: ON
- name: install-shared-macos
os: macos-15
shared: ON
sqlite: OFF
- name: install-static-macos
os: macos-15
shared: OFF
sqlite: OFF
- name: install-shared-windows
os: windows-2022
shared: ON
sqlite: OFF
- name: install-shared-sqlite-windows
os: windows-2022
shared: ON
sqlite: ON
- name: install-static-windows
os: windows-2022
shared: OFF
sqlite: OFF
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install dependencies (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get $APT_OPTS update
sudo apt-get $APT_OPTS install -y --no-install-recommends \
libcurl4-openssl-dev libssl-dev
- name: Build and install
run: |
cmake -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DCOUNTLY_USE_SQLITE=${{ matrix.sqlite }} -DCMAKE_BUILD_TYPE=Release -B build .
cmake --build build --config Release -j 4
cmake --install build --config Release --prefix "$RUNNER_TEMP/countly"
# Apps built without CMake (vcpkg's Visual Studio integration, plain makefiles) never see the SDK's definitions
- name: Check that the installed headers do not depend on COUNTLY_USE_SQLITE
run: |
if grep -rnE '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif).*COUNTLY_USE_SQLITE' "$RUNNER_TEMP/countly/include/countly.hpp" "$RUNNER_TEMP/countly/include/countly"; then
echo "::error::the installed headers change with COUNTLY_USE_SQLITE"
exit 1
fi
- name: Build and run an app with find_package
working-directory: ${{ runner.temp }}
run: |
openssl_root=""
if [ "$RUNNER_OS" = "macOS" ]; then
openssl_root="-DOPENSSL_ROOT_DIR=$(brew --prefix openssl)"
fi
cmake -S "$GITHUB_WORKSPACE/.github/package-check" -B app/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$RUNNER_TEMP/countly" -DEXPECT_COUNTLY_SQLITE=${{ matrix.sqlite }} $openssl_root
cmake --build app/build --config Release
if [ "$RUNNER_OS" = "Windows" ]; then
if [ "${{ matrix.shared }}" = "ON" ]; then
cp countly/bin/countly.dll app/build/Release/
fi
./app/build/Release/app.exe
else
./app/build/app
fi
# ──────────────────────────────────────────────
# Android: the SDK compiles with the NDK's default
# flags, which make format-security warnings errors.
# ──────────────────────────────────────────────
android:
name: android-${{ matrix.abi }}
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
abi: [arm64-v8a, x86_64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build with the Android NDK
run: |
ndk="${ANDROID_NDK_LATEST_HOME:-$ANDROID_NDK_HOME}"
cmake -B build -DCMAKE_TOOLCHAIN_FILE="$ndk/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=${{ matrix.abi }} -DANDROID_PLATFORM=android-28 -DCMAKE_BUILD_TYPE=Release \
-DCOUNTLY_USE_CUSTOM_HTTP=ON -DCOUNTLY_USE_CUSTOM_SHA256=ON -DCOUNTLY_USE_SQLITE=ON \
-DCOUNTLY_BUILD_TESTS=1 .
cmake --build build -j 4
# ──────────────────────────────────────────────
# Release tooling smoke test: the SBOM generator must
# not be discovered broken on release day.
# ──────────────────────────────────────────────
sbom-check:
name: sbom-generator
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Generate and validate SBOM
run: |
python3 scripts/generate_sbom.py
python3 - << 'EOF'
import glob, json, sys
path = glob.glob("countly-sdk-cpp-*.cdx.json")[0]
doc = json.load(open(path))
assert doc["bomFormat"] == "CycloneDX", "not a CycloneDX document"
assert doc["components"], "no components"
refs = {c["bom-ref"] for c in doc["components"]}
refs.add(doc["metadata"]["component"]["bom-ref"])
for dep in doc["dependencies"]:
missing = [r for r in [dep["ref"], *dep["dependsOn"]] if r not in refs]
assert not missing, f"dangling bom-refs: {missing}"
print(f"ok: {path} with {len(doc['components'])} components")
EOF