Skip to content

Commit f085e19

Browse files
Pierre-Luc GagnéCopilot
andcommitted
ci: add parallel Clang and MSVC validation jobs
CMake changes: - Add MSVC compiler flags (/W4 /WX /permissive-) alongside GCC/Clang flags - Add cross-platform MySQL detection: pkg-config on Linux/macOS, find_path/find_library on Windows (auto-detects MySQL Server install, override with -DMYSQL_ROOT_DIR=<path>) - Consolidate lib/CMakeLists.txt: remove duplicate target_* calls and invalid VERSION property on INTERFACE target - Remove spurious find_package(PkgConfig) from tests/unit/CMakeLists.txt CI workflow: - Rename 'tests' -> 'tests-gcc' (GCC, ubuntu, unit + integration) - Add 'tests-clang' (Clang 15, ubuntu, unit tests only, runs in parallel) - Add 'tests-msvc' (MSVC VS17 2022, windows-latest, unit tests only, runs in parallel); detects MySQL root dir from Program Files and adds lib dir to PATH for test runtime Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4b2d0ab commit f085e19

4 files changed

Lines changed: 102 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
tests:
11+
tests-gcc:
1212
runs-on: ubuntu-latest
1313

1414
env:
@@ -71,3 +71,73 @@ jobs:
7171
7272
- name: Integration tests
7373
run: ctest --preset release -R tests_integration_ds_mysql
74+
75+
tests-clang:
76+
runs-on: ubuntu-latest
77+
78+
steps:
79+
- uses: actions/checkout@v6
80+
81+
- name: Install dependencies
82+
run: |
83+
sudo apt-get update -q
84+
sudo apt-get install -y software-properties-common ca-certificates gpg wget
85+
# Kitware APT repo for CMake 3.31+
86+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc \
87+
| gpg --dearmor \
88+
| sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null
89+
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' \
90+
| sudo tee /etc/apt/sources.list.d/kitware.list
91+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
92+
sudo apt-get update -q
93+
sudo apt-get install -y cmake ninja-build clang-15 \
94+
libmysqlclient-dev pkg-config
95+
96+
- name: Configure
97+
run: cmake --preset release -DSKIP_DOCKER_MANAGEMENT=ON -DBUILD_INTEGRATION_TESTS=OFF -DBUILD_EXAMPLES=OFF
98+
env:
99+
CXX: clang++-15
100+
CC: clang-15
101+
102+
- name: Build
103+
run: cmake --build build -j4
104+
105+
- name: Unit tests
106+
run: ctest --preset release -R tests_unit_ds_mysql
107+
108+
tests-msvc:
109+
runs-on: windows-latest
110+
111+
steps:
112+
- uses: actions/checkout@v6
113+
114+
- name: Install dependencies
115+
run: |
116+
choco install cmake ninja --no-progress -y
117+
shell: pwsh
118+
119+
- name: Detect MySQL root
120+
shell: pwsh
121+
run: |
122+
$dirs = Get-ChildItem "C:\Program Files\MySQL" -Directory -ErrorAction SilentlyContinue |
123+
Where-Object { $_.Name -like "MySQL Server *" } |
124+
Sort-Object Name -Descending
125+
if (-not $dirs) { throw "MySQL installation not found" }
126+
$root = $dirs[0].FullName
127+
echo "MYSQL_ROOT_DIR=$root" >> $env:GITHUB_ENV
128+
echo "$root\lib" >> $env:GITHUB_PATH
129+
130+
- name: Configure
131+
shell: pwsh
132+
run: |
133+
cmake -B build `
134+
-G "Visual Studio 17 2022" -A x64 `
135+
-DBUILD_INTEGRATION_TESTS=OFF `
136+
-DBUILD_EXAMPLES=OFF `
137+
"-DMYSQL_ROOT_DIR=$env:MYSQL_ROOT_DIR"
138+
139+
- name: Build
140+
run: cmake --build build --config Release -j4
141+
142+
- name: Unit tests
143+
run: ctest --build-dir build -C Release -R tests_unit_ds_mysql --output-on-failure

CMakeLists.txt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
4141
-Wpedantic
4242
-Werror
4343
)
44+
elseif(MSVC)
45+
add_compile_options(
46+
/W4 # High warning level
47+
/WX # Warnings as errors
48+
/permissive- # Strict standards conformance
49+
)
4450
endif()
4551

4652
# Coverage flags
@@ -61,8 +67,30 @@ include(FetchContent)
6167
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
6268

6369
# MySQL client library
64-
find_package(PkgConfig REQUIRED)
65-
pkg_check_modules(MYSQL REQUIRED mysqlclient)
70+
if(WIN32)
71+
# On Windows, search common MySQL Server installation paths.
72+
# Override by passing -DMYSQL_ROOT_DIR=<path> to cmake.
73+
set(MYSQL_ROOT_DIR "" CACHE PATH "MySQL installation root (e.g. C:/Program Files/MySQL/MySQL Server 8.0)")
74+
if(NOT MYSQL_ROOT_DIR)
75+
file(GLOB _mysql_dirs "C:/Program Files/MySQL/MySQL Server *")
76+
if(_mysql_dirs)
77+
list(SORT _mysql_dirs ORDER DESCENDING)
78+
list(GET _mysql_dirs 0 MYSQL_ROOT_DIR)
79+
set(MYSQL_ROOT_DIR "${MYSQL_ROOT_DIR}" CACHE PATH "" FORCE)
80+
else()
81+
message(FATAL_ERROR "MySQL not found. Set -DMYSQL_ROOT_DIR=<path> to the MySQL installation directory.")
82+
endif()
83+
endif()
84+
85+
find_path(MYSQL_INCLUDE_DIR mysql.h PATHS "${MYSQL_ROOT_DIR}/include" NO_DEFAULT_PATH REQUIRED)
86+
find_library(MYSQL_LIBRARY libmysql PATHS "${MYSQL_ROOT_DIR}/lib" NO_DEFAULT_PATH REQUIRED)
87+
set(MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIR}")
88+
set(MYSQL_LIBRARIES "${MYSQL_LIBRARY}")
89+
message(STATUS "MySQL found at: ${MYSQL_ROOT_DIR}")
90+
else()
91+
find_package(PkgConfig REQUIRED)
92+
pkg_check_modules(MYSQL REQUIRED mysqlclient)
93+
endif()
6694

6795
# Note: Boost.PFR is header-only and doesn't have a standard CMake config package yet,
6896
# so we fetch it directly without find_package. Once Boost.PFR is officially integrated

lib/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,11 @@ target_include_directories(ds_mysql
77
INTERFACE
88
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
99
$<INSTALL_INTERFACE:include>
10-
)
11-
12-
target_link_libraries(ds_mysql
13-
INTERFACE
14-
Boost::pfr
15-
)
16-
17-
target_include_directories(ds_mysql
18-
INTERFACE
1910
${MYSQL_INCLUDE_DIRS}
2011
)
2112

2213
target_link_libraries(ds_mysql
2314
INTERFACE
15+
Boost::pfr
2416
${MYSQL_LIBRARIES}
2517
)
26-
27-
# Set library properties
28-
set_target_properties(ds_mysql PROPERTIES
29-
VERSION ${PROJECT_VERSION}
30-
)

tests/unit/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ if(NOT TARGET Boost::ut)
1414
FetchContent_MakeAvailable(boost_ut)
1515
endif()
1616

17-
find_package(PkgConfig REQUIRED)
18-
1917
add_executable(tests_unit_ds_mysql
2018
main.cpp
2119
test_ddl.cpp

0 commit comments

Comments
 (0)