Skip to content

Commit 34dfe07

Browse files
committed
ci(client-cpp): link-test example after Windows VS package builds
1 parent 6dc9834 commit 34dfe07

3 files changed

Lines changed: 85 additions & 3 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with this
4+
# work for additional information regarding copyright ownership. The ASF
5+
# licenses this file to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance with the
7+
# License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Link-test example/client-cpp-example against a freshly built Windows SDK install
18+
# tree, using the same Visual Studio generator as the package job (CMAKE_GENERATOR).
19+
set -euxo pipefail
20+
21+
cd "${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is not set}"
22+
23+
SDK="${GITHUB_WORKSPACE}/iotdb-client/client-cpp/target/install"
24+
EXAMPLE_SRC="${GITHUB_WORKSPACE}/example/client-cpp-example/src"
25+
BUILD_DIR="${GITHUB_WORKSPACE}/build/client-cpp-example-verify"
26+
rm -rf "${BUILD_DIR}"
27+
28+
test -f "${SDK}/lib/iotdb_session.dll"
29+
test -f "${SDK}/lib/iotdb_session.lib"
30+
31+
GEN_ARGS=()
32+
if [[ -n "${CMAKE_GENERATOR:-}" ]]; then
33+
GEN_ARGS=(-G "${CMAKE_GENERATOR}")
34+
fi
35+
36+
echo "=== Link-test client-cpp-example (Windows / same VS generator) ==="
37+
if [[ ${#GEN_ARGS[@]} -gt 0 ]]; then
38+
echo "CMAKE_GENERATOR=${CMAKE_GENERATOR}"
39+
else
40+
echo "CMAKE_GENERATOR=(default for runner)"
41+
fi
42+
cmake --version | head -1
43+
44+
cmake -S "${EXAMPLE_SRC}" -B "${BUILD_DIR}" \
45+
"${GEN_ARGS[@]}" \
46+
-A x64 \
47+
-DIOTDB_SDK_ROOT="${SDK}" \
48+
-DWITH_SSL=OFF
49+
50+
cmake --build "${BUILD_DIR}" --config Release --target SessionExample --parallel
51+
52+
EXE="${BUILD_DIR}/Release/SessionExample.exe"
53+
DLL="${BUILD_DIR}/Release/iotdb_session.dll"
54+
test -f "${EXE}"
55+
test -f "${DLL}"
56+
57+
# Guard against accidental Win32 builds.
58+
python3 - <<'PY' "${EXE}"
59+
import struct, sys
60+
path = sys.argv[1]
61+
with open(path, "rb") as f:
62+
data = f.read()
63+
pe_off = struct.unpack_from("<I", data, 0x3C)[0]
64+
machine = struct.unpack_from("<H", data, pe_off + 4)[0]
65+
if machine != 0x8664:
66+
raise SystemExit(f"Expected PE32+ x64 (0x8664), got 0x{machine:04X}")
67+
print(f"Verified x64 executable: {path}")
68+
PY
69+
70+
echo "client-cpp-example SessionExample link test passed (Windows)"

.github/workflows/client-cpp-package.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
- '.github/workflows/client-cpp-package.yml'
6161
- '.github/workflows/client-cpp-source-build.yml'
6262
- '.github/scripts/package-client-cpp-*.sh'
63+
- '.github/scripts/verify-client-cpp-example-*.sh'
6364
- id: result
6465
shell: bash
6566
run: |
@@ -409,6 +410,14 @@ jobs:
409410
throw "Expected PE32+ x64 (machine=0x8664), got 0x$($machine.ToString('X4'))"
410411
}
411412
Write-Host "Verified x64 DLL: $dll"
413+
- name: Link-test client-cpp-example (same VS toolchain)
414+
shell: bash
415+
env:
416+
CMAKE_GENERATOR: ${{ matrix.cmake_generator }}
417+
run: |
418+
set -euxo pipefail
419+
chmod +x .github/scripts/verify-client-cpp-example-windows.sh
420+
.github/scripts/verify-client-cpp-example-windows.sh
412421
- name: Resolve package zip
413422
id: pkg
414423
shell: bash

iotdb-client/client-cpp/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ Example file name:
101101
when linking.
102102

103103
CI runs an extra check after packaging: build `SessionExample` from
104-
`example/client-cpp-example` inside the same manylinux2014 container using
105-
**system `/usr/bin/g++`** (no devtoolset on `PATH`) against the freshly built
106-
SDK install tree, then prints `ldd` output.
104+
`example/client-cpp-example` against the freshly built SDK install tree.
105+
106+
- **Linux glibc217**: inside manylinux2014 with **system `/usr/bin/g++`**
107+
(no devtoolset on `PATH`), then `ldd`.
108+
- **Windows**: same **Visual Studio generator** as the package matrix entry
109+
(see `.github/scripts/verify-client-cpp-example-windows.sh`).
107110

108111
Thrift **0.21.0** is compiled from source during the CMake configure step (see
109112
`cmake/FetchThrift.cmake`). Older releases that used pre-built

0 commit comments

Comments
 (0)