mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-23 02:40:56 +00:00
ci👷: run the migration tests against SQL Server too
The fourth registered driver, and the one that disagrees with the other three about NULL. A suite that never pointed at it reported success for a migration no SQL Server database could apply - the same shape as the PostgreSQL gap that put the postgres service here, one driver further along. SQL Server has no equivalent of POSTGRES_DB, so the database the DSN names is created in a step before the tests. The test helper fails rather than skips when CI is set and the variable is not, so dropping the service or renaming the variable cannot quietly go green.
This commit is contained in:
@@ -46,6 +46,28 @@ jobs:
|
||||
--health-timeout 3s
|
||||
--health-retries 10
|
||||
|
||||
# The fourth registered driver, and the one that disagrees with the
|
||||
# other three about NULL: its unique index treats two NULLs as equal and
|
||||
# permits one. A migration that builds a unique index over a nullable
|
||||
# column therefore fails here and nowhere else, which is how one shipped
|
||||
# that no SQL Server database could apply at all - not even an empty
|
||||
# one. The password is this container's only credential and the
|
||||
# container lives for the length of one job.
|
||||
sqlserver:
|
||||
image: mcr.microsoft.com/mssql/server:2022-latest
|
||||
env:
|
||||
ACCEPT_EULA: "Y"
|
||||
MSSQL_SA_PASSWORD: GoAdmin_Test1
|
||||
MSSQL_PID: Developer
|
||||
ports:
|
||||
- 1433:1433
|
||||
options: >-
|
||||
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P GoAdmin_Test1 -C -Q 'SELECT 1'"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 20
|
||||
--health-start-period 20s
|
||||
|
||||
env:
|
||||
GO_ADMIN_TEST_REDIS_ADDR: 127.0.0.1:6379
|
||||
# The soft-delete conversion drops an index, and gorm's PostgreSQL driver
|
||||
@@ -54,6 +76,7 @@ jobs:
|
||||
# migration that failed on every PostgreSQL database it was pointed at.
|
||||
# See go-admin#919.
|
||||
GO_ADMIN_TEST_POSTGRES_DSN: "host=127.0.0.1 port=5432 user=postgres password=postgres dbname=goadmin_test sslmode=disable"
|
||||
GO_ADMIN_TEST_SQLSERVER_DSN: "sqlserver://sa:GoAdmin_Test1@127.0.0.1:1433?database=goadmin_test"
|
||||
|
||||
steps:
|
||||
|
||||
@@ -66,6 +89,14 @@ jobs:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
# SQL Server has no equivalent of POSTGRES_DB, so the database the DSN
|
||||
# names has to be created before the tests run.
|
||||
- name: Create the SQL Server test database
|
||||
run: |
|
||||
docker exec ${{ job.services.sqlserver.id }} /opt/mssql-tools18/bin/sqlcmd \
|
||||
-S localhost -U sa -P GoAdmin_Test1 -C \
|
||||
-Q "IF DB_ID('goadmin_test') IS NULL CREATE DATABASE goadmin_test"
|
||||
|
||||
- name: Get dependencies
|
||||
run: go mod tidy
|
||||
|
||||
|
||||
Reference in New Issue
Block a user