Skip to content

Commit 7de2b4e

Browse files
authored
Merge pull request #146 from Countly/sbs
SDK Behavior Settings
2 parents 16ec656 + a8e44f0 commit 7de2b4e

32 files changed

+3678
-63
lines changed

.github/workflows/tests.yml

Lines changed: 249 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,271 @@ on:
77
branches: [master, staging]
88

99
jobs:
10-
doctests:
10+
# ──────────────────────────────────────────────
11+
# Core test matrix: OS × SQLite
12+
# ──────────────────────────────────────────────
13+
tests:
1114
runs-on: ${{ matrix.os }}
1215
timeout-minutes: 120
1316
strategy:
1417
fail-fast: false
1518
matrix:
16-
os:
17-
- ubuntu-22.04
18-
- macos-15
19-
- windows-2022
20-
21-
include:
19+
os: [ubuntu-22.04, ubuntu-24.04, macos-15, windows-2022]
20+
sqlite: [OFF, ON]
21+
exclude:
22+
# Windows has no system sqlite3.lib
2223
- os: windows-2022
23-
cmake-generator: -G "Visual Studio 17 2022" -A x64
24-
cmake-install: "" #Already installed on hosted runner
25-
dependencies: "" #Already installed on hosted runner
26-
make: msbuild countly-tests.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release && .\Release\countly-tests.exe
27-
- os: macos-15
28-
cmake-install: "" #Already installed on hosted runner
29-
dependencies: "" #Already installed on hosted runner
30-
make: make ./countly-tests && ./countly-tests
31-
- os: ubuntu-22.04
32-
cmake-install: "" #Already installed on hosted runner
33-
dependencies: |
34-
sudo apt-get update && sudo apt-get install -y \
35-
libcurl4-openssl-dev \
36-
libssl-dev
37-
make: make ./countly-tests && ./countly-tests
24+
sqlite: ON
3825

3926
steps:
4027
- name: Checkout code
41-
uses: actions/checkout@v2
28+
uses: actions/checkout@v4
4229
with:
4330
submodules: "recursive"
4431

45-
- name: Update submodules
46-
run: git submodule update --init --recursive
32+
- name: Install dependencies (Ubuntu)
33+
if: startsWith(matrix.os, 'ubuntu')
34+
run: |
35+
sudo apt-get update && sudo apt-get install -y \
36+
libcurl4-openssl-dev \
37+
libssl-dev \
38+
libsqlite3-dev
4739
48-
- name: Install CMake
49-
run: ${{ matrix.cmake-install }}
40+
- name: Set up MSVC
41+
if: matrix.os == 'windows-2022'
42+
uses: microsoft/setup-msbuild@v2
5043

51-
- name: Install dependencies
52-
run: ${{ matrix.dependencies }}
44+
- name: Configure (Unix)
45+
if: matrix.os != 'windows-2022'
46+
run: cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=${{ matrix.sqlite }} -B build .
47+
env:
48+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
5349

