Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions buildAndReleaseTask/EnsureSQL.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function Ensure-SQLTools{
param(
[int]$majorPSVersion
)

if($majorPSVersion -gt 4)
{
$confirmSqlServer = Get-Module SqlServer -ListAvailable
if(!$confirmSqlServer)
{
Try
{
Install-Module -Name SqlServer -AllowClobber
Write-Host "Loaded SqlServer module"
}
Catch
{
Write-Host "SqlServer not available via PowerShell Gallery, check connection settings"
}
}
else
{
Write-Host "SqlServer module is loaded"
}
}
else
{
$confirmSQLPS = Get-Module SQLPS -ListAvailable
if(!$confirmSQLPS)
{
Try
{
Import-Module "SQLPS" -DisableNameChecking
Write-Host "Loaded SQLPS module"
}
Catch
{
Write-Host "SQLPS not available to import; installation needed"
}
}
else
{
Write-Host "SQLPS module is loaded"
}
}
}
37 changes: 33 additions & 4 deletions buildAndReleaseTask/Install-Dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ param(
# [string]$installDirectory = $PSScriptRoot
)

if(!(Get-Module SqlServer)){
Install-Module -Name SqlServer -Scope CurrentUser -Force -AllowClobber
}
#if(!(Get-Module SqlServer)){
# Install-Module -Name SqlServer -Scope CurrentUser -Force -AllowClobber
#}

# $packagesDirectory = Join-Path -Path $installDirectory -ChildPath "packages"

Expand All @@ -22,4 +22,33 @@ if(!(Get-Module SqlServer)){
# Write-Output "Installing OpenCoverToCoberturaConverter..."
# Install-Package OpenCoverToCoberturaConverter -RequiredVersion 0.3.4 -Destination $packagesDirectory

# Write-Output "Finished installing dependencies."
# Write-Output "Finished installing dependencies."


$majorPSVersion = $PSVersionTable.PSVersion.Major

if($majorPSVersion -gt 4)
{
$confirmSqlServer = Get-Module SqlServer -ListAvailable;
if(!$confirmSqlServer)
{
Ensure-SQLTools $majorPSVersion
}
else
{
#Write-Verbose "SqlServer module already loaded"
Write-Host "SqlServer module already loaded"
}
}
else
{
$confirmSQLPS = Get-Module SQLPS -ListAvailable;
if(!$confirmSQLPS)
{
Ensure-SQLTools $majorPSVersion
}
else
{
Write-Verbose "SQLPS module already loaded"
}
}
12 changes: 11 additions & 1 deletion buildAndReleaseTask/Invoke-tSQLtTests-WithCodeCoverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ param (
[string]$coberturaFileName,
[string]$htmlReportsOutput,
[string]$queryTimeout
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may have a comma missing here, after $queryTimeout.

I think it breaks the code execution. But in case we're not sure, it would be good to keep the standard.

[string]$enableAzure
)

$sqlCoverPath = "$PSScriptRoot\dependencies\sqlcover\SQLCover.dll"
Expand All @@ -25,7 +26,16 @@ $connectionStringBuilder.set_ConnectionString($connectionString)
$database = $connectionStringBuilder["initial catalog"]
Write-Output "Database set to $database"

$coverage = new-object SQLCover.CodeCoverage($connectionString, $database, $null, $true, $false, [SQLCover.Trace.TraceControllerType]::Azure)
#to be able to work with Azure and SQL -- Glomaga
Write-Output "EnableAzure set to $enableAzure"

if ($enableAzure -eq "true") {
Write-Output "SQLCover with Azure SQL"
$coverage = new-object SQLCover.CodeCoverage($connectionString, $database, $null, $true, $false, [SQLCover.Trace.TraceControllerType]::Azure)
}Else{
Write-Output "SQLCover with SQL"
$coverage = new-object SQLCover.CodeCoverage($connectionString, $database, $null, $true, $false, [SQLCover.Trace.TraceControllerType]::sql)
}

$startResult = $coverage.Start()

Expand Down
5 changes: 4 additions & 1 deletion buildAndReleaseTask/Run-tSQLtTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ param (

# Code Coverage parameters
[string]$enableCodeCoverage = "false",
[string]$enableAzure = "false",
[string]$openCoverSourceFolder = "OpenCoverSourceFiles",
[string]$coberturaFileName = "Cobertura.xml",
[string]$htmlReportsOutput = "AzurePipelines",
Expand All @@ -26,6 +27,8 @@ if(!$workingDirectory) {
# Dependencies are then embeded to the extension VSIX
# . .\InstallDependencies.ps1 -installDirectory $workingDirectory

. .\EnsureSQL.ps1

. .\Install-Dependencies.ps1

$ErrorActionPreference = "Continue"
Expand Down Expand Up @@ -69,5 +72,5 @@ else {
$htmlReportsOutput = Join-Path -Path $rootOutput -ChildPath $htmlReportsOutput
Write-Output "htmlReportsOutput set to $htmlReportsOutput"

. .\Invoke-tSQLtTests-WithCodeCoverage.ps1 -connectionString $connectionString -rootOutput $rootOutput -testResultsFileName $testResultsFileName -openCoverSourceFolder $openCoverSourceFolder -openCoverXmlFile $openCoverXmlFile -coberturaFileName $coberturaFileName -htmlReportsOutput $htmlReportsOutput -queryTimeout $queryTimeout
. .\Invoke-tSQLtTests-WithCodeCoverage.ps1 -connectionString $connectionString -rootOutput $rootOutput -testResultsFileName $testResultsFileName -openCoverSourceFolder $openCoverSourceFolder -openCoverXmlFile $openCoverXmlFile -coberturaFileName $coberturaFileName -htmlReportsOutput $htmlReportsOutput -queryTimeout $queryTimeout -enableAzure $enableAzure
}
9 changes: 9 additions & 0 deletions buildAndReleaseTask/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
"required": false,
"helpMarkDown": "If you want Cobertura reports to be generated for the test execution, enable this.",
"groupName": "codeCoverage"
},
{
"name": "enableAzure",
"type": "boolean",
"label": "Enable Azure SQL",
"defaultValue": "false",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we've been working on a cloud world, do you think that it makes sense to leave it true by default?

"required": false,
"helpMarkDown": "If you want to get the result from a Azure SQL Server, enable this.",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking about requesting this info from the user as a Dropdown list. What do you think?

This way, we could ask for something like:

"SQL Server technology/service type":

  • SQL Server On Premises
  • Azure SQL

And then we'd handle this on the scripts.

"groupName": "codeCoverage"
},
{
"name": "coberturaFileName",
Expand Down