Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .azure-pipelines/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
- name: poolName
displayName: Pool Name
type: string
default: pool-ubuntu-2004
default: pool-windows-2019
- name: dotnet_sdk_3_1
displayName: .NET Core 3.1
default: 3.1.x
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
pwsh: true
targetType: filePath
filePath: ./tools/TestFx/Coverage/SaveTestCoverageResult.ps1
arguments: CITest $(Build.BuildId) $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(TestCoverageDatabaseName) $(TestCoverageTableName) $(TestCoverageLocation)
arguments: CITest $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion)

- task: PowerShell@2
displayName: Update Test Coverage Baseline
Expand Down
44 changes: 10 additions & 34 deletions tools/TestFx/Coverage/SaveTestCoverageResult.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,39 @@ param (

[Parameter(Mandatory, Position = 1)]
[ValidateNotNullOrEmpty()]
[string] $BuildId,

[Parameter(Mandatory, Position = 2)]
[ValidateNotNullOrEmpty()]
[guid] $KustoServicePrincipalTenantId,

[Parameter(Mandatory, Position = 3)]
[Parameter(Mandatory, Position = 2)]
[ValidateNotNullOrEmpty()]
[guid] $KustoServicePrincipalId,

[Parameter(Mandatory, Position = 4)]
[Parameter(Mandatory, Position = 3)]
[ValidateNotNullOrEmpty()]
[string] $KustoServicePrincipalSecret,

[Parameter(Mandatory, Position = 5)]
[Parameter(Mandatory, Position = 4)]
[ValidateNotNullOrEmpty()]
[string] $ClusterName,

[Parameter(Mandatory, Position = 6)]
[ValidateNotNullOrEmpty()]
[string] $ClusterRegion,

[Parameter(Mandatory, Position = 7)]
[ValidateNotNullOrEmpty()]
[string] $DatabaseName,

[Parameter(Mandatory, Position = 8)]
[Parameter(Mandatory, Position = 5)]
[ValidateNotNullOrEmpty()]
[string] $TableName,

[Parameter(Mandatory, Position = 9)]
[ValidateNotNull()]
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })]
[string] $DataLocation
[string] $ClusterRegion
)

$script:AzPSCommonParameters = @("-Break", "-Confirm", "-Debug", "-DefaultProfile", "-ErrorAction", "-ErrorVariable", "-HttpPipelineAppend", "-HttpPipelinePrepend", "-InformationAction", "-InformationVariable",
"-OutBuffer", "-OutVariable", "-PassThru", "-PipelineVariable", "-Proxy", "-ProxyCredential", "-ProxyUseDefaultCredentials", "-Verbose", "-WarningAction", "-WarningVariable", "-WhatIf")

$cvgDir = Join-Path -Path $DataLocation -ChildPath "TestCoverageAnalysis" | Join-Path -ChildPath "Raw"
$cvgDir = Join-Path -Path ${env:TESTCOVERAGELOCATION} -ChildPath "TestCoverageAnalysis" | Join-Path -ChildPath "Raw"
if (Test-Path -LiteralPath $cvgDir -PathType Container) {
Import-Module (Join-Path -Path ($PSScriptRoot | Split-Path) -ChildPath "Utilities" | Join-Path -ChildPath "KustoUtility.psd1") -Force
$kustoUtil = Join-Path -Path ($PSScriptRoot | Split-Path) -ChildPath "Utilities" | Join-Path -ChildPath "KustoUtility.psd1"
Import-Module $kustoUtil -ArgumentList $KustoServicePrincipalTenantId, $KustoServicePrincipalId, $KustoServicePrincipalSecret, $ClusterName, $ClusterRegion -Force

$cvgRawCsv = Get-ChildItem -Path $cvgDir -Filter "*.csv" -File | Select-Object -ExpandProperty FullName
$cvgRawCsv | ForEach-Object {
(Import-Csv -Path $_) |
Select-Object `
@{ Name = "Source"; Expression = { $Source } }, `
@{ Name = "BuildId"; Expression = { $BuildId } }, `
@{ Name = "BuildId"; Expression = { ${env:BUILD_BUILDID} } }, `
@{ Name = "Module"; Expression = { $_.Module } }, `
@{ Name = "CommandName"; Expression = { $_.CommandName } }, `
@{ Name = "TotalCommands"; Expression = { $_.TotalCommands } }, `
Expand All @@ -69,15 +53,7 @@ if (Test-Path -LiteralPath $cvgDir -PathType Container) {
Export-Csv -Path $_ -Encoding utf8 -NoTypeInformation -Force
}

Import-KustoDataFromCsv `
-ServicePrincipalTenantId $KustoServicePrincipalTenantId `
-ServicePrincipalId $KustoServicePrincipalId `
-ServicePrincipalSecret $KustoServicePrincipalSecret `
-ClusterName $ClusterName `
-ClusterRegion $ClusterRegion `
-DatabaseName $DatabaseName `
-TableName $TableName `
-CsvFile $cvgRawCsv
Import-KustoDataFromCsv -DatabaseName ${env:TESTCOVERAGEDATABASENAME} -TableName ${env:TESTCOVERAGETABLENAME} -CsvFile $cvgRawCsv
}
else {
Write-Host "##[warning]No test coverage data was found." -ForegroundColor Yellow
Expand Down