From 2ee4c3219d78c7970f5d9e50022c3900d872e7f4 Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:14:29 +0100 Subject: [PATCH 1/4] feat: add health checks to docker-compose and remove sleep from pipeline --- .github/workflows/tests.yml | 6 ++-- docker-compose.yml | 62 +++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c07f2a42..d2ba8b395 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,8 +57,7 @@ jobs: - name: Load and Start Services run: | docker load --input /tmp/${{ env.IMAGE }}.tar - docker compose up -d - sleep 10 + docker compose up -d --wait - name: Run Unit Tests run: docker compose exec tests vendor/bin/phpunit /usr/src/code/tests/unit @@ -101,8 +100,7 @@ jobs: - name: Load and Start Services run: | docker load --input /tmp/${{ env.IMAGE }}.tar - docker compose up -d - sleep 10 + docker compose up -d --wait - name: Run Tests run: docker compose exec -T tests vendor/bin/phpunit /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php --debug diff --git a/docker-compose.yml b/docker-compose.yml index 098d465ac..e6c68c5a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,16 @@ services: - ./docker-compose.yml:/usr/src/code/docker-compose.yml environment: PHP_IDE_CONFIG: serverName=tests + depends_on: + - postgres + - postgres-mirror + - mariadb + - mariadb-mirror + - mysql + - mysql-mirror + - redis + - redis-mirror + - mongo adminer: image: adminer @@ -44,6 +54,12 @@ services: POSTGRES_USER: root POSTGRES_PASSWORD: password POSTGRES_DB: root + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 5s postgres-mirror: build: @@ -60,6 +76,12 @@ services: POSTGRES_USER: root POSTGRES_PASSWORD: password POSTGRES_DB: root + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 5s mariadb: image: mariadb:10.11 @@ -71,6 +93,12 @@ services: - "8703:3306" environment: - MYSQL_ROOT_PASSWORD=password + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 mariadb-mirror: image: mariadb:10.11 @@ -82,6 +110,12 @@ services: - "8704:3306" environment: - MYSQL_ROOT_PASSWORD=password + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 mongo: image: mongo:8.0.14 @@ -110,10 +144,10 @@ services: \" 2>/dev/null || exit 1 fi " - interval: 10s + interval: 5s timeout: 10s retries: 10 - start_period: 30s + start_period: 10s mongo-express: image: mongo-express @@ -145,6 +179,12 @@ services: MYSQL_TCP_PORT: 3307 cap_add: - SYS_NICE + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u $$MYSQL_USER", "-p $$MYSQL_PASSWORD"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s mysql-mirror: image: mysql:8.0.43 @@ -161,6 +201,12 @@ services: MYSQL_TCP_PORT: 3307 cap_add: - SYS_NICE + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u $$MYSQL_USER", "-p $$MYSQL_PASSWORD"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s redis: image: redis:8.2.1-alpine3.22 @@ -169,6 +215,12 @@ services: - "8708:6379" networks: - database + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 5s redis-mirror: image: redis:8.2.1-alpine3.22 @@ -177,6 +229,12 @@ services: - "8709:6379" networks: - database + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 5s volumes: mongo-data: From 93071eb0fa181e176ae6ed1af7ef8b03b8ba4cbc Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:43:11 +0100 Subject: [PATCH 2/4] chore: set specific service_healthy condition on dependency Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docker-compose.yml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e6c68c5a7..4d4e8861d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,15 +20,24 @@ services: environment: PHP_IDE_CONFIG: serverName=tests depends_on: - - postgres - - postgres-mirror - - mariadb - - mariadb-mirror - - mysql - - mysql-mirror - - redis - - redis-mirror - - mongo + postgres: + condition: service_healthy + postgres-mirror: + condition: service_healthy + mariadb: + condition: service_healthy + mariadb-mirror: + condition: service_healthy + mysql: + condition: service_healthy + mysql-mirror: + condition: service_healthy + redis: + condition: service_healthy + redis-mirror: + condition: service_healthy + mongo: + condition: service_healthy adminer: image: adminer From 011e1fee91b22816684e5a1e853646995596f56e Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:44:24 +0100 Subject: [PATCH 3/4] chore: cleanup command mysql & mysql-mirror --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4d4e8861d..74eff6b2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -189,7 +189,7 @@ services: cap_add: - SYS_NICE healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u $$MYSQL_USER", "-p $$MYSQL_PASSWORD"] + test: ["CMD-SHELL", "mysqladmin ping -h localhost -u $$MYSQL_USER -p $$MYSQL_PASSWORD"] interval: 10s timeout: 5s retries: 5 @@ -211,7 +211,7 @@ services: cap_add: - SYS_NICE healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u $$MYSQL_USER", "-p $$MYSQL_PASSWORD"] + test: ["CMD-SHELL", "mysqladmin ping -h localhost -u $$MYSQL_USER -p $$MYSQL_PASSWORD"] interval: 10s timeout: 5s retries: 5 From be522328dbdbe0a0a6cc52013c715c5c744633b2 Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:55:56 +0100 Subject: [PATCH 4/4] chore: change back to previous healthcheck --- .github/workflows/tests.yml | 1 - docker-compose.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2ba8b395..386d728b6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -104,4 +104,3 @@ jobs: - name: Run Tests run: docker compose exec -T tests vendor/bin/phpunit /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php --debug - diff --git a/docker-compose.yml b/docker-compose.yml index 74eff6b2b..4d4e8861d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -189,7 +189,7 @@ services: cap_add: - SYS_NICE healthcheck: - test: ["CMD-SHELL", "mysqladmin ping -h localhost -u $$MYSQL_USER -p $$MYSQL_PASSWORD"] + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u $$MYSQL_USER", "-p $$MYSQL_PASSWORD"] interval: 10s timeout: 5s retries: 5 @@ -211,7 +211,7 @@ services: cap_add: - SYS_NICE healthcheck: - test: ["CMD-SHELL", "mysqladmin ping -h localhost -u $$MYSQL_USER -p $$MYSQL_PASSWORD"] + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u $$MYSQL_USER", "-p $$MYSQL_PASSWORD"] interval: 10s timeout: 5s retries: 5