@@ -11,33 +11,50 @@ jobs:
11
11
run-tests :
12
12
strategy :
13
13
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 ]
16
16
runs-on : ubuntu-latest
17
+
18
+ env :
19
+ MSSQL_DB : gorm
20
+ MSSQL_USER : gorm
21
+ MSSQL_PASSWORD : LoremIpsum86
22
+
17
23
services :
18
24
mssql :
19
- image : mcmoe/mssqldocker: latest
25
+ image : mcr.microsoft.com/mssql/server:2022- latest
20
26
env :
21
27
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
26
30
ports :
27
31
- 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
28
38
29
39
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
34
48
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}];"
37
54
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 .
41
58
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