Skip to content

Commit

Permalink
✅ Publish Test Results to Azure Pipelines (#230)
Browse files Browse the repository at this point in the history
* 📦 Add pipelines step for test publishing

* ✨ Enable test publishing!
  • Loading branch information
vexx32 committed Aug 30, 2019
1 parent d2c56e6 commit 60fe30d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Build/Psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Properties {

$Timestamp = Get-Date -Format "yyyyMMdd-hhmmss"
$PSVersion = $PSVersionTable.PSVersion
$TestFile = "TestResults_PS${PSVersion}_${TimeStamp}.xml"
$TestFile = "PS${PSVersion}_${TimeStamp}_PSKoans.TestResults.xml"
$Lines = '-' * 70

$Continue = @{
Expand Down Expand Up @@ -48,20 +48,21 @@ STATUS: Testing with PowerShell $PSVersion
$env:PSModulePath = '{0}{1}{2}' -f $ProjectRoot, ([System.IO.Path]::PathSeparator), $env:PSModulePath
Import-Module 'PSKoans'

# Tell Azure where the test results file will be
Write-Host "##vso[task.setvariable variable=TestResults]$TestFile"

# Gather test results. Store them in a variable and file
$PesterParams = @{
Path = "$ProjectRoot/Tests"
PassThru = $true
OutputFormat = 'NUnitXml'
OutputFile = "$ProjectRoot/$TestFile"
OutputFile = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$TestFile"
Show = "Header", "Failed", "Summary"
}
$TestResults = Invoke-Pester @PesterParams

[Net.ServicePointManager]::SecurityProtocol = $SecurityProtocol

Remove-Item -Path "$ProjectRoot/$TestFile" -Force -ErrorAction SilentlyContinue

# Failed tests?
# Need to tell psake or it will proceed to the deployment. Danger!
if ($TestResults.FailedCount -gt 0) {
Expand Down Expand Up @@ -93,6 +94,5 @@ Continuing with existing version.
}

# Build external help files from Platyps MD files

New-ExternalHelp -Path "$ProjectRoot/docs/" -OutputPath "$ProjectRoot/PSKoans/en-us"
}
8 changes: 8 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ jobs:
failOnStderr: true
pwsh: true

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: NUnit
testResultsFiles: '$(TestResults)'
searchFolder: '$(Build.ArtifactStagingDirectory)'
mergeTestResults: true

- task: PowerShell@2
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
displayName: 'Deploy to Gallery'
Expand Down

0 comments on commit 60fe30d

Please sign in to comment.