Skip to content

Commit b36bdb7

Browse files
main to dev (#239)
* Update .tsqllintrc_150 * Transition to Github Runners instead of AppVeyor (#233) * chores: use new gha for tsqlt (#234) * remove internal tsqlt action * Update sqlserver-unit.yml * Update badges for github CI * Tweak more github CI setup (#235) * Bump potatoqualitee/mssqlsuite from 1.4 to 1.5 (#236) Bumps [potatoqualitee/mssqlsuite](https://github.com/potatoqualitee/mssqlsuite) from 1.4 to 1.5. - [Release notes](https://github.com/potatoqualitee/mssqlsuite/releases) - [Commits](potatoqualitee/mssqlsuite@v1.4...v1.5) --- updated-dependencies: - dependency-name: potatoqualitee/mssqlsuite dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add sql server 2017 unit tests in github ci (#237) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 7b17826 commit b36bdb7

39 files changed

+545
-11741
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These are supported funding model platforms
22

3-
github: LowlyDBA # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
3+
github: lowlydba # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
44
patreon: # Replace with a single Patreon username
55
open_collective: # Replace with a single Open Collective username
66
ko_fi: # Replace with a single Ko-fi username
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "MSSQL Sample Database"
2+
author: "lowlydba"
3+
branding:
4+
icon: "database"
5+
color: "red"
6+
description: "Restores a sample database to an instance."
7+
inputs:
8+
sql-instance:
9+
description: "Target SQL instance."
10+
required: false
11+
default: "localhost"
12+
database:
13+
description: "Sample database to download and restore."
14+
required: false
15+
default: "WideWorldImporters"
16+
runs:
17+
using: "composite"
18+
steps:
19+
- shell: pwsh
20+
id: "mssql-sample-database"
21+
run: |
22+
$params = @{
23+
Database = "${{ inputs.database }}"
24+
SqlInstance = "${{ inputs.sql-instance }}"
25+
}
26+
27+
${{ github.action_path }}\main.ps1 @params
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[ValidateSet("WideWorldImporters")]
4+
[string]$Database,
5+
[Parameter(Mandatory = $true)]
6+
[string]$SqlInstance
7+
)
8+
9+
if ($Env:RUNNER_OS -ne "Windows") {
10+
Write-Error "This action only supported on Windows runners." -ErrorAction "Stop"
11+
}
12+
13+
if ($Database -eq "WideWorldImporters") {
14+
$BackupPath = Join-Path -Path $Env:RUNNER_TEMP -ChildPath "$Database.bak"
15+
$Uri = "https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak"
16+
$Documentation = "https://docs.microsoft.com/en-us/sql/samples/wide-world-importers-what-is"
17+
}
18+
19+
Write-Output "Thanks for using MSSQL Sample Database!"
20+
Write-Output "📃: $Documentation"
21+
Write-Output "-----"
22+
Write-Output "Downloading '$Database' to '$BackupPath' ..."
23+
Invoke-WebRequest -Uri $Uri -OutFile $BackupPath
24+
Write-Output "Restoring '$Database' ..."
25+
Restore-SqlDatabase -ServerInstance $SqlInstance -Database $Database -BackupFile $BackupPath -AutoRelocateFile -Verbose
26+
#Get-DbaDatabase -SqlInstance $SqlInstance -Database $Database | Select-Object -Property Name, Status, SizeMB, SqlInstance
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "SQLCover"
2+
author: "lowlydba"
3+
branding:
4+
icon: "database"
5+
color: "purple"
6+
description: "Installs, starts, and stops SQLCover by GoEddie."
7+
inputs:
8+
sql-instance:
9+
description: "Target SQL instance."
10+
required: false
11+
default: "localhost"
12+
database:
13+
description: "Target database."
14+
required: false
15+
default: "master"
16+
output-file:
17+
description: "File to output results to."
18+
required: false
19+
default: "cobertura.xml"
20+
runs:
21+
using: "composite"
22+
steps:
23+
- id: output
24+
shell: pwsh
25+
run: |
26+
$params = @{
27+
Database = "${{ inputs.database }}"
28+
SqlInstance = "${{ inputs.sql-instance }}"
29+
OutputFile = "${{ inputs.output-file }}"
30+
}
31+
32+
${{github.action_path}}\main.ps1 @params

.github/actions/sqlcover/main.ps1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$Database,
4+
[Parameter(Mandatory = $true)]
5+
[string]$SqlInstance,
6+
[string]$Package = "GOEddie.SQLCover",
7+
[Parameter(Mandatory = $true)]
8+
[string]$OutputFile
9+
)
10+
11+
if ($Env:RUNNER_OS -ne "Windows") {
12+
Write-Error "This action only supported on Windows runners." -ErrorAction "Stop"
13+
}
14+
15+
# Install SQLCover
16+
Write-Output "Installing SQLCover."
17+
$null = Install-Package $Package -Force -Scope "CurrentUser"
18+
$NugetPath = (Get-Package $Package).Source | Convert-Path
19+
$SQLCoverRoot = Split-Path $NugetPath
20+
$SQLCoverDllPath = Join-Path $SQLCoverRoot "lib\SQLCover.dll"
21+
Add-Type -Path $SQLCoverDllPath
22+
23+
$connString = "server=$SqlInstance;Trusted_Connection=yes"
24+
$sqlCover = New-Object SQLCover.CodeCoverage($connString, $Database)
25+
$null = $sqlCover.Start()
26+
27+
# Run tests
28+
Invoke-Pester -Path ".\tests\*"
29+
30+
# Stop
31+
Write-Output "Stopping SQL Cover."
32+
$coverageResults = $sqlCover.Stop()
33+
34+
# Save results
35+
[xml]$coberturaXml = $coverageResults.Cobertura()
36+
$OutputFullPath = Join-Path -Path "." -ChildPath $OutputFile
37+
Write-Output "Saving Cobertura report to $OutputFullPath"
38+
39+
# Fix missing filename with best-effort value
40+
# https://github.com/GoEddie/SQLCover/issues/79
41+
foreach ($class in $coberturaXml.coverage.packages.package.classes.class) {
42+
$class.filename = $class.Name
43+
}
44+
$coberturaXml.Save($OutputFullPath)
45+
46+
# HTML artifact
47+
$HtmlFullPath = Join-Path -Path "." -ChildPath "coverage.html"
48+
Write-Output "Saving HTML report to $HtmlFullPath"
49+
Set-Content -Path $HtmlFullPath -Value $coverageResults.Html2() -Force
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
# TSQLLint Github Action
1+
# tSQLt Github Action
22

