Skip to content

Commit 0367200

Browse files
committed
CI: build in-tree smoke tests and run them via CTest on all platforms
New tools/tests/ target (networkml_smoke) exercises the whole public API: 44 offline checks for Auth/Url/File/Chat-state/object construction, plus 26 live HTTP checks against postman-echo.com covering every Requests verb, download with progress, and multipart upload. Gated behind NETWORKML_BUILD_TESTS=ON so downstream consumers never build it. CI configures with -DNETWORKML_BUILD_TESTS=ON on Linux, macOS, and Windows, then runs ctest with NETWORKML_LIVE=1 so the HTTP verbs are actually exercised (not just linked). Live Chat coverage stays opt-in via NETWORKML_CHAT_PROVIDER/MODEL so no credentials are required. Motivates: the CMake-config find_dependency bug found earlier this session shipped past CI because the workflow only compiled + installed the library, never running a real consumer. This closes that gap.
1 parent 141cbc7 commit 0367200

4 files changed

Lines changed: 383 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
# --- configure ---
3131
- name: Configure (Linux/macOS, system packages)
3232
if: runner.os != 'Windows'
33-
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
33+
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DNETWORKML_BUILD_TESTS=ON
3434

3535
# Cache vcpkg's built-package archives so curl/nlohmann-json are not
3636
# rebuilt from source on every run. vcpkg's old x-gha backend was
@@ -55,11 +55,19 @@ jobs:
5555
git -C "$env:VCPKG_INSTALLATION_ROOT" fetch --depth 1 origin $base
5656
git -C "$env:VCPKG_INSTALLATION_ROOT" checkout -f $base
5757
& "$env:VCPKG_INSTALLATION_ROOT\bootstrap-vcpkg.bat" -disableMetrics
58-
cmake -B build -S . "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
58+
cmake -B build -S . "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DNETWORKML_BUILD_TESTS=ON
5959
60-
# --- build + verify install/export ---
60+
# --- build + test + verify install/export ---
6161
- name: Build
6262
run: cmake --build build --config Release
6363

64+
# Smoke tests. Live HTTP is enabled on all runners; live Chat is skipped
65+
# unless NETWORKML_CHAT_PROVIDER + NETWORKML_CHAT_MODEL are set (opt-in).
66+
- name: Test
67+
working-directory: build
68+
env:
69+
NETWORKML_LIVE: "1"
70+
run: ctest -C Release --output-on-failure
71+
6472
- name: Install (verify export)
6573
run: cmake --install build --config Release --prefix "${{ runner.temp }}/nml-install"

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ install(FILES
7474
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NetworkML
7575
)
7676

77+
# Optional in-tree smoke tests (built only when explicitly requested, so downstream
78+
# consumers via add_subdirectory / FetchContent never build them by default).
79+
option(NETWORKML_BUILD_TESTS "Build the Network ML smoke tests (tools/tests)" OFF)
80+
if(NETWORKML_BUILD_TESTS)
81+
enable_testing()
82+
add_subdirectory(tools/tests)
83+
endif()
84+
7785
# Building, installing, and consuming instructions for this library are as follows:
7886
#
7987
# Build:

tools/tests/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Smoke test target, driven by CTest. Built only when NETWORKML_BUILD_TESTS=ON;
2+
# consumers of the library never see this.
3+
add_executable(networkml_smoke main.cpp)
4+
target_link_libraries(networkml_smoke PRIVATE networkml)
5+
6+
add_test(NAME smoke COMMAND networkml_smoke)
7+
# Keep the whole run under two minutes even if postman-echo is slow.
8+
set_tests_properties(smoke PROPERTIES TIMEOUT 120)

0 commit comments

Comments
 (0)