[PR #8010] [MERGED] chore(ci): add Docker Compose healthchecks for faster CI service readiness #7686

Closed
opened 2026-03-13 13:45:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8010
Author: @starslingdev[bot]
Created: 2/16/2026
Status: Merged
Merged: 2/16/2026
Merged by: @Bekacru

Base: canaryHead: starsling/docker-healthchecks


📝 Commits (1)

  • 188f4ce chore(ci): add Docker Compose healthchecks for faster CI service readiness

📊 Changes

3 files changed (+49 additions, -20 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -4)
📝 .github/workflows/e2e.yml (+3 -12)
📝 docker-compose.yml (+45 -4)

📄 Description

chore(ci): add Docker Compose healthchecks for faster CI service readiness

CI currently waits for services using a hard-coded sleep 10 after docker compose up -d (in ci.yml and e2e.yml). This:

  • Adds ~10s per job even when 10 DB services are ready in 2–5s
  • Is pure overhead on StarSling runners (containers are already warm)
  • Relies on time-based guessing instead of actual readiness

Fix

  • Add healthcheck to all DB services in docker-compose.yml.
  • Replace sleeps with: docker compose up -d --wait --wait-timeout 60

This makes startup event-driven: the step exits as soon as all services are accepting connections.

  • Warm runners: ~0s wait
  • Cold starts: ~5s (bounded by MySQL)

Healthchecks
All use interval: 1s, timeout: 5s. Engine-specific tuning:

  • MySQL: start_period: 30s (slow data-dir init in CI)
  • MSSQL: start_period: 5s
Service Probe Notes
Postgres (×4) pg_isready -U user -d better_auth Built-in
MySQL (×3) mysqladmin ping -h 127.0.0.1 Forces TCP to avoid init-only Unix socket trap
MongoDB mongosh --eval "db.adminCommand('ping')" Admin ping, no collection access
Redis redis-cli ping Inline PING/PONG
MSSQL sqlcmd -C -S localhost -Q 'SELECT 1' TCP query (-C bypasses TLS)

Removes fixed sleeps, reduces CI time, and guarantees true readiness.

Changes

  • .github/workflows/ci.yml
  • .github/workflows/e2e.yml
  • docker-compose.yml

References


Summary by cubic

Replace fixed sleeps in CI with Docker Compose healthchecks and --wait so tests start as soon as services are ready. This removes ~10s of idle time per job and makes startup reliable on warm and cold runners.

  • Refactors
    • Added healthchecks in docker-compose for Postgres (pg_isready), MySQL (mysqladmin ping via 127.0.0.1), MongoDB (mongosh ping), Redis (redis-cli ping), MSSQL (sqlcmd SELECT 1).
    • Tuned timing: interval 1s, timeout 5s, retries 10; MySQL start_period 30s; MSSQL start_period 5s.
    • Replaced sleep 10 with docker compose up -d --wait --wait-timeout 60 in ci.yml and e2e.yml.

Written for commit 188f4ce583. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8010 **Author:** [@starslingdev[bot]](https://github.com/apps/starslingdev) **Created:** 2/16/2026 **Status:** ✅ Merged **Merged:** 2/16/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `starsling/docker-healthchecks` --- ### 📝 Commits (1) - [`188f4ce`](https://github.com/better-auth/better-auth/commit/188f4ce58347d69ce22ba2cae1bffdf6cdf1e891) chore(ci): add Docker Compose healthchecks for faster CI service readiness ### 📊 Changes **3 files changed** (+49 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -4) 📝 `.github/workflows/e2e.yml` (+3 -12) 📝 `docker-compose.yml` (+45 -4) </details> ### 📄 Description ## chore(ci): add Docker Compose healthchecks for faster CI service readiness CI currently waits for services using a hard-coded `sleep 10` after `docker compose up -d` (in [`ci.yml`](https://github.com/better-auth/better-auth/blob/d3b579e42a707a9037a9210ad14611366b745d2a/.github/workflows/ci.yml#L163-L165) and [`e2e.yml`](https://github.com/better-auth/better-auth/blob/d3b579e42a707a9037a9210ad14611366b745d2a/.github/workflows/e2e.yml#L51-L53)). This: * Adds ~10s per job even when 10 DB services are ready in 2–5s * Is pure overhead on StarSling runners (containers are already warm) * Relies on time-based guessing instead of actual readiness ### Fix * Add `healthcheck` to all DB services in `docker-compose.yml`. * Replace sleeps with: `docker compose up -d --wait --wait-timeout 60` This makes startup event-driven: the step exits as soon as all services are accepting connections. * **Warm runners:** ~0s wait * **Cold starts:** ~5s (bounded by MySQL) **Healthchecks** All use `interval: 1s`, `timeout: 5s`. Engine-specific tuning: * **MySQL:** `start_period: 30s` (slow data-dir init in CI) * **MSSQL:** `start_period: 5s` | Service | Probe | Notes | | --- | --- | --- | | **Postgres** (×4) | `pg_isready -U user -d better_auth` | Built-in | | **MySQL** (×3) | `mysqladmin ping -h 127.0.0.1` | Forces TCP to avoid init-only Unix socket trap | | **MongoDB** | `mongosh --eval "db.adminCommand('ping')"` | Admin ping, no collection access | | **Redis** | `redis-cli ping` | Inline PING/PONG | | **MSSQL** | `sqlcmd -C -S localhost -Q 'SELECT 1'` | TCP query (`-C` bypasses TLS) | Removes fixed sleeps, reduces CI time, and guarantees true readiness. ### Changes - `.github/workflows/ci.yml` - `.github/workflows/e2e.yml` - `docker-compose.yml` ### References - [`docker compose up --wait`](https://docs.docker.com/reference/cli/docker/compose/up/) — blocks until all containers with healthchecks report healthy - [Compose `healthcheck`](https://docs.docker.com/reference/compose-file/services/#healthcheck) — `test`, `interval`, `timeout`, `retries`, `start_period` reference - [`pg_isready`](https://www.postgresql.org/docs/current/app-pg-isready.html) — Postgres connection check utility - [`mysqladmin ping`](https://dev.mysql.com/doc/refman/en/mysqladmin.html) — lightweight MySQL liveness check - [MySQL `--skip-networking` during init](https://dev.mysql.com/doc/refman/en/server-system-variables.html#sysvar_skip_networking) — why TCP (`127.0.0.1`) is required over Unix socket (`localhost`) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Replace fixed sleeps in CI with Docker Compose healthchecks and --wait so tests start as soon as services are ready. This removes ~10s of idle time per job and makes startup reliable on warm and cold runners. - **Refactors** - Added healthchecks in docker-compose for Postgres (pg_isready), MySQL (mysqladmin ping via 127.0.0.1), MongoDB (mongosh ping), Redis (redis-cli ping), MSSQL (sqlcmd SELECT 1). - Tuned timing: interval 1s, timeout 5s, retries 10; MySQL start_period 30s; MSSQL start_period 5s. - Replaced sleep 10 with docker compose up -d --wait --wait-timeout 60 in ci.yml and e2e.yml. <sup>Written for commit 188f4ce58347d69ce22ba2cae1bffdf6cdf1e891. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:45:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7686