3-
This action runs [TSQLLint](https://git.io/JILDv) via a Github Action.
3+
This action installs [tSQLt](https://github.com/tSQLt-org/tSQLt) via a Github Action.
44

55
## Inputs
66

7-
### `file-dir-1`
7+
### `sqlinstance`
88

9-
**Required** First path to file or directory to lint.
9+
**Required** SQL Instance to install to.
1010

11-
### `file-dir-2`
11+
### `database`
1212

13-
**Required** Second path to file or directory to lint.
13+
**Required** Database to install to.
1414

15-
### `config`
15+
### `version`
1616

17-
**Optional** Location of a TSQLLint configuration file, otherwise defaults are used.
18-
19-
## Example usage
20-
21-
TBD
17+
**Optional** Version of tSQLt to install.

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
# Check for updates to GitHub Actions every weekday
9+
interval: "daily"

.github/linter-conf/.tsqllintrc_150

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"rules": {
33
"case-sensitive-variables": "error",
44
"concat-strings": "error",
5-
"conditional-begin-end": "off",
5+
"conditional-begin-end": "on",
66
"count-star": "error",
77
"cross-database-transaction": "error",
88
"data-compression": "warn",
@@ -31,4 +31,4 @@
3131
"unicode-string": "error"
3232
},
3333
"compatability-level": 150
34-
}
34+
}

.github/workflows/artifacts.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Generate Scripts
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths-ignore:
9+
- .vscode/*
10+
pull_request:
11+
paths-ignore:
12+
- .vscode/*
13+
14+
# Cancel existing runs on new commits to a branch
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
INSTALLER_FILE: "install_dba-multitool.sql"
21+
22+
jobs:
23+
bundle:
24+
runs-on: ubuntu-latest
25+
name: Generate installer
26+
defaults:
27+
run:
28+
shell: pwsh
29+
30+
steps:
31+
- name: Check out code
32+
uses: actions/[email protected]
33+
with:
34+
repository: ${{ github.event.pull_request.head.repo.full_name }}
35+
ref: ${{ github.event.pull_request.head.ref }}
36+
37+
- name: Create bundled installer script
38+
run: |
39+
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Filter "sp_*.sql" | Get-Content | Out-File $Env:INSTALLER_FILE -Encoding ascii
40+
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Filter $Env:INSTALLER_FILE | Select-Object -Property Name, Size, LastWriteTime, User
41+
42+
- name: Commit bundled installer script
43+
uses: stefanzweifel/[email protected]
44+
with:
45+
commit_message: Updated bundled installer
46+
file_pattern: ${{ env.INSTALLER_FILE }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: Unit Test (AzureSQL)
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths-ignore:
9+
- .vscode/*
10+
pull_request:
11+
paths-ignore:
12+
- .vscode/*
13+
14+
# Run CI once per day (at 06:00 UTC)
15+
schedule:
16+
- cron: "0 6 * * *"
17+
18+
# Cancel existing runs on new commits to a branch
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
env:
24+
SQLINSTANCE: "localhost"
25+
DATABASE: "tsqlt"
26+
INSTALLER_FILE: "install_dba-multitool.sql"
27+
TSQLT_FILE: "run_tsqlt.sql"
28+
29+
jobs:
30+
integration:
31+
runs-on: ubuntu-latest
32+
name: azuresql
33+
defaults:
34+
run:
35+
shell: pwsh
36+
37+
steps:
38+
- name: Check out code
39+
uses: actions/[email protected]
40+
with:
41+
path: ""
42+
43+
- name: Create installer script
44+
run: |
45+
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Filter "sp_*.sql" | Get-Content | Out-File $Env:INSTALLER_FILE -Encoding ascii
46+
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Filter $Env:INSTALLER_FILE
47+
48+
- name: Create tsqlt runner script
49+
run: |
50+
New-Item -Path $Env:TSQLT_FILE -ItemType "File" -Value "EXEC tsqlt.RunAll;" -Force
51+
52+
- name: Install multitool
53+
uses: azure/[email protected]
54+
with:
55+
connection-string: ${{ secrets.AZURE_SQL_CONNECTION_STRING }}
56+
sql-file: ${{ env.INSTALLER_FILE }}
57+
58+
- name: Run tSQLt tests
59+
uses: azure/[email protected]
60+
with:
61+
connection-string: ${{ secrets.AZURE_SQL_CONNECTION_STRING }}
62+
sql-file: ${{ env.TSQLT_FILE }}

0 commit comments

Comments
 (0)