Skip to content

Commit c6ac548

Browse files
authored
Use official SQL Server docker image for tests (#7205)
* Use official SQL Server docker image for tests * Try with tag 2019-latest instead of latest * Use platform ubuntu-20.04 for SQL Server * Switch to 2019-CU18-ubuntu-20.04 * Check with 2022-latest image tag and ubuntu-latest platform * Update health-cmd * Try sqlcmd without -N -C * Re-include -N -C, try with ubuntu-20.04 * Try ubuntu-20.04 without -N -C (last trial) * Finalize working config * Remove unused env variables
1 parent 68434b7 commit c6ac548

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

.github/workflows/tests.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,15 @@ jobs:
176176

177177
services:
178178
mssql:
179-
image: mcmoe/mssqldocker:latest
179+
image: mcr.microsoft.com/mssql/server:2022-latest
180180
env:
181+
TZ: Asia/Shanghai
181182
ACCEPT_EULA: Y
182-
SA_PASSWORD: LoremIpsum86
183-
MSSQL_DB: gorm
184-
MSSQL_USER: gorm
185-
MSSQL_PASSWORD: LoremIpsum86
183+
MSSQL_SA_PASSWORD: LoremIpsum86
186184
ports:
187185
- 9930:1433
188186
options: >-
189-
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
187+
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -N -C -l 30 -Q \"SELECT 1\" || exit 1"
190188
--health-start-period 10s
191189
--health-interval 10s
192190
--health-timeout 5s
@@ -208,7 +206,7 @@ jobs:
208206
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }}
209207

210208
- name: Tests
211-
run: GITHUB_ACTION=true GORM_DIALECT=sqlserver GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh
209+
run: GITHUB_ACTION=true GORM_DIALECT=sqlserver GORM_DSN="sqlserver://sa:LoremIpsum86@localhost:9930?database=master" ./tests/tests_all.sh
212210

213211
tidb:
214212
strategy:

tests/compose.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ services:
1818
- POSTGRES_USER=gorm
1919
- POSTGRES_PASSWORD=gorm
2020
mssql:
21-
image: '${MSSQL_IMAGE:-mcmoe/mssqldocker}:latest'
21+
image: '${MSSQL_IMAGE}:2022-latest'
2222
ports:
2323
- "127.0.0.1:9930:1433"
2424
environment:
2525
- TZ=Asia/Shanghai
2626
- ACCEPT_EULA=Y
27-
- SA_PASSWORD=LoremIpsum86
28-
- MSSQL_DB=gorm
29-
- MSSQL_USER=gorm
30-
- MSSQL_PASSWORD=LoremIpsum86
27+
- MSSQL_SA_PASSWORD=LoremIpsum86
3128
tidb:
3229
image: 'pingcap/tidb:v6.5.0'
3330
ports:

tests/tests_all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if [[ -z $GITHUB_ACTION ]]; then
2727
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF SUSER_ID (N'gorm') IS NULL CREATE LOGIN gorm WITH PASSWORD = 'LoremIpsum86';" > /dev/null || true
2828
SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF USER_ID (N'gorm') IS NULL CREATE USER gorm FROM LOGIN gorm; ALTER SERVER ROLE sysadmin ADD MEMBER [gorm];" > /dev/null || true
2929
else
30-
docker compose up -d
30+
MSSQL_IMAGE=mcr.microsoft.com/mssql/server docker compose up -d
3131
fi
3232
cd ..
3333
fi

tests/tests_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var DB *gorm.DB
2020
var (
2121
mysqlDSN = "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local"
2222
postgresDSN = "user=gorm password=gorm dbname=gorm host=localhost port=9920 sslmode=disable TimeZone=Asia/Shanghai"
23-
sqlserverDSN = "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm"
23+
sqlserverDSN = "sqlserver://sa:LoremIpsum86@localhost:9930?database=master"
2424
tidbDSN = "root:@tcp(localhost:9940)/test?charset=utf8&parseTime=True&loc=Local"
2525
)
2626

0 commit comments

Comments
 (0)