mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Fail build if we fail to build PowerShell.exe before running tests Fail build if we fail to push an artifact because it doesn't exist.
138 lines
5.3 KiB
YAML
138 lines
5.3 KiB
YAML
version: 0.6.0.{build}
|
|
|
|
cache:
|
|
- '%LocalAppData%\Microsoft\dotnet'
|
|
|
|
nuget:
|
|
project_feed: true
|
|
|
|
environment:
|
|
priv_key:
|
|
secure: <encryped-value>
|
|
|
|
install:
|
|
- ps: $fileContent = "-----BEGIN RSA PRIVATE KEY-----`n"
|
|
- ps: $fileContent += $env:priv_key.Replace(' ', "`n")
|
|
- ps: $fileContent += "`n-----END RSA PRIVATE KEY-----`n"
|
|
- ps: Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
|
|
- git config --global url.git@github.com:.insteadOf https://github.com/
|
|
- git submodule update --init
|
|
- ps: $buildConfiguration = 'Release'
|
|
- ps: Import-Module .\build.psm1; Start-PSBootstrap -Force
|
|
|
|
build_script:
|
|
- ps: |
|
|
$ErrorActionPreference = 'Stop'
|
|
# check to be sure our test tags are correct
|
|
$result = Get-PesterTag
|
|
if ( $result.Result -ne "Pass" ) {
|
|
$result.Warnings
|
|
throw "Tags must be CI, Feature, Scenario, or Slow"
|
|
}
|
|
Start-PSBuild -CrossGen -Configuration $buildConfiguration
|
|
Start-PSBuild -FullCLR
|
|
|
|
test_script:
|
|
- ps: |
|
|
# fail tests execution, if any PS error detected
|
|
$ErrorActionPreference = 'Stop'
|
|
#
|
|
# CoreCLR
|
|
$env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Publish -Configuration $buildConfiguration))
|
|
Write-Host -Foreground Green 'Run CoreCLR tests'
|
|
$testResultsFile = "$pwd\TestsResults.xml"
|
|
if(!(Test-Path "$env:CoreOutput\powershell.exe"))
|
|
{
|
|
throw "CoreCL PowerShell.exe was not built"
|
|
}
|
|
& ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Set-ExecutionPolicy -Scope Process Unrestricted; Invoke-Pester test/powershell -Tag 'CI' -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFile"
|
|
|
|
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
|
|
#
|
|
# FullCLR
|
|
$env:FullOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -FullCLR))
|
|
Write-Host -Foreground Green 'Run FullCLR tests'
|
|
$testResultsFileFullCLR = "$pwd\TestsResults.FullCLR.xml"
|
|
Start-DevPowerShell -FullCLR -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Set-ExecutionPolicy -Scope Process Unrestricted; Invoke-Pester test/fullCLR -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR"
|
|
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFileFullCLR))
|
|
#
|
|
# Fail the build, if tests failed
|
|
Write-Host -Foreground Green 'Upload CoreCLR test results'
|
|
$x = [xml](cat -raw $testResultsFile)
|
|
if ([int]$x.'test-results'.failures -gt 0)
|
|
{
|
|
throw "$($x.'test-results'.failures) tests in test/powershell failed"
|
|
}
|
|
Write-Host -Foreground Green 'Upload FullCLR test results'
|
|
$x = [xml](cat -raw $testResultsFileFullCLR)
|
|
if ([int]$x.'test-results'.failures -gt 0)
|
|
{
|
|
throw "$($x.'test-results'.failures) tests in test/fullCLR failed"
|
|
}
|
|
|
|
on_finish:
|
|
- ps: |
|
|
$ErrorActionPreference = 'Stop'
|
|
try {
|
|
# Build packages
|
|
$packages = Start-PSPackage
|
|
|
|
# Creating project artifact
|
|
$name = git describe
|
|
|
|
# Remove 'v' from version, append 'PowerShell' - to be consistent with other package names
|
|
$name = $name -replace 'v',''
|
|
$name = 'PowerShell_' + $name
|
|
|
|
$zipFilePath = Join-Path $pwd "$name.zip"
|
|
$zipFileFullPath = Join-Path $pwd "$name.FullCLR.zip"
|
|
Add-Type -assemblyname System.IO.Compression.FileSystem
|
|
Write-Verbose "Zipping ${env:CoreOutput} into $zipFilePath" -verbose
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($env:CoreOutput, $zipFilePath)
|
|
Write-Verbose "Zipping ${env:FullOutput} into $zipFileFullPath" -verbose
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($env:FullOutput, $zipFileFullPath)
|
|
|
|
$artifacts = New-Object System.Collections.ArrayList
|
|
foreach ($package in $packages) {
|
|
$artifacts.Add($package)
|
|
}
|
|
|
|
$artifacts.Add($zipFilePath)
|
|
$artifacts.Add($zipFileFullPath)
|
|
|
|
if ($env:APPVEYOR_REPO_TAG_NAME)
|
|
{
|
|
# ignore the first part of semver, use the preview part
|
|
$preReleaseVersion = ($env:APPVEYOR_REPO_TAG_NAME).Split('-')[1]
|
|
}
|
|
else
|
|
{
|
|
$previewLabel = (git describe --abbrev=0).Split('-')[1]
|
|
$preReleaseVersion = "$previewLabel.$($env:APPVEYOR_BUILD_NUMBER)"
|
|
}
|
|
|
|
Publish-NuGetFeed -OutputPath .\nuget-artifacts -VersionSuffix $preReleaseVersion
|
|
|
|
$artifacts += (ls .\nuget-artifacts | % {$_.FullName})
|
|
|
|
$pushedAllArtifacts = $true
|
|
$artifacts | % {
|
|
Write-Host "Pushing $_ as Appveyor artifact"
|
|
if(Test-Path $_)
|
|
{
|
|
Push-AppveyorArtifact $_
|
|
}
|
|
else
|
|
{
|
|
$pushedAllArtifacts = $false
|
|
Write-Warning "Artifact $_ does not exist."
|
|
}
|
|
}
|
|
if(!$pushedAllArtifacts)
|
|
{
|
|
throw "Some artifacts did not exist!"
|
|
}
|
|
} catch {
|
|
Write-Host -Foreground Red $_
|
|
}
|