54-
- name: Set up MSVC
50+
- name: Configure (Windows)
5551
if: matrix.os == 'windows-2022'
56-
uses: microsoft/setup-msbuild@v1
52+
run: cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=${{ matrix.sqlite }} -G "Visual Studio 17 2022" -A x64 -B build .
53+
env:
54+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
55+
56+
- name: Build (Unix)
57+
if: matrix.os != 'windows-2022'
58+
run: cd build && make ./countly-tests
59+
60+
- name: Build (Windows)
61+
if: matrix.os == 'windows-2022'
62+
run: cd build && msbuild countly-tests.vcxproj -t:rebuild -verbosity:minimal -property:Configuration=Release
63+
64+
- name: Run tests (Unix)
65+
if: matrix.os != 'windows-2022'
66+
run: cd build && ./countly-tests
67+
68+
- name: Run tests (Windows)
69+
if: matrix.os == 'windows-2022'
70+
run: cd build && .\Release\countly-tests.exe
71+
72+
# ──────────────────────────────────────────────
73+
# Sanitizers (Linux only, with SQLite)
74+
# ──────────────────────────────────────────────
75+
sanitizer-asan:
76+
runs-on: ubuntu-22.04
77+
timeout-minutes: 120
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
with:
82+
submodules: "recursive"
83+
84+
- name: Install dependencies
85+
run: |
86+
sudo apt-get update && sudo apt-get install -y \
87+
libcurl4-openssl-dev \
88+
libssl-dev \
89+
libsqlite3-dev
90+
91+
- name: Configure with ASAN
92+
run: |
93+
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=ON \
94+
-DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
95+
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" \
96+
-DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address" \
97+
-B build .
98+
env:
99+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
100+
101+
- name: Build
102+
run: cd build && make ./countly-tests
103+
104+
- name: Run tests
105+
run: cd build && ./countly-tests
106+
env:
107+
ASAN_OPTIONS: "detect_leaks=1"
108+
109+
sanitizer-tsan:
110+
runs-on: ubuntu-22.04
111+
timeout-minutes: 120
112+
# TSAN detects known threading issues tracked for future refactor.
113+
# Runs for visibility but does not block the pipeline.
114+
continue-on-error: true
115+
steps:
116+
- name: Checkout code
117+
uses: actions/checkout@v4
118+
with:
119+
submodules: "recursive"
120+
121+
- name: Install dependencies
122+
run: |
123+
sudo apt-get update && sudo apt-get install -y \
124+
libcurl4-openssl-dev \
125+
libssl-dev \
126+
libsqlite3-dev
127+
128+
- name: Configure with TSAN
129+
run: |
130+
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=ON \
131+
-DCMAKE_CXX_FLAGS="-fsanitize=thread" \
132+
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread" \
133+
-DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=thread" \
134+
-B build .
135+
env:
136+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
137+
138+
- name: Build
139+
run: cd build && make ./countly-tests
140+
141+
- name: Run tests
142+
run: cd build && ./countly-tests
143+
env:
144+
TSAN_OPTIONS: "second_deadlock_stack=1"
145+
146+
sanitizer-ubsan:
147+
runs-on: ubuntu-22.04
148+
timeout-minutes: 120
149+
steps:
150+
- name: Checkout code
151+
uses: actions/checkout@v4
152+
with:
153+
submodules: "recursive"
154+
155+
- name: Install dependencies
156+
run: |
157+
sudo apt-get update && sudo apt-get install -y \
158+
libcurl4-openssl-dev \
159+
libssl-dev \
160+
libsqlite3-dev
57161
58-
- name: Build and run tests
162+
- name: Configure with UBSAN
59163
run: |
60-
cmake -DCOUNTLY_BUILD_TESTS=1 -B build . ${{ matrix.cmake-generator }}
61-
cd build
62-
${{ matrix.make }}
164+
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=ON \
165+
-DCMAKE_CXX_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all" \
166+
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=undefined" \
167+
-DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=undefined" \
168+
-B build .
169+
env:
170+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
171+
172+
- name: Build
173+
run: cd build && make ./countly-tests
174+
175+
- name: Run tests
176+
run: cd build && ./countly-tests
63177
env:
64-
CMAKE_POLICY_VERSION_MINIMUM: 3.31
178+
UBSAN_OPTIONS: "print_stacktrace=1"
179+
180+
# ──────────────────────────────────────────────
181+
# Static library build (custom HTTP, no curl)
182+
# ──────────────────────────────────────────────
183+
static-build:
184+
runs-on: ubuntu-22.04
185+
timeout-minutes: 120
186+
steps:
187+
- name: Checkout code
188+
uses: actions/checkout@v4
189+
with:
190+
submodules: "recursive"
191+
192+
- name: Install dependencies
193+
run: |
194+
sudo apt-get update && sudo apt-get install -y \
195+
libssl-dev \
196+
libsqlite3-dev
197+
198+
- name: Configure static build
199+
run: |
200+
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=ON \
201+
-DBUILD_SHARED_LIBS=OFF -DCOUNTLY_USE_CUSTOM_HTTP=ON \
202+
-B build .
203+
env:
204+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
205+
206+
- name: Build
207+
run: cd build && make ./countly-tests
208+
209+
- name: Run tests
210+
run: cd build && ./countly-tests
211+
212+
# ──────────────────────────────────────────────
213+
# C++17 compatibility check
214+
# ──────────────────────────────────────────────
215+
cpp17:
216+
runs-on: ubuntu-24.04
217+
timeout-minutes: 120
218+
steps:
219+
- name: Checkout code
220+
uses: actions/checkout@v4
221+
with:
222+
submodules: "recursive"
223+
224+
- name: Install dependencies
225+
run: |
226+
sudo apt-get update && sudo apt-get install -y \
227+
libcurl4-openssl-dev \
228+
libssl-dev \
229+
libsqlite3-dev
230+
231+
- name: Configure with C++17
232+
run: |
233+
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=ON \
234+
-DCMAKE_CXX_STANDARD=17 \
235+
-B build .
236+
env:
237+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
238+
239+
- name: Build
240+
run: cd build && make ./countly-tests
241+
242+
- name: Run tests
243+
run: cd build && ./countly-tests
244+
245+
# ──────────────────────────────────────────────
246+
# Clang on Linux
247+
# ──────────────────────────────────────────────
248+
clang-linux:
249+
runs-on: ubuntu-24.04
250+
timeout-minutes: 120
251+
steps:
252+
- name: Checkout code
253+
uses: actions/checkout@v4
254+
with:
255+
submodules: "recursive"
256+
257+
- name: Install dependencies
258+
run: |
259+
sudo apt-get update && sudo apt-get install -y \
260+
clang \
261+
libcurl4-openssl-dev \
262+
libssl-dev \
263+
libsqlite3-dev
264+
265+
- name: Configure with Clang
266+
run: |
267+
cmake -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_SQLITE=ON \
268+
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
269+
-B build .
270+
env:
271+
CMAKE_POLICY_VERSION_MINIMUM: "3.31"
272+
273+
- name: Build
274+
run: cd build && make ./countly-tests
275+
276+
- name: Run tests
277+
run: cd build && ./countly-tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ compile_commands.json
2020
CTestTestfile.cmake
2121
_deps
2222
cmake-build-debug/
23+
24+
.DS_Store
25+
test_results_*.log
26+
*.db

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
## XX.XX.XX
2+
- ! Minor breaking change ! SDK Behavior Settings is now enabled by default. Changes made on SDK Manager > SDK Behavior Settings on your server will affect SDK behavior directly.
3+
4+
- Added init config method "disableSDKBehaviorSettingsUpdates" to disable periodic SBS updates from the server.
5+
- Added init config method "setSDKBehaviorSettings" to provide server configuration in JSON format during initialization.
6+
27
- Fixed OpenSSL discovery in CMakeLists.txt to dynamically resolve the Homebrew prefix, supporting both Apple Silicon and Intel Macs.
38

