-
-
Notifications
You must be signed in to change notification settings - Fork 39
60 lines (50 loc) · 1.67 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
name: tests
on:
push:
pull_request:
permissions:
contents: read
jobs:
run-tests:
strategy:
matrix:
go: [ '1.21', '1.20', '1.19' ]
platform: [ ubuntu-latest ]
runs-on: ubuntu-latest
env:
MSSQL_DB: gorm
MSSQL_USER: gorm
MSSQL_PASSWORD: LoremIpsum86
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: ${{ env.MSSQL_PASSWORD }}
MSSQL_PID: Developer
ports:
- 9930:1433
options: >-
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -N -C -l 30 -Q \"SELECT 1\" || exit 1"
--health-start-period 10s
--health-interval 5s
--health-timeout 10s
--health-retries 10
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Create gorm database and user in SQL Server
run: |
docker exec $(docker ps --filter "name=sqlserver" --format "{{.Names}}") \
/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_PASSWORD} -N -C -l 30 \
-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}];"
# Run build of the application
- name: Run build
run: go build .
- name: Run tests
run: go test -race -count=1 -v ./...