Add functionality to create a test package (#8087)
This commit is contained in:
parent
3ceb1c17ef
commit
487073e57b
|
@ -78,7 +78,7 @@ phases:
|
|||
|
||||
# Uploads any packages as an artifact
|
||||
- powershell: |
|
||||
Get-ChildItem -Path *.rpm, *.deb, *.tar.gz -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
|
||||
Get-ChildItem -Path *.rpm, *.deb, *.tar.gz, *.zip -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
|
||||
Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts]$_"
|
||||
}
|
||||
displayName: Publish Artifacts
|
||||
|
|
|
@ -53,7 +53,7 @@ phases:
|
|||
|
||||
# Uploads any packages as an artifact
|
||||
- powershell: |
|
||||
Get-ChildItem -Path *.pkg, *.tar.gz -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
|
||||
Get-ChildItem -Path *.pkg, *.tar.gz, *.zip -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
|
||||
Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts]$_"
|
||||
}
|
||||
displayName: Publish Artifacts
|
||||
|
|
61
build.psm1
61
build.psm1
|
@ -2972,3 +2972,64 @@ $script:RESX_TEMPLATE = @'
|
|||
{0}
|
||||
</root>
|
||||
'@
|
||||
|
||||
function New-TestPackage
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $Destination
|
||||
)
|
||||
|
||||
if (Test-Path $Destination -PathType Leaf)
|
||||
{
|
||||
throw "Destination: '$Destination' is not a directory or does not exist."
|
||||
}
|
||||
else
|
||||
{
|
||||
$null = New-Item -Path $Destination -ItemType Directory -Force
|
||||
Write-Verbose -Message "Creating destination folder: $Destination"
|
||||
}
|
||||
|
||||
$packageRoot = Join-Path $env:TEMP ('TestPackage-' + (new-guid))
|
||||
$null = New-Item -ItemType Directory -Path $packageRoot -Force
|
||||
$packagePath = Join-Path $Destination "TestPackage.zip"
|
||||
|
||||
# Build test tools so they are placed in appropriate folders under 'test' then copy to package root.
|
||||
$null = Publish-PSTestTools
|
||||
$powerShellTestRoot = Join-Path $PSScriptRoot 'test'
|
||||
Copy-Item $powerShellTestRoot -Recurse -Destination $packageRoot -Force
|
||||
Write-Verbose -Message "Copied test directory"
|
||||
|
||||
# Copy assests folder to package root for wix related tests.
|
||||
$assetsPath = Join-Path $PSScriptRoot 'assets'
|
||||
Copy-Item $assetsPath -Recurse -Destination $packageRoot -Force
|
||||
Write-Verbose -Message "Copied assests directory"
|
||||
|
||||
# Create expected folder structure for resx files in package root.
|
||||
$srcRootForResx = New-Item -Path "$packageRoot/src" -Force -ItemType Directory
|
||||
|
||||
$resourceDirectories = Get-ChildItem -Recurse "$PSScriptRoot/src" -Directory -Filter 'resources'
|
||||
|
||||
$resourceDirectories | ForEach-Object {
|
||||
$directoryFullName = $_.FullName
|
||||
|
||||
$partToRemove = Join-Path $PSScriptRoot "src"
|
||||
|
||||
$assemblyPart = $directoryFullName.Replace($partToRemove, '')
|
||||
$assemblyPart = $assemblyPart.TrimStart([io.path]::DirectorySeparatorChar)
|
||||
$resxDestPath = Join-Path $srcRootForResx $assemblyPart
|
||||
$null = New-Item -Path $resxDestPath -Force -ItemType Directory
|
||||
Write-Verbose -Message "Created resx directory : $resxDestPath"
|
||||
Copy-Item -Path "$directoryFullName\*" -Recurse $resxDestPath -Force
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
if(Test-Path $packagePath)
|
||||
{
|
||||
Remove-Item -Path $packagePath -Force
|
||||
}
|
||||
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($packageRoot, $packagePath)
|
||||
}
|
||||
|
|
|
@ -468,6 +468,12 @@ function Invoke-AppVeyorAfterTest
|
|||
|
||||
Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts'
|
||||
$codeCoverageArtifacts | ForEach-Object { Push-AppveyorArtifact $_ }
|
||||
|
||||
New-TestPackage -Destination $pwd
|
||||
$testPackageFullName = Join-Path $pwd 'TestPackage.zip'
|
||||
Write-Verbose "Created TestPackage.zip" -Verbose
|
||||
Write-Host -ForegroundColor Green -'Upload test package'
|
||||
Push-AppveyorArtifact $testPackageFullName
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -370,6 +370,11 @@ elseif($Stage -eq 'Build')
|
|||
Start-PSBuild -PSModuleRestore -Clean -Runtime linux-arm -Configuration 'Release'
|
||||
Start-PSPackage @packageParams -Type tar-arm -SkipReleaseChecks
|
||||
}
|
||||
|
||||
if ($isDailyBuild)
|
||||
{
|
||||
New-TestPackage -Destination $pwd
|
||||
}
|
||||
}
|
||||
|
||||
# if the tests did not pass, throw the reason why
|
||||
|
|
Loading…
Reference in a new issue