Skip to content

Commit 4b2d0ab

Browse files
Pierre-Luc GagnéCopilot
andcommitted
ci: merge into single job with MySQL service container and checkout@v6
- Merge unit-tests and integration-tests into a single 'tests' job so both run in the same environment (same runner, single checkout and build) - Unit tests step gates integration tests: if it fails, subsequent steps are skipped automatically - Replace manual Docker management with a GitHub Actions MySQL service container (fixed port 3306, TCP health check, auto-cleaned up) - Upgrade actions/checkout@v4 -> @v6 which runs on Node.js 24, fixing the 'Node.js 20 actions are deprecated' warning - Remove FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env var (no longer needed) - Install mysql-client alongside other deps in the single Install step - Use explicit CTest -R filter per test suite instead of running all Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 47c9b4a commit 4b2d0ab

1 file changed

Lines changed: 29 additions & 101 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,40 @@ on:
77
branches: [main]
88
workflow_dispatch:
99

10-
env:
11-
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
12-
1310
jobs:
14-
unit-tests:
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- uses: actions/checkout@v4
19-
20-
- name: Install dependencies
21-
run: |
22-
sudo apt-get update -q
23-
sudo apt-get install -y software-properties-common ca-certificates gpg wget
24-
# Kitware APT repo for CMake 3.31+
25-
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc \
26-
| gpg --dearmor \
27-
| sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null
28-
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' \
29-
| sudo tee /etc/apt/sources.list.d/kitware.list
30-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
31-
sudo apt-get update -q
32-
sudo apt-get install -y cmake ninja-build g++-15 \
33-
libmysqlclient-dev pkg-config
34-
35-
- name: Configure
36-
run: cmake --preset release -DSKIP_DOCKER_MANAGEMENT=ON -DBUILD_INTEGRATION_TESTS=OFF
37-
env:
38-
CXX: g++-15
39-
CC: gcc-15
40-
41-
- name: Build
42-
run: cmake --build build -j$(nproc)
43-
44-
- name: Test
45-
run: ctest --preset release
46-
47-
integration-tests:
48-
needs: unit-tests
11+
tests:
4912
runs-on: ubuntu-latest
5013

5114
env:
5215
DS_MYSQL_TEST_HOST: 127.0.0.1
16+
DS_MYSQL_TEST_PORT: 3306
5317
DS_MYSQL_TEST_DATABASE: ds_mysql_test
5418
DS_MYSQL_TEST_USER: ds_mysql_test_user
5519
DS_MYSQL_TEST_PASSWORD: ds_mysql_test_password
5620

21+
services:
22+
mysql:
23+
image: mysql:8.0
24+
env:
25+
MYSQL_ROOT_PASSWORD: root
26+
MYSQL_DATABASE: ds_mysql_test
27+
MYSQL_USER: ds_mysql_test_user
28+
MYSQL_PASSWORD: ds_mysql_test_password
29+
ports:
30+
- 3306:3306
31+
options: >-
32+
--health-cmd="mysqladmin ping -h 127.0.0.1 --protocol=tcp"
33+
--health-interval=5s
34+
--health-timeout=10s
35+
--health-retries=10
36+
5737
steps:
58-
- uses: actions/checkout@v4
38+
- uses: actions/checkout@v6
5939

6040
- name: Install dependencies
6141
run: |
6242
sudo apt-get update -q
63-
sudo apt-get install -y software-properties-common ca-certificates gpg wget
43+
sudo apt-get install -y software-properties-common ca-certificates gpg wget mysql-client
6444
# Kitware APT repo for CMake 3.31+
6545
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc \
6646
| gpg --dearmor \
@@ -72,74 +52,22 @@ jobs:
7252
sudo apt-get install -y cmake ninja-build g++-15 \
7353
libmysqlclient-dev pkg-config
7454
75-
- name: Start MySQL
76-
run: |
77-
CONTAINER_ID=$(docker run -d \
78-
-p 0:3306 \
79-
-e MYSQL_ROOT_PASSWORD=root \
80-
-e MYSQL_DATABASE=ds_mysql_test \
81-
-e MYSQL_USER=ds_mysql_test_user \
82-
-e MYSQL_PASSWORD=ds_mysql_test_password \
83-
--health-cmd="mysqladmin ping -h 127.0.0.1 --protocol=tcp" \
84-
--health-interval=5s \
85-
--health-timeout=10s \
86-
--health-retries=10 \
87-
mysql:8.0)
88-
echo "MYSQL_CONTAINER_ID=$CONTAINER_ID" >> "$GITHUB_ENV"
89-
PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "3306/tcp") 0).HostPort}}' "$CONTAINER_ID")
90-
echo "DS_MYSQL_TEST_PORT=$PORT" >> "$GITHUB_ENV"
91-
echo "Waiting for MySQL to be healthy..."
92-
for i in $(seq 1 30); do
93-
STATUS=$(docker inspect --format='{{.State.Health.Status}}' "$CONTAINER_ID")
94-
if [ "$STATUS" = "healthy" ]; then
95-
echo "MySQL is healthy on port $PORT"
96-
break
97-
fi
98-
if [ "$i" = "30" ]; then
99-
echo "MySQL did not become healthy in time"
100-
docker logs "$CONTAINER_ID"
101-
exit 1
102-
fi
103-
echo "Status: $STATUS, waiting... ($i/30)"
104-
sleep 5
105-
done
106-
107-
- name: Initialize database
108-
run: |
109-
sudo apt-get install -y mysql-client
110-
echo "Waiting for TCP connection on port $DS_MYSQL_TEST_PORT..."
111-
for i in $(seq 1 20); do
112-
if mysql -h 127.0.0.1 -P "$DS_MYSQL_TEST_PORT" -u root -proot \
113-
--connect-timeout=5 -e "SELECT 1" > /dev/null 2>&1; then
114-
echo "TCP connection established"
115-
break
116-
fi
117-
if [ "$i" = "20" ]; then
118-
echo "MySQL TCP port did not become available in time"
119-
exit 1
120-
fi
121-
echo "Waiting for TCP... ($i/20)"
122-
sleep 2
123-
done
124-
mysql -h 127.0.0.1 -P "$DS_MYSQL_TEST_PORT" -u root -proot \
125-
< tests/integration/docker/init-db.sql
126-
12755
- name: Configure
12856
run: cmake --preset release -DSKIP_DOCKER_MANAGEMENT=ON
12957
env:
13058
CXX: g++-15
13159
CC: gcc-15
13260

13361
- name: Build
134-
run: cmake --build build -j$(nproc)
62+
run: cmake --build build -j4
13563

136-
- name: Test
137-
run: ctest --preset release
64+
- name: Unit tests
65+
run: ctest --preset release -R tests_unit_ds_mysql
13866

139-
- name: Stop MySQL
140-
if: always()
67+
- name: Initialize database
14168
run: |
142-
if [ -n "$MYSQL_CONTAINER_ID" ]; then
143-
docker stop "$MYSQL_CONTAINER_ID"
144-
docker rm "$MYSQL_CONTAINER_ID"
145-
fi
69+
mysql -h 127.0.0.1 -P 3306 -u root -proot \
70+
< tests/integration/docker/init-db.sql
71+
72+
- name: Integration tests
73+
run: ctest --preset release -R tests_integration_ds_mysql

0 commit comments

Comments
 (0)