49
## 23.2.4

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ add_library(countly
4848
${CMAKE_CURRENT_SOURCE_DIR}/src/request_builder.cpp
4949
${CMAKE_CURRENT_SOURCE_DIR}/src/storage_module_db.cpp
5050
${CMAKE_CURRENT_SOURCE_DIR}/src/storage_module_memory.cpp
51-
${CMAKE_CURRENT_SOURCE_DIR}/src/event.cpp)
51+
${CMAKE_CURRENT_SOURCE_DIR}/src/event.cpp
52+
${CMAKE_CURRENT_SOURCE_DIR}/src/configuration_module.cpp)
5253

5354
target_include_directories(countly
5455
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -116,7 +117,8 @@ if(COUNTLY_BUILD_TESTS)
116117
${CMAKE_CURRENT_SOURCE_DIR}/tests/event.cpp
117118
${CMAKE_CURRENT_SOURCE_DIR}/tests/crash.cpp
118119
${CMAKE_CURRENT_SOURCE_DIR}/tests/request.cpp
119-
${CMAKE_CURRENT_SOURCE_DIR}/tests/config.cpp)
120+
${CMAKE_CURRENT_SOURCE_DIR}/tests/config.cpp
121+
${CMAKE_CURRENT_SOURCE_DIR}/tests/sbs.cpp)
120122

121123
target_compile_options(countly-tests PRIVATE -g)
122124
target_compile_definitions(countly-tests PRIVATE COUNTLY_BUILD_TESTS)

0 commit comments

Comments
 (0)