From d5c82701e17037e8d06c34ff8d133ac16919a6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Skytte=20Randl=C3=B8v?= Date: Fri, 9 Feb 2024 23:42:44 +0100 Subject: [PATCH 1/3] feat(code-coverage): Print MSSQL container logs --- .github/workflows/code-coverage.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/code-coverage.yaml index 4052c09b..0bdf32c4 100644 --- a/.github/workflows/code-coverage.yaml +++ b/.github/workflows/code-coverage.yaml @@ -226,6 +226,7 @@ jobs: uses: potatoqualitee/mssqlsuite@v1.7 with: install: sqlengine, sqlpackage, sqlclient + show-log: true - name: Setup testing schemata in SQL server if: ${{ inputs.schemas != 'none' }} @@ -282,3 +283,17 @@ jobs: with: name: coverage-test-failures-mssql path: ${{ runner.temp }}/package + + - name: Collect docker logs + if: always() + uses: jwalton/gh-docker-logs@v1 + with: + dest: '${{ runner.workspace }}/logs-docker' + + - name: Check docker logs for SQL Server ERRORs + if: always() + run: | + ## -------------------------------------------------------------------- + log=$(find ${{ runner.workspace }}/logs-docker/ -name 'sql.log') + + cat "$log" From 3a4b88e2004af30201510010859a273076b71331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Skytte=20Randl=C3=B8v?= Date: Sat, 10 Feb 2024 00:19:47 +0100 Subject: [PATCH 2/3] feat(code-coverag): Rename MSSQL database --- .github/workflows/code-coverage.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/code-coverage.yaml index 0bdf32c4..d0251025 100644 --- a/.github/workflows/code-coverage.yaml +++ b/.github/workflows/code-coverage.yaml @@ -215,7 +215,7 @@ jobs: "MSSQL": { "driver": "ODBC Driver 17 for SQL Server", "server": "localhost", - "database": "tempdb", + "database": "master", "UID": "SA", "PWD": "dbatools.I0" } @@ -232,16 +232,20 @@ jobs: if: ${{ inputs.schemas != 'none' }} run: | set -o xtrace + + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -Q "CREATE DATABASE master;" + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -Q "ALTER LOGIN SA WITH DEFAULT_DATABASE = master;" + IFS=',' read -ra schemas <<< "${{ inputs.schemas }}" for schema in "${schemas[@]}"; do - sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "CREATE SCHEMA [$schema];" - sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "GO" + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d master -Q "CREATE SCHEMA [$schema];" + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d master -Q "GO" done - sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "SELECT * FROM sys.schemas" + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d master -Q "SELECT * FROM sys.schemas" - sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA WHERE schema_name = 'test'" - sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA WHERE schema_name = 'test.one'" + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d master -Q "SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA WHERE schema_name = 'test'" + sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d master -Q "SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA WHERE schema_name = 'test.one'" - uses: actions/checkout@v4 From c65d2a73ae3d1137260f4bce5aa22782b7cdabe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Skytte=20Randl=C3=B8v?= Date: Sat, 10 Feb 2024 00:30:25 +0100 Subject: [PATCH 3/3] fix(code-coverage): Don't create master DB (MSSQL) --- .github/workflows/code-coverage.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/code-coverage.yaml index d0251025..c9bb09af 100644 --- a/.github/workflows/code-coverage.yaml +++ b/.github/workflows/code-coverage.yaml @@ -233,7 +233,6 @@ jobs: run: | set -o xtrace - sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -Q "CREATE DATABASE master;" sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -Q "ALTER LOGIN SA WITH DEFAULT_DATABASE = master;" IFS=',' read -ra schemas <<< "${{ inputs.schemas }}"