Skip to content

Commit 06e74fc

Browse files
committed
ci: add database services for MSSQL testing
Add PostgreSQL, MySQL, and MSSQL as GitHub Actions services so they're ready before tests run. This avoids the timeout issues from pulling the large MSSQL image (~1.5GB) during test execution. Set environment variables so tests use the pre-started service databases instead of trying to start their own containers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 1764695 commit 06e74fc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,33 @@ jobs:
2424
GOARCH: ${{ matrix.goarch }}
2525
test:
2626
runs-on: ubuntu-24.04
27+
services:
28+
postgres:
29+
image: postgres:16
30+
env:
31+
POSTGRES_USER: postgres
32+
POSTGRES_PASSWORD: mysecretpassword
33+
POSTGRES_DB: postgres
34+
ports:
35+
- 5432:5432
36+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
37+
mysql:
38+
image: mysql:9
39+
env:
40+
MYSQL_DATABASE: dinotest
41+
MYSQL_ROOT_PASSWORD: mysecretpassword
42+
MYSQL_ROOT_HOST: '%'
43+
ports:
44+
- 3306:3306
45+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
46+
mssql:
47+
image: mcr.microsoft.com/mssql/server:2022-latest
48+
env:
49+
ACCEPT_EULA: Y
50+
MSSQL_SA_PASSWORD: MySecretPassword1!
51+
MSSQL_PID: Developer
52+
ports:
53+
- 1433:1433
2754
steps:
2855
- uses: actions/checkout@v6
2956
- uses: actions/setup-go@v6
@@ -58,6 +85,9 @@ jobs:
5885
CI_SQLC_AUTH_TOKEN: ${{ secrets.CI_SQLC_AUTH_TOKEN }}
5986
SQLC_AUTH_TOKEN: ${{ secrets.CI_SQLC_AUTH_TOKEN }}
6087
CGO_ENABLED: "0"
88+
POSTGRESQL_SERVER_URI: "postgres://postgres:mysecretpassword@localhost:5432/postgres?sslmode=disable"
89+
MYSQL_SERVER_URI: "root:mysecretpassword@tcp(localhost:3306)/dinotest?parseTime=true"
90+
MSSQL_SERVER_URI: "sqlserver://sa:MySecretPassword1!@localhost:1433?database=master"
6191

6292
vuln_check:
6393
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)