Skip to content

Commit 552f8f1

Browse files
committed
Implement package testing
1 parent 1081143 commit 552f8f1

File tree

4 files changed

+473
-2
lines changed

4 files changed

+473
-2
lines changed

.github/workflows/build-cpack-packages.yml

Lines changed: 146 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,50 @@ jobs:
4747
- name: Build packages
4848
run: make build-package
4949

50+
- name: Install driver package (DEB)
51+
run: |
52+
set -euo pipefail
53+
shopt -s nullglob
54+
DRIVER_PACKAGES=(build/*.deb)
55+
if [ "${#DRIVER_PACKAGES[@]}" -eq 0 ]; then
56+
echo "No driver DEB packages produced"
57+
exit 1
58+
fi
59+
sudo dpkg -i "${DRIVER_PACKAGES[@]}"
60+
sudo apt-get install -f -y
61+
62+
- name: Build smoke-test application package
63+
run: |
64+
set -euo pipefail
65+
make -C packaging/smoke-test-app package \
66+
BUILD_TYPE=${{ inputs.build-type }} \
67+
CMAKE_GENERATOR=Ninja \
68+
INSTALL_PREFIX=/usr \
69+
CPACK_GENERATORS="DEB RPM"
70+
71+
- name: Install smoke-test application package (DEB)
72+
run: |
73+
set -euo pipefail
74+
make -C packaging/smoke-test-app install-deb
75+
76+
- name: Run smoke-test application against local Scylla
77+
run: |
78+
set -euo pipefail
79+
cleanup() {
80+
sudo docker compose -f tests/examples_cluster/docker-compose.yml down --remove-orphans
81+
}
82+
trap cleanup EXIT
83+
sudo docker compose -f tests/examples_cluster/docker-compose.yml up -d --wait
84+
/usr/bin/scylla-cpp-driver-smoke-test 172.43.0.2
85+
5086
- name: Collect artifacts
5187
run: |
5288
set -euo pipefail
5389
shopt -s nullglob
5490
mkdir -p artifacts/linux
55-
for file in build/*.deb build/*.rpm; do
91+
for file in build/*.deb build/*.rpm \
92+
packaging/smoke-test-app/build/*.deb \
93+
packaging/smoke-test-app/build/*.rpm; do
5694
cp "$file" artifacts/linux/
5795
done
5896
@@ -72,12 +110,48 @@ jobs:
72110
- name: Build packages
73111
run: make build-package
74112

113+
- name: Install driver package (pkg)
114+
run: |
115+
set -euo pipefail
116+
shopt -s nullglob
117+
packages=(build/*.pkg)
118+
if [ "${#packages[@]}" -eq 0 ]; then
119+
echo "No driver pkg packages produced"
120+
exit 1
121+
fi
122+
for pkg in "${packages[@]}"; do
123+
sudo installer -pkg "$pkg" -target /
124+
done
125+
126+
- name: Build smoke-test application package
127+
run: |
128+
set -euo pipefail
129+
make -C packaging/smoke-test-app package \
130+
BUILD_TYPE=${{ inputs.build-type }}
131+
132+
- name: Install smoke-test application package (pkg)
133+
run: |
134+
set -euo pipefail
135+
make -C packaging/smoke-test-app install-pkg
136+
137+
- name: Run smoke-test application against local Scylla
138+
run: |
139+
set -euo pipefail
140+
cleanup() {
141+
docker compose -f tests/examples_cluster/docker-compose.yml down --remove-orphans
142+
}
143+
trap cleanup EXIT
144+
docker compose -f tests/examples_cluster/docker-compose.yml up -d --wait
145+
/usr/local/bin/scylla-cpp-driver-smoke-test 172.43.0.2
146+
75147
- name: Collect artifacts
76148
run: |
77149
set -euo pipefail
78150
shopt -s nullglob
79151
mkdir -p artifacts/macos
80-
for file in build/*.pkg build/*.dmg; do
152+
for file in build/*.pkg build/*.dmg \
153+
packaging/smoke-test-app/build/*.pkg \
154+
packaging/smoke-test-app/build/*.dmg; do
81155
cp "$file" artifacts/macos/
82156
done
83157
@@ -121,6 +195,11 @@ jobs:
121195
"OPENSSL_LIB_DIR=$libPath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
122196
"OPENSSL_INCLUDE_DIR=$(Join-Path $opensslRoot 'include')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
123197
198+
- name: Install pkg-config
199+
shell: pwsh
200+
run: |
201+
choco install pkgconfiglite --no-progress -y
202+
124203
- name: Configure
125204
shell: pwsh
126205
run: |
@@ -135,12 +214,77 @@ jobs:
135214
working-directory: build
136215
run: cpack -G WIX -C ${{ inputs.build-type }}
137216

217+
- name: Install driver package (MSI)
218+
shell: pwsh
219+
run: |
220+
$ErrorActionPreference = 'Stop'
221+
$packages = Get-ChildItem build -Filter *.msi
222+
if (-not $packages) {
223+
throw "No driver MSI packages produced"
224+
}
225+
foreach ($pkg in $packages) {
226+
$process = Start-Process msiexec.exe -ArgumentList "/i `"$($pkg.FullName)`" /qn /norestart" -Wait -PassThru
227+
if ($process.ExitCode -ne 0) {
228+
throw "Failed to install driver package $($pkg.Name): exit code $($process.ExitCode)"
229+
}
230+
}
231+
232+
- name: Build smoke-test application package
233+
shell: pwsh
234+
run: |
235+
$ErrorActionPreference = 'Stop'
236+
$env:PKG_CONFIG_PATH = "C:/Program Files/ScyllaDB/Scylla CPP Driver/lib/pkgconfig"
237+
cmake -S packaging/smoke-test-app -B packaging/smoke-test-app/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{ inputs.build-type }}
238+
cmake --build packaging/smoke-test-app/build --config ${{ inputs.build-type }}
239+
Push-Location packaging/smoke-test-app/build
240+
cpack -G WIX -C ${{ inputs.build-type }}
241+
Pop-Location
242+
243+
- name: Install smoke-test application package (MSI)
244+
shell: pwsh
245+
run: |
246+
$ErrorActionPreference = 'Stop'
247+
$packages = Get-ChildItem packaging/smoke-test-app/build -Filter *.msi
248+
if (-not $packages) {
249+
throw "No smoke-test MSI packages produced"
250+
}
251+
foreach ($pkg in $packages) {
252+
$process = Start-Process msiexec.exe -ArgumentList "/i `"$($pkg.FullName)`" /qn /norestart" -Wait -PassThru
253+
if ($process.ExitCode -ne 0) {
254+
throw "Failed to install smoke-test package $($pkg.Name): exit code $($process.ExitCode)"
255+
}
256+
}
257+
258+
- name: Run smoke-test application against local Scylla
259+
shell: pwsh
260+
run: |
261+
$ErrorActionPreference = 'Stop'
262+
$composeFile = "tests/examples_cluster/docker-compose.yml"
263+
function Cleanup {
264+
docker compose -f $composeFile down --remove-orphans | Out-Null
265+
}
266+
try {
267+
$dockerService = Get-Service -Name docker -ErrorAction SilentlyContinue
268+
if ($dockerService -and $dockerService.Status -ne 'Running') {
269+
Start-Service docker
270+
}
271+
docker compose -f $composeFile up -d --wait
272+
$smokePath = "C:\Program Files\ScyllaDB\Scylla CPP Driver Smoke Test\bin\scylla-cpp-driver-smoke-test.exe"
273+
if (-not (Test-Path $smokePath)) {
274+
throw "Smoke-test binary not found at $smokePath"
275+
}
276+
& $smokePath 172.43.0.2
277+
} finally {
278+
Cleanup
279+
}
280+
138281
- name: Collect artifacts
139282
if: inputs.save-artifacts
140283
shell: pwsh
141284
run: |
142285
New-Item -ItemType Directory -Path artifacts\windows -Force | Out-Null
143286
Get-ChildItem build -Filter *.msi | Copy-Item -Destination artifacts\windows
287+
Get-ChildItem packaging/smoke-test-app/build -Filter *.msi | Copy-Item -Destination artifacts\windows
144288
145289
- uses: actions/upload-artifact@v4
146290
if: inputs.save-artifacts
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(scylla_cpp_driver_smoke_app LANGUAGES C)
3+
4+
# Derive driver version information from the root header so the smoke-app
5+
# package stays in lockstep with the driver packages.
6+
get_filename_component(CPP_DRIVER_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
7+
get_filename_component(CPP_DRIVER_ROOT "${CPP_DRIVER_ROOT}/.." ABSOLUTE)
8+
set(CASS_INCLUDE_DIR "${CPP_DRIVER_ROOT}/include")
9+
10+
file(STRINGS "${CASS_INCLUDE_DIR}/cassandra.h" _VERSION_PARTS
11+
REGEX "^#define[ \t]+CASS_VERSION_(MAJOR|MINOR|PATCH|SUFFIX)[ \t]+([0-9]+|\"([^\"]+)\")$")
12+
13+
foreach(part MAJOR MINOR PATCH SUFFIX)
14+
string(REGEX MATCH "CASS_VERSION_${part}[ \t]+([0-9]+|\"([^\"]+)\")"
15+
PROJECT_VERSION_${part} "${_VERSION_PARTS}")
16+
if(PROJECT_VERSION_${part})
17+
string(REGEX REPLACE "CASS_VERSION_${part}[ \t]+([0-9]+|\"([^\"]+)\")" "\\1"
18+
PROJECT_VERSION_${part} "${PROJECT_VERSION_${part}}")
19+
endif()
20+
endforeach()
21+
22+
if(NOT PROJECT_VERSION_MAJOR OR NOT PROJECT_VERSION_MINOR)
23+
message(FATAL_ERROR "Unable to extract driver version from cassandra.h")
24+
endif()
25+
26+
set(PROJECT_VERSION_STRING
27+
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
28+
if(NOT PROJECT_VERSION_PATCH STREQUAL "")
29+
set(PROJECT_VERSION_STRING
30+
"${PROJECT_VERSION_STRING}.${PROJECT_VERSION_PATCH}")
31+
endif()
32+
if(NOT PROJECT_VERSION_SUFFIX STREQUAL "")
33+
string(REPLACE "\"" ""
34+
PROJECT_VERSION_SUFFIX ${PROJECT_VERSION_SUFFIX})
35+
set(PROJECT_VERSION_STRING
36+
"${PROJECT_VERSION_STRING}-${PROJECT_VERSION_SUFFIX}")
37+
endif()
38+
39+
set(CMAKE_C_STANDARD 11)
40+
set(CMAKE_C_STANDARD_REQUIRED ON)
41+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
42+
43+
find_package(PkgConfig)
44+
if(PKG_CONFIG_FOUND)
45+
pkg_check_modules(SCYLLA_CPP_DRIVER scylla-cpp-driver)
46+
endif()
47+
48+
set(DRIVER_INCLUDE_DIRS "")
49+
set(DRIVER_LIBRARY_DIRS "")
50+
set(DRIVER_LIBRARIES "")
51+
set(DRIVER_COMPILE_OPTIONS "")
52+
set(DRIVER_LINK_OPTIONS "")
53+
54+
if(PKG_CONFIG_FOUND AND SCYLLA_CPP_DRIVER_FOUND)
55+
list(APPEND DRIVER_INCLUDE_DIRS ${SCYLLA_CPP_DRIVER_INCLUDE_DIRS})
56+
list(APPEND DRIVER_LIBRARY_DIRS ${SCYLLA_CPP_DRIVER_LIBRARY_DIRS})
57+
list(APPEND DRIVER_LIBRARIES ${SCYLLA_CPP_DRIVER_LIBRARIES})
58+
list(APPEND DRIVER_COMPILE_OPTIONS ${SCYLLA_CPP_DRIVER_CFLAGS_OTHER})
59+
list(APPEND DRIVER_LINK_OPTIONS ${SCYLLA_CPP_DRIVER_LDFLAGS_OTHER})
60+
endif()
61+
62+
if(NOT PKG_CONFIG_FOUND OR NOT SCYLLA_CPP_DRIVER_FOUND)
63+
if(NOT DEFINED SCYLLA_CPP_DRIVER_ROOT AND DEFINED ENV{SCYLLA_CPP_DRIVER_ROOT})
64+
set(SCYLLA_CPP_DRIVER_ROOT "$ENV{SCYLLA_CPP_DRIVER_ROOT}")
65+
endif()
66+
if(NOT DEFINED SCYLLA_CPP_DRIVER_ROOT)
67+
if(WIN32)
68+
set(SCYLLA_CPP_DRIVER_ROOT "C:/Program Files/ScyllaDB/Scylla CPP Driver")
69+
elseif(APPLE)
70+
set(SCYLLA_CPP_DRIVER_ROOT "/usr/local")
71+
else()
72+
set(SCYLLA_CPP_DRIVER_ROOT "/usr")
73+
endif()
74+
endif()
75+
76+
find_path(SCYLLA_CPP_DRIVER_INCLUDE_DIR cassandra.h
77+
PATHS
78+
"${SCYLLA_CPP_DRIVER_ROOT}/include"
79+
PATH_SUFFIXES
80+
""
81+
"cassandra"
82+
"x86_64-linux-gnu"
83+
"x86_64-linux-gnu/cassandra")
84+
85+
find_library(SCYLLA_CPP_DRIVER_LIBRARY
86+
NAMES scylla-cpp-driver
87+
PATHS
88+
"${SCYLLA_CPP_DRIVER_ROOT}/lib"
89+
"${SCYLLA_CPP_DRIVER_ROOT}/lib64"
90+
"${SCYLLA_CPP_DRIVER_ROOT}/lib/x86_64-linux-gnu"
91+
"${SCYLLA_CPP_DRIVER_ROOT}/lib64/x86_64-linux-gnu")
92+
93+
if(NOT SCYLLA_CPP_DRIVER_INCLUDE_DIR OR NOT SCYLLA_CPP_DRIVER_LIBRARY)
94+
message(FATAL_ERROR
95+
"Unable to locate scylla-cpp-driver installation. Set SCYLLA_CPP_DRIVER_ROOT "
96+
"or install pkg-config so the package can be discovered automatically.")
97+
endif()
98+
99+
set(SCYLLA_CPP_DRIVER_FOUND TRUE)
100+
set(DRIVER_INCLUDE_DIRS ${SCYLLA_CPP_DRIVER_INCLUDE_DIR})
101+
get_filename_component(_driver_library_dir ${SCYLLA_CPP_DRIVER_LIBRARY} DIRECTORY)
102+
set(DRIVER_LIBRARY_DIRS ${_driver_library_dir})
103+
set(DRIVER_LIBRARIES ${SCYLLA_CPP_DRIVER_LIBRARY})
104+
endif()
105+
106+
add_executable(scylla-cpp-driver-smoke-test
107+
src/smoke_test.c)
108+
109+
if(DRIVER_INCLUDE_DIRS)
110+
target_include_directories(scylla-cpp-driver-smoke-test PRIVATE
111+
${DRIVER_INCLUDE_DIRS})
112+
endif()
113+
114+
if(DRIVER_LIBRARY_DIRS)
115+
target_link_directories(scylla-cpp-driver-smoke-test PRIVATE
116+
${DRIVER_LIBRARY_DIRS})
117+
endif()
118+
119+
if(DRIVER_LIBRARIES)
120+
target_link_libraries(scylla-cpp-driver-smoke-test PRIVATE
121+
${DRIVER_LIBRARIES})
122+
endif()
123+
124+
if(DRIVER_COMPILE_OPTIONS)
125+
target_compile_options(scylla-cpp-driver-smoke-test PRIVATE
126+
${DRIVER_COMPILE_OPTIONS})
127+
endif()
128+
129+
if(DRIVER_LINK_OPTIONS)
130+
target_link_options(scylla-cpp-driver-smoke-test PRIVATE
131+
${DRIVER_LINK_OPTIONS})
132+
endif()
133+
134+
install(TARGETS scylla-cpp-driver-smoke-test DESTINATION bin)
135+
136+
#------------------------
137+
# Packaging (CPack)
138+
#------------------------
139+
140+
set(CPACK_PACKAGE_NAME "scylla-cpp-driver-smoke-app")
141+
set(CPACK_PACKAGE_VENDOR "ScyllaDB")
142+
set(CPACK_PACKAGE_CONTACT "ScyllaDB <info@scylladb.com>")
143+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
144+
"Smoke test application for scylla-cpp-driver binary packages")
145+
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/scylladb/cpp-rust-driver")
146+
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_STRING})
147+
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
148+
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
149+
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
150+
set(CPACK_VERBATIM_VARIABLES ON)
151+
set(CPACK_MONOLITHIC_INSTALL ON)
152+
153+
if(WIN32)
154+
set(CPACK_GENERATOR "WIX")
155+
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ScyllaDB\\Scylla CPP Driver Smoke Test")
156+
set(CPACK_WIX_UPGRADE_GUID "180C9F7E-8D90-40F1-A91E-9DE5DB451A80")
157+
elseif(APPLE)
158+
set(CPACK_GENERATOR "productbuild;DragNDrop")
159+
set(CPACK_RESOURCE_FILE_LICENSE "${CPP_DRIVER_ROOT}/LICENSE")
160+
set(CPACK_PACKAGE_FILE_NAME
161+
"scylla-cpp-driver-smoke-app-${PROJECT_VERSION_STRING}-macos")
162+
set(CPACK_PRODUCTBUILD_IDENTIFIER "com.scylladb.cpp-rust-driver.smoke-app")
163+
set(CPACK_PRODUCTBUILD_SIGNING_IDENTITY "")
164+
else()
165+
set(CPACK_GENERATOR "DEB;RPM")
166+
set(CPACK_RESOURCE_FILE_LICENSE "${CPP_DRIVER_ROOT}/LICENSE")
167+
set(CPACK_PACKAGE_FILE_NAME
168+
"scylla-cpp-driver-smoke-app-${PROJECT_VERSION_STRING}-${CMAKE_SYSTEM_NAME}")
169+
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
170+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ScyllaDB")
171+
set(CPACK_DEBIAN_PACKAGE_SECTION "database")
172+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL})
173+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
174+
set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0")
175+
set(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_HOMEPAGE_URL})
176+
set(CPACK_RPM_PACKAGE_RELEASE 1)
177+
set(CPACK_RPM_PACKAGE_GROUP "Applications/Databases")
178+
endif()
179+
180+
include(CPack)

0 commit comments

Comments
 (0)