Skip to content

Commit

Permalink
🔀 Merge pull request #1 from godoes/fix_ci_mssqldocker
Browse files Browse the repository at this point in the history
ci: fix failed to initialize container mcmoe/mssqldocker:latest
  • Loading branch information
iTanken committed Sep 25, 2024
2 parents 991cdb1 + 806fcf7 commit c893675
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,50 @@ jobs:
run-tests:
strategy:
matrix:
go: ['1.21', '1.20', '1.19']
platform: [ubuntu-latest]
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: mcmoe/mssqldocker:latest
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: LoremIpsum86
MSSQL_DB: gorm
MSSQL_USER: gorm
MSSQL_PASSWORD: LoremIpsum86
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@v4
with:
go-version: ${{ matrix.go }}
- 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: 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 .
# Run build of the application
- name: Run build
run: go build .

- name: Run tests
run: go test -race -count=1 -v ./...
- name: Run tests
run: go test -race -count=1 -v ./...

0 comments on commit c893675

Please sign in to comment.