Moved publishing of code coverage artifacts to test_script phase (#2760)
* Moved publishing of code coverage artifacts to after_test phase The webhook for build completion is called after the after_test phase hence we needed to publish code coverage artifacts before that. Moved the logic for compression and publish the artifacts after running tests. * Added check for daily build * Address code review comments. * Addressed code review comments Addressed comments about definition of artifacts. Defined new function for after_test phase.
This commit is contained in:
parent
3d94e35f21
commit
ead4df4097
|
@ -20,5 +20,8 @@ build_script:
|
|||
test_script:
|
||||
- ps: Invoke-AppveyorTest
|
||||
|
||||
after_test:
|
||||
- ps: Invoke-AppVeyorAfterTest
|
||||
|
||||
on_finish:
|
||||
- ps: Invoke-AppveyorFinish
|
||||
|
|
|
@ -326,9 +326,6 @@ function Invoke-AppVeyorTest
|
|||
Write-Host -Foreground Green 'Upload FullCLR test results'
|
||||
Update-AppVeyorTestResults -resultsFile $testResultsFileFullCLR
|
||||
|
||||
## CodeCoverage
|
||||
$env:CodeCoverageOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Configuration CodeCoverage))
|
||||
|
||||
#
|
||||
# Fail the build, if tests failed
|
||||
@(
|
||||
|
@ -342,6 +339,49 @@ function Invoke-AppVeyorTest
|
|||
Set-BuildVariable -Name TestPassed -Value True
|
||||
}
|
||||
|
||||
#Implement AppVeyor 'after_test' phase
|
||||
function Invoke-AppVeyorAfterTest
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
if(Test-DailyBuild)
|
||||
{
|
||||
## Publish code coverage build, tests and OpenCover module to artifacts, so webhook has the information.
|
||||
## Build webhook is called after 'after_test' phase, hence we need to do this here and not in AppveyorFinish.
|
||||
$codeCoverageOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Configuration CodeCoverage))
|
||||
$codeCoverageArtifacts = Compress-CoverageArtifacts -CodeCoverageOutput $codeCoverageOutput
|
||||
|
||||
Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts'
|
||||
$codeCoverageArtifacts | % { Push-AppveyorArtifact $_ }
|
||||
}
|
||||
}
|
||||
|
||||
function Compress-CoverageArtifacts
|
||||
{
|
||||
param([string] $CodeCoverageOutput)
|
||||
|
||||
# Create archive for test content, OpenCover module and CodeCoverage build
|
||||
$artifacts = New-Object System.Collections.ArrayList
|
||||
|
||||
$zipTestContentPath = Join-Path $pwd 'tests.zip'
|
||||
Compress-TestContent -Destination $zipTestContentPath
|
||||
$artifacts.Add($zipTestContentPath)
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
$resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $PSScriptRoot '..\test\tools\OpenCover'))
|
||||
$zipOpenCoverPath = Join-Path $pwd 'OpenCover.zip'
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($resolvedPath, $zipOpenCoverPath)
|
||||
$artifacts.Add($zipOpenCoverPath)
|
||||
|
||||
$zipCodeCoveragePath = Join-Path $pwd "$name.CodeCoverage.zip"
|
||||
Write-Verbose "Zipping ${CodeCoverageOutput} into $zipCodeCoveragePath" -verbose
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($CodeCoverageOutput, $zipCodeCoveragePath)
|
||||
$artifacts.Add($zipCodeCoveragePath)
|
||||
|
||||
return $artifacts
|
||||
}
|
||||
|
||||
# Implements AppVeyor 'on_finish' step
|
||||
function Invoke-AppveyorFinish
|
||||
{
|
||||
|
@ -373,25 +413,6 @@ function Invoke-AppveyorFinish
|
|||
$artifacts.Add($zipFilePath)
|
||||
$artifacts.Add($zipFileFullPath)
|
||||
|
||||
# Create archive for test content, OpenCover module and CodeCoverage build
|
||||
if(Test-DailyBuild)
|
||||
{
|
||||
$zipTestContentPath = Join-Path $pwd 'tests.zip'
|
||||
Compress-TestContent -Destination $zipTestContentPath
|
||||
$artifacts.Add($zipTestContentPath)
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
$resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $PSScriptRoot '..\test\tools\OpenCover'))
|
||||
$zipOpenCoverPath = Join-Path $pwd 'OpenCover.zip'
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($resolvedPath, $zipOpenCoverPath)
|
||||
$artifacts.Add($zipOpenCoverPath)
|
||||
|
||||
$zipCodeCoveragePath = Join-Path $pwd "$name.CodeCoverage.zip"
|
||||
Write-Verbose "Zipping ${env:CodeCoverageOutput} into $zipCodeCoveragePath" -verbose
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($env:CodeCoverageOutput, $zipCodeCoveragePath)
|
||||
$artifacts.Add($zipCodeCoveragePath)
|
||||
}
|
||||
|
||||
if ($env:APPVEYOR_REPO_TAG_NAME)
|
||||
{
|
||||
# ignore the first part of semver, use the preview part
|
||||
|
|
Loading…
Reference in a new issue