Skip to content

Commit 806fcf7

Browse files
committed
ci: fix failed to initialize container mcmoe/mssqldocker:latest
1 parent 64af933 commit 806fcf7

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

.github/workflows/tests.yml

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,50 @@ jobs:
1111
run-tests:
1212
strategy:
1313
matrix:
14-
go: ['1.21', '1.20', '1.19']
15-
platform: [ubuntu-latest]
14+
go: [ '1.21', '1.20', '1.19' ]
15+
platform: [ ubuntu-latest ]
1616
runs-on: ubuntu-latest
17+
18+
env:
19+
MSSQL_DB: gorm
20+
MSSQL_USER: gorm
21+
MSSQL_PASSWORD: LoremIpsum86
22+
1723
services:
1824
mssql:
19-
image: mcmoe/mssqldocker:latest
25+
image: mcr.microsoft.com/mssql/server:2022-latest
2026
env:
2127
ACCEPT_EULA: Y
22-
SA_PASSWORD: LoremIpsum86
23-
MSSQL_DB: gorm
24-
MSSQL_USER: gorm
25-
MSSQL_PASSWORD: LoremIpsum86
28+
MSSQL_SA_PASSWORD: ${{ env.MSSQL_PASSWORD }}
29+
MSSQL_PID: Developer
2630
ports:
2731
- 9930:1433
32+
options: >-
33+
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -N -C -l 30 -Q \"SELECT 1\" || exit 1"
34+
--health-start-period 10s
35+
--health-interval 5s
36+
--health-timeout 10s
37+
--health-retries 10
2838
2939
steps:
30-
- name: Set up Go 1.x
31-
uses: actions/setup-go@v4
32-
with:
33-
go-version: ${{ matrix.go }}
40+
- name: Set up Go 1.x
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version: ${{ matrix.go }}
44+
cache: false
45+
46+
- name: Check out code into the Go module directory
47+
uses: actions/checkout@v4
3448

35-
- name: Check out code into the Go module directory
36-
uses: actions/checkout@v4
49+
- name: Create gorm database and user in SQL Server
50+
run: |
51+
docker exec $(docker ps --filter "name=sqlserver" --format "{{.Names}}") \
52+
/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_PASSWORD} -N -C -l 30 \
53+
-Q "CREATE DATABASE ${MSSQL_DB}; CREATE LOGIN ${MSSQL_USER} WITH PASSWORD='${MSSQL_PASSWORD}'; CREATE USER ${MSSQL_USER} FOR LOGIN ${MSSQL_USER}; ALTER SERVER ROLE sysadmin ADD MEMBER [${MSSQL_USER}];"
3754
38-
# Run build of the application
39-
- name: Run build
40-
run: go build .
55+
# Run build of the application
56+
- name: Run build
57+
run: go build .
4158

42-
- name: Run tests
43-
run: go test -race -count=1 -v ./...
59+
- name: Run tests
60+
run: go test -race -count=1 -v ./...

0 commit comments

Comments
 (0)