forked from longbridgeapp/gorm-sharding
-
-
Notifications
You must be signed in to change notification settings - Fork 59
185 lines (159 loc) · 5.41 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Tests
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
jobs:
postgres:
strategy:
matrix:
dbversion:
[
"postgres:latest",
"postgres:13",
"postgres:12",
"postgres:11",
"postgres:10",
]
platform: [ubuntu-latest] # can not run in macOS and Windows
runs-on: ${{ matrix.platform }}
services:
postgres:
image: ${{ matrix.dbversion }}
env:
POSTGRES_DB: sharding-test
POSTGRES_USER: gorm
POSTGRES_PASSWORD: gorm
TZ: Asia/Shanghai
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DIALECTOR: postgres
DB_URL: postgres://gorm:gorm@localhost:5432/sharding-test
DB_NOID_URL: postgres://gorm:gorm@localhost:5432/sharding-noid-test
DB_READ_URL: postgres://gorm:gorm@localhost:5432/sharding-read-test
DB_WRITE_URL: postgres://gorm:gorm@localhost:5432/sharding-write-test
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go
- name: Create No ID Database
run: PGPASSWORD=gorm psql -h localhost -U gorm -d sharding-test -c 'CREATE DATABASE "sharding-noid-test";'
- name: Create Read Database
run: PGPASSWORD=gorm psql -h localhost -U gorm -d sharding-test -c 'CREATE DATABASE "sharding-read-test";'
- name: Create Write Databases
run: PGPASSWORD=gorm psql -h localhost -U gorm -d sharding-test -c 'CREATE DATABASE "sharding-write-test";'
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: go test
mysql:
name: MySQL
strategy:
matrix:
dbversion: ["mysql:latest", "mysql:5.7"]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
services:
mysql:
image: ${{ matrix.dbversion }}
env:
MYSQL_DATABASE: sharding-test
MYSQL_USER: gorm
MYSQL_PASSWORD: gorm
MYSQL_ROOT_PASSWORD: gorm
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ugorm -pgorm"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
env:
DIALECTOR: mysql
DB_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-test?charset=utf8mb4&parseTime=True&loc=Local
DB_NOID_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-noid-test?charset=utf8mb4&parseTime=True&loc=Local
DB_READ_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-read-test?charset=utf8mb4&parseTime=True&loc=Local
DB_WRITE_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-write-test?charset=utf8mb4&parseTime=True&loc=Local
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go
- name: Create No ID Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-noid-test
- name: Create Read Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-read-test
- name: Create Write Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-write-test
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: go test
mariadb:
name: MariaDB
strategy:
matrix:
dbversion: ["mariadb:10.11"]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
services:
mariadb:
image: ${{ matrix.dbversion }}
env:
MYSQL_DATABASE: sharding-test
MYSQL_USER: gorm
MYSQL_PASSWORD: gorm
MYSQL_ROOT_PASSWORD: gorm
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ugorm -pgorm"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
env:
DIALECTOR: mariadb
DB_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-test?charset=utf8mb4&parseTime=True&loc=Local
DB_NOID_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-noid-test?charset=utf8mb4&parseTime=True&loc=Local
DB_READ_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-read-test?charset=utf8mb4&parseTime=True&loc=Local
DB_WRITE_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-write-test?charset=utf8mb4&parseTime=True&loc=Local
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go
- name: Create No ID Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-noid-test
- name: Create Read Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-read-test
- name: Create Write Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-write-test
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: go test