Skip to content

Commit 46d2c18

Browse files
committed
refactor: add db service in ci
1 parent 97c060b commit 46d2c18

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/go.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,41 @@ jobs:
1010

1111
build:
1212
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
db: ['MySQL', 'PostgreSQL']
16+
services:
17+
mysql:
18+
# Docker Hub image
19+
image: mysql:8
20+
env:
21+
MYSQL_ROOT_PASSWORD: test
22+
MYSQL_DATABASE: test
23+
MYSQL_USER: test
24+
MYSQL_PASSWORD: test
25+
# Set health checks to wait until mysql has started
26+
options: >-
27+
--health-cmd="mysqladmin ping"
28+
--health-interval 10s
29+
--health-timeout 5s
30+
--health-retries 5
31+
ports:
32+
- 3306:3306
33+
postgres:
34+
# Docker Hub image
35+
image: postgres:13.0
36+
env:
37+
POSTGRES_DB: testdb
38+
POSTGRES_USER: test
39+
POSTGRES_PASSWORD: test
40+
# Set health checks to wait until postgres has started
41+
options: >-
42+
--health-cmd pg_isready
43+
--health-interval 10s
44+
--health-timeout 5s
45+
--health-retries 5
46+
ports:
47+
- 5432:5432
1348
steps:
1449
- uses: actions/checkout@v3
1550

0 commit comments

Comments
 (0)