2018-02-13 18:23:53 +01:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the MIT License.
|
2016-08-29 22:12:01 +02:00
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$repoRoot = Join-Path $PSScriptRoot '..'
|
2016-10-11 00:24:04 +02:00
|
|
|
$script:administratorsGroupSID = "S-1-5-32-544"
|
|
|
|
$script:usersGroupSID = "S-1-5-32-545"
|
2016-08-29 22:12:01 +02:00
|
|
|
|
2017-07-18 20:39:04 +02:00
|
|
|
$dotNetPath = "$env:USERPROFILE\Appdata\Local\Microsoft\dotnet"
|
|
|
|
if(Test-Path $dotNetPath)
|
|
|
|
{
|
|
|
|
$env:PATH = $dotNetPath + ';' + $env:PATH
|
|
|
|
}
|
|
|
|
|
2017-07-23 21:29:33 +02:00
|
|
|
#import build into the global scope so it can be used by packaging
|
|
|
|
Import-Module (Join-Path $repoRoot 'build.psm1') -Scope Global
|
|
|
|
Import-Module (Join-Path $repoRoot 'tools\packaging')
|
2016-08-29 22:12:01 +02:00
|
|
|
|
2016-10-11 00:24:04 +02:00
|
|
|
function New-LocalUser
|
|
|
|
{
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Creates a local user with the specified username and password
|
|
|
|
.DESCRIPTION
|
|
|
|
.EXAMPLE
|
|
|
|
.PARAMETER
|
|
|
|
username Username of the user which will be created
|
|
|
|
.PARAMETER
|
|
|
|
password Password of the user which will be created
|
|
|
|
.OUTPUTS
|
|
|
|
.NOTES
|
|
|
|
#>
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $username,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $password
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
$LocalComputer = [ADSI] "WinNT://$env:computername";
|
|
|
|
$user = $LocalComputer.Create('user', $username);
|
|
|
|
$user.SetPassword($password) | out-null;
|
|
|
|
$user.SetInfo() | out-null;
|
|
|
|
}
|
|
|
|
|
|
|
|
<#
|
|
|
|
Converts SID to NT Account Name
|
|
|
|
#>
|
|
|
|
function ConvertTo-NtAccount
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $sid
|
|
|
|
)
|
|
|
|
(new-object System.Security.Principal.SecurityIdentifier($sid)).translate([System.Security.Principal.NTAccount]).Value
|
|
|
|
}
|
|
|
|
|
|
|
|
<#
|
|
|
|
Add a user to a local security group
|
|
|
|
#>
|
|
|
|
function Add-UserToGroup
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $username,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true, ParameterSetName = "SID")]
|
|
|
|
[string] $groupSid,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true, ParameterSetName = "Name")]
|
|
|
|
[string] $group
|
|
|
|
)
|
|
|
|
|
|
|
|
$userAD = [ADSI] "WinNT://$env:computername/${username},user"
|
|
|
|
|
|
|
|
if($PsCmdlet.ParameterSetName -eq "SID")
|
|
|
|
{
|
|
|
|
$ntAccount=ConvertTo-NtAccount $groupSid
|
|
|
|
$group =$ntAccount.Split("\\")[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
$groupAD = [ADSI] "WinNT://$env:computername/${group},group"
|
|
|
|
|
|
|
|
$groupAD.Add($userAD.AdsPath);
|
|
|
|
}
|
|
|
|
|
2016-08-31 22:02:12 +02:00
|
|
|
# tests if we should run a daily build
|
2017-01-16 22:31:14 +01:00
|
|
|
# returns true if the build is scheduled
|
2016-08-31 22:02:12 +02:00
|
|
|
# or is a pushed tag
|
|
|
|
Function Test-DailyBuild
|
|
|
|
{
|
2017-07-23 00:34:03 +02:00
|
|
|
$trueString = 'True'
|
|
|
|
if(($env:PS_DAILY_BUILD -eq $trueString) -or ($env:APPVEYOR_SCHEDULED_BUILD -eq $trueString) -or ($env:APPVEYOR_REPO_TAG_NAME))
|
2016-08-31 22:02:12 +02:00
|
|
|
{
|
|
|
|
return $true
|
|
|
|
}
|
2017-09-07 00:20:25 +02:00
|
|
|
|
2017-07-19 19:33:58 +02:00
|
|
|
# if [Feature] is in the commit message,
|
|
|
|
# Run Daily tests
|
|
|
|
if($env:APPVEYOR_REPO_COMMIT_MESSAGE -match '\[feature\]')
|
|
|
|
{
|
2017-07-23 00:34:03 +02:00
|
|
|
Set-AppveyorBuildVariable -Name PS_DAILY_BUILD -Value $trueString
|
2017-07-19 19:33:58 +02:00
|
|
|
return $true
|
|
|
|
}
|
2016-09-30 01:26:34 +02:00
|
|
|
|
2016-08-31 22:02:12 +02:00
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
|
|
# Sets a build variable
|
|
|
|
Function Set-BuildVariable
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string]
|
|
|
|
$Name,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string]
|
|
|
|
$Value
|
|
|
|
)
|
|
|
|
|
|
|
|
if($env:AppVeyor)
|
|
|
|
{
|
|
|
|
Set-AppveyorBuildVariable @PSBoundParameters
|
|
|
|
}
|
2017-01-16 22:31:14 +01:00
|
|
|
else
|
2016-08-31 22:02:12 +02:00
|
|
|
{
|
|
|
|
Set-Item env:/$name -Value $Value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-29 23:21:48 +02:00
|
|
|
# Emulates running all of AppVeyor but locally
|
|
|
|
# should not be used on AppVeyor
|
2016-08-29 22:12:01 +02:00
|
|
|
function Invoke-AppVeyorFull
|
|
|
|
{
|
2016-08-31 22:02:12 +02:00
|
|
|
param(
|
|
|
|
[switch] $APPVEYOR_SCHEDULED_BUILD,
|
|
|
|
[switch] $CleanRepo
|
|
|
|
)
|
|
|
|
if($CleanRepo)
|
|
|
|
{
|
|
|
|
Clear-PSRepo
|
|
|
|
}
|
|
|
|
|
|
|
|
if($env:APPVEYOR)
|
|
|
|
{
|
|
|
|
throw "This function is to simulate appveyor, but not to be run from appveyor!"
|
|
|
|
}
|
|
|
|
|
|
|
|
if($APPVEYOR_SCHEDULED_BUILD)
|
|
|
|
{
|
|
|
|
$env:APPVEYOR_SCHEDULED_BUILD = 'True'
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
Invoke-AppVeyorInstall
|
|
|
|
Invoke-AppVeyorBuild
|
|
|
|
Invoke-AppVeyorTest -ErrorAction Continue
|
|
|
|
Invoke-AppveyorFinish
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
if($APPVEYOR_SCHEDULED_BUILD -and $env:APPVEYOR_SCHEDULED_BUILD)
|
|
|
|
{
|
|
|
|
Remove-Item env:APPVEYOR_SCHEDULED_BUILD
|
|
|
|
}
|
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
|
2016-08-29 23:21:48 +02:00
|
|
|
# Implements the AppVeyor 'build_script' step
|
2016-08-29 22:12:01 +02:00
|
|
|
function Invoke-AppVeyorBuild
|
|
|
|
{
|
2017-11-21 22:51:10 +01:00
|
|
|
$releaseTag = Get-ReleaseTag
|
|
|
|
# check to be sure our test tags are correct
|
|
|
|
$result = Get-PesterTag
|
|
|
|
if ( $result.Result -ne "Pass" ) {
|
2016-08-29 22:12:01 +02:00
|
|
|
$result.Warnings
|
|
|
|
throw "Tags must be CI, Feature, Scenario, or Slow"
|
2017-11-21 22:51:10 +01:00
|
|
|
}
|
2016-11-11 20:12:07 +01:00
|
|
|
|
2017-11-21 22:51:10 +01:00
|
|
|
if(Test-DailyBuild)
|
|
|
|
{
|
2017-12-05 02:16:53 +01:00
|
|
|
Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore -CI -ReleaseTag $releaseTag
|
2017-11-21 22:51:10 +01:00
|
|
|
}
|
2016-11-11 20:12:07 +01:00
|
|
|
|
2017-12-05 02:16:53 +01:00
|
|
|
Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
|
2016-08-29 23:21:48 +02:00
|
|
|
# Implements the AppVeyor 'install' step
|
2016-08-29 22:12:01 +02:00
|
|
|
function Invoke-AppVeyorInstall
|
|
|
|
{
|
2017-08-01 23:35:50 +02:00
|
|
|
# Make sure we have all the tags
|
|
|
|
Sync-PSTags -AddRemoteIfMissing
|
2017-11-21 22:51:10 +01:00
|
|
|
$releaseTag = Get-ReleaseTag
|
2017-08-01 23:35:50 +02:00
|
|
|
if($env:APPVEYOR_BUILD_NUMBER)
|
|
|
|
{
|
2017-11-21 22:51:10 +01:00
|
|
|
Update-AppveyorBuild -Version $releaseTag
|
2017-08-01 23:35:50 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 22:02:12 +02:00
|
|
|
if(Test-DailyBuild){
|
|
|
|
$buildName = "[Daily]"
|
2017-07-19 19:33:58 +02:00
|
|
|
|
|
|
|
# Add daily to title if it's not already there
|
|
|
|
# It can be there already for rerun requests
|
|
|
|
if($env:APPVEYOR_PULL_REQUEST_TITLE -and $env:APPVEYOR_PULL_REQUEST_TITLE -notmatch '^\[Daily\]')
|
2016-08-31 22:02:12 +02:00
|
|
|
{
|
|
|
|
$buildName += $env:APPVEYOR_PULL_REQUEST_TITLE
|
|
|
|
}
|
2017-07-20 01:47:11 +02:00
|
|
|
elseif($env:APPVEYOR_PULL_REQUEST_TITLE)
|
2016-08-31 22:02:12 +02:00
|
|
|
{
|
2017-07-20 01:47:11 +02:00
|
|
|
$buildName = $env:APPVEYOR_PULL_REQUEST_TITLE
|
|
|
|
}
|
|
|
|
elseif($env:APPVEYOR_REPO_COMMIT_MESSAGE -notmatch '^\[Daily\].*$')
|
|
|
|
{
|
2016-08-31 22:02:12 +02:00
|
|
|
$buildName += $env:APPVEYOR_REPO_COMMIT_MESSAGE
|
|
|
|
}
|
2017-07-20 01:47:11 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$buildName = $env:APPVEYOR_REPO_COMMIT_MESSAGE
|
|
|
|
}
|
2016-08-31 22:02:12 +02:00
|
|
|
|
|
|
|
Update-AppveyorBuild -message $buildName
|
|
|
|
}
|
|
|
|
|
2016-10-11 00:24:04 +02:00
|
|
|
if ($env:APPVEYOR)
|
|
|
|
{
|
|
|
|
#
|
|
|
|
# Generate new credential for appveyor (only) remoting tests.
|
|
|
|
#
|
|
|
|
Write-Verbose "Creating account for remoting tests in AppVeyor."
|
|
|
|
|
|
|
|
# Password
|
|
|
|
$randomObj = [System.Random]::new()
|
|
|
|
$password = ""
|
2017-07-22 06:03:49 +02:00
|
|
|
1..(Get-Random -Minimum 15 -Maximum 126) | ForEach-Object { $password = $password + [char]$randomObj.next(45,126) }
|
2016-10-11 00:24:04 +02:00
|
|
|
|
|
|
|
# Account
|
|
|
|
$userName = 'appVeyorRemote'
|
|
|
|
New-LocalUser -username $userName -password $password
|
|
|
|
Add-UserToGroup -username $userName -groupSid $script:administratorsGroupSID
|
|
|
|
|
|
|
|
# Provide credentials globally for remote tests.
|
|
|
|
$ss = ConvertTo-SecureString -String $password -AsPlainText -Force
|
|
|
|
$appveyorRemoteCredential = [PSCredential]::new("$env:COMPUTERNAME\$userName", $ss)
|
|
|
|
$appveyorRemoteCredential | Export-Clixml -Path "$env:TEMP\AppVeyorRemoteCred.xml" -Force
|
|
|
|
|
|
|
|
# Check that LocalAccountTokenFilterPolicy policy is set, since it is needed for remoting
|
|
|
|
# using above local admin account.
|
|
|
|
Write-Verbose "Checking for LocalAccountTokenFilterPolicy in AppVeyor."
|
|
|
|
$haveLocalAccountTokenFilterPolicy = $false
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$haveLocalAccountTokenFilterPolicy = ((Get-ItemPropertyValue -Path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy) -eq 1)
|
|
|
|
}
|
|
|
|
catch { }
|
|
|
|
if (!$haveLocalAccountTokenFilterPolicy)
|
|
|
|
{
|
|
|
|
Write-Verbose "Setting the LocalAccountTokenFilterPolicy for remoting tests"
|
|
|
|
Set-ItemProperty -Path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy -Value 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-31 22:02:12 +02:00
|
|
|
Set-BuildVariable -Name TestPassed -Value False
|
2017-07-18 20:39:04 +02:00
|
|
|
Start-PSBootstrap -Confirm:$false
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
|
2016-08-29 23:21:48 +02:00
|
|
|
# A wrapper to ensure that we upload test results
|
|
|
|
# and that if we are not able to that it does not fail
|
|
|
|
# the CI build
|
2016-08-29 22:12:01 +02:00
|
|
|
function Update-AppVeyorTestResults
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[string] $resultsFile
|
|
|
|
)
|
|
|
|
|
|
|
|
if($env:Appveyor)
|
|
|
|
{
|
2017-01-16 22:31:14 +01:00
|
|
|
$retryCount = 0
|
2016-08-29 22:57:20 +02:00
|
|
|
$pushedResults = $false
|
2017-01-16 22:31:14 +01:00
|
|
|
$pushedArtifacts = $false
|
2016-08-29 22:57:20 +02:00
|
|
|
while( (!$pushedResults -or !$pushedResults) -and $retryCount -lt 3)
|
|
|
|
{
|
|
|
|
if($retryCount -gt 0)
|
|
|
|
{
|
|
|
|
Write-Verbose "Retrying updating test artifacts..."
|
|
|
|
}
|
|
|
|
|
|
|
|
$retryCount++
|
|
|
|
$resolvedResultsPath = (Resolve-Path $resultsFile)
|
|
|
|
try {
|
|
|
|
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $resolvedResultsPath)
|
|
|
|
$pushedResults = $true
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
Write-Warning "Pushing test result failed..."
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Push-AppveyorArtifact $resolvedResultsPath
|
|
|
|
$pushedArtifacts = $true
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
Write-Warning "Pushing test Artifact failed..."
|
|
|
|
}
|
|
|
|
}
|
2016-08-29 23:21:48 +02:00
|
|
|
|
2016-08-29 22:57:20 +02:00
|
|
|
if(!$pushedResults -or !$pushedResults)
|
|
|
|
{
|
|
|
|
Write-Warning "Failed to push all artifacts for $resultsFile"
|
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
2017-01-16 22:31:14 +01:00
|
|
|
else
|
2016-08-29 22:12:01 +02:00
|
|
|
{
|
|
|
|
Write-Warning "Not running in appveyor, skipping upload of test results: $resultsFile"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-29 23:21:48 +02:00
|
|
|
# Implement AppVeyor 'Test_script'
|
2017-01-16 22:31:14 +01:00
|
|
|
function Invoke-AppVeyorTest
|
2016-08-29 22:12:01 +02:00
|
|
|
{
|
2016-08-30 20:47:27 +02:00
|
|
|
[CmdletBinding()]
|
2018-06-11 23:18:51 +02:00
|
|
|
param(
|
|
|
|
[ValidateSet('UnelevatedPesterTests', 'ElevatedPesterTests_xUnit_Packaging')]
|
|
|
|
[string] $Purpose
|
|
|
|
)
|
2016-08-29 22:12:01 +02:00
|
|
|
#
|
|
|
|
# CoreCLR
|
2017-01-16 22:31:14 +01:00
|
|
|
|
2017-08-30 02:21:50 +02:00
|
|
|
$env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (Get-PSOptions))
|
2016-08-29 22:12:01 +02:00
|
|
|
Write-Host -Foreground Green 'Run CoreCLR tests'
|
2016-09-16 04:33:54 +02:00
|
|
|
$testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin.xml"
|
|
|
|
$testResultsAdminFile = "$pwd\TestsResultsAdmin.xml"
|
2018-01-03 21:43:28 +01:00
|
|
|
$SequentialXUnitTestResultsFile = "$pwd\SequentialXUnitTestResults.xml"
|
|
|
|
$ParallelXUnitTestResultsFile = "$pwd\ParallelXUnitTestResults.xml"
|
2017-10-18 02:25:11 +02:00
|
|
|
if(!(Test-Path "$env:CoreOutput\pwsh.exe"))
|
2016-08-29 22:12:01 +02:00
|
|
|
{
|
2017-10-18 02:25:11 +02:00
|
|
|
throw "CoreCLR pwsh.exe was not built"
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
2017-01-16 22:31:14 +01:00
|
|
|
|
2018-06-11 23:18:51 +02:00
|
|
|
# Pester doesn't allow Invoke-Pester -TagAll@('CI', 'RequireAdminOnWindows') currently
|
|
|
|
# https://github.com/pester/Pester/issues/608
|
|
|
|
# To work-around it, we exlude all categories, but 'CI' from the list
|
|
|
|
if (Test-DailyBuild) {
|
2016-09-26 22:16:32 +02:00
|
|
|
$ExcludeTag = @()
|
2016-09-16 04:33:54 +02:00
|
|
|
Write-Host -Foreground Green 'Running all CoreCLR tests..'
|
2016-08-31 22:02:12 +02:00
|
|
|
}
|
2018-06-11 23:18:51 +02:00
|
|
|
else {
|
2018-08-03 20:20:14 +02:00
|
|
|
$ExcludeTag = @('Slow', 'Feature', 'Scenario')
|
2018-06-11 23:18:51 +02:00
|
|
|
Write-Host -Foreground Green 'Running "CI" CoreCLR tests..'
|
|
|
|
}
|
2017-01-16 22:31:14 +01:00
|
|
|
|
2018-08-03 20:20:14 +02:00
|
|
|
# Get the experimental feature names and the tests associated with them
|
|
|
|
$ExperimentalFeatureTests = Get-ExperimentalFeatureTests
|
|
|
|
|
2018-06-11 23:18:51 +02:00
|
|
|
if ($Purpose -eq 'UnelevatedPesterTests') {
|
2018-08-03 20:20:14 +02:00
|
|
|
$arguments = @{
|
|
|
|
Bindir = $env:CoreOutput
|
|
|
|
OutputFile = $testResultsNonAdminFile
|
|
|
|
Unelevate = $true
|
|
|
|
Terse = $true
|
|
|
|
Tag = @()
|
|
|
|
ExcludeTag = $ExcludeTag + 'RequireAdminOnWindows'
|
|
|
|
}
|
|
|
|
Start-PSPester @arguments
|
2018-06-11 23:18:51 +02:00
|
|
|
Write-Host -Foreground Green 'Upload CoreCLR Non-Admin test results'
|
|
|
|
Update-AppVeyorTestResults -resultsFile $testResultsNonAdminFile
|
|
|
|
# Fail the build, if tests failed
|
|
|
|
Test-PSPesterResults -TestResultsFile $testResultsNonAdminFile
|
2018-08-03 20:20:14 +02:00
|
|
|
|
|
|
|
# Run tests with specified experimental features enabled
|
|
|
|
foreach ($entry in $ExperimentalFeatureTests.GetEnumerator()) {
|
|
|
|
$featureName = $entry.Key
|
|
|
|
$testFiles = $entry.Value
|
|
|
|
|
|
|
|
$expFeatureTestResultFile = "$pwd\TestsResultsNonAdmin.$featureName.xml"
|
|
|
|
$arguments['OutputFile'] = $expFeatureTestResultFile
|
|
|
|
$arguments['ExperimentalFeatureName'] = $featureName
|
|
|
|
if ($testFiles.Count -eq 0) {
|
|
|
|
# If an empty array is specified for the feature name, we run all tests with the feature enabled.
|
|
|
|
# This allows us to prevent regressions to a critical engine experimental feature.
|
|
|
|
$arguments.Remove('Path')
|
|
|
|
} else {
|
|
|
|
# If a non-empty string or array is specified for the feature name, we only run those test files.
|
|
|
|
$arguments['Path'] = $testFiles
|
|
|
|
}
|
|
|
|
Start-PSPester @arguments
|
|
|
|
|
|
|
|
Write-Host -ForegroundColor Green "Upload CoreCLR Non-Admin test results for experimental feature '$featureName'"
|
|
|
|
Update-AppVeyorTestResults -resultsFile $expFeatureTestResultFile
|
|
|
|
# Fail the build, if tests failed
|
|
|
|
Test-PSPesterResults -TestResultsFile $expFeatureTestResultFile
|
|
|
|
}
|
2016-09-16 04:33:54 +02:00
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
|
2018-06-11 23:18:51 +02:00
|
|
|
if ($Purpose -eq 'ElevatedPesterTests_xUnit_Packaging') {
|
2018-08-03 20:20:14 +02:00
|
|
|
$arguments = @{
|
|
|
|
Terse = $true
|
|
|
|
Bindir = $env:CoreOutput
|
|
|
|
OutputFile = $testResultsAdminFile
|
|
|
|
Tag = @('RequireAdminOnWindows')
|
|
|
|
ExcludeTag = $ExcludeTag
|
|
|
|
}
|
|
|
|
Start-PSPester @arguments
|
2018-06-11 23:18:51 +02:00
|
|
|
Write-Host -Foreground Green 'Upload CoreCLR Admin test results'
|
|
|
|
Update-AppVeyorTestResults -resultsFile $testResultsAdminFile
|
|
|
|
|
|
|
|
Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile
|
|
|
|
Write-Host -ForegroundColor Green 'Uploading PSxUnit test results'
|
|
|
|
Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFile
|
|
|
|
Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFile
|
|
|
|
|
|
|
|
# Fail the build, if tests failed
|
|
|
|
Test-PSPesterResults -TestResultsFile $testResultsAdminFile
|
|
|
|
@(
|
|
|
|
$SequentialXUnitTestResultsFile,
|
|
|
|
$ParallelXUnitTestResultsFile
|
|
|
|
) | ForEach-Object {
|
|
|
|
Test-XUnitTestResults -TestResultsFile $_
|
|
|
|
}
|
2018-08-03 20:20:14 +02:00
|
|
|
|
|
|
|
# Run tests with specified experimental features enabled
|
|
|
|
foreach ($entry in $ExperimentalFeatureTests.GetEnumerator()) {
|
|
|
|
$featureName = $entry.Key
|
|
|
|
$testFiles = $entry.Value
|
|
|
|
|
|
|
|
$expFeatureTestResultFile = "$pwd\TestsResultsAdmin.$featureName.xml"
|
|
|
|
$arguments['OutputFile'] = $expFeatureTestResultFile
|
|
|
|
$arguments['ExperimentalFeatureName'] = $featureName
|
|
|
|
if ($testFiles.Count -eq 0) {
|
|
|
|
# If an empty array is specified for the feature name, we run all tests with the feature enabled.
|
|
|
|
# This allows us to prevent regressions to a critical engine experimental feature.
|
|
|
|
$arguments.Remove('Path')
|
|
|
|
} else {
|
|
|
|
# If a non-empty string or array is specified for the feature name, we only run those test files.
|
|
|
|
$arguments['Path'] = $testFiles
|
|
|
|
}
|
|
|
|
Start-PSPester @arguments
|
|
|
|
|
|
|
|
Write-Host -ForegroundColor Green "Upload CoreCLR Admin test results for experimental feature '$featureName'"
|
|
|
|
Update-AppVeyorTestResults -resultsFile $expFeatureTestResultFile
|
|
|
|
# Fail the build, if tests failed
|
|
|
|
Test-PSPesterResults -TestResultsFile $expFeatureTestResultFile
|
|
|
|
}
|
2018-01-03 21:43:28 +01:00
|
|
|
}
|
2017-11-30 23:44:41 +01:00
|
|
|
|
2016-08-31 22:02:12 +02:00
|
|
|
Set-BuildVariable -Name TestPassed -Value True
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
|
2016-11-23 21:22:18 +01:00
|
|
|
#Implement AppVeyor 'after_test' phase
|
|
|
|
function Invoke-AppVeyorAfterTest
|
|
|
|
{
|
|
|
|
[CmdletBinding()]
|
|
|
|
param()
|
|
|
|
|
2018-06-11 23:18:51 +02:00
|
|
|
if (Test-DailyBuild)
|
2016-11-23 21:22:18 +01:00
|
|
|
{
|
|
|
|
## Publish code coverage build, tests and OpenCover module to artifacts, so webhook has the information.
|
2017-01-16 22:31:14 +01:00
|
|
|
## Build webhook is called after 'after_test' phase, hence we need to do this here and not in AppveyorFinish.
|
2016-11-23 21:22:18 +01:00
|
|
|
$codeCoverageOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Configuration CodeCoverage))
|
|
|
|
$codeCoverageArtifacts = Compress-CoverageArtifacts -CodeCoverageOutput $codeCoverageOutput
|
|
|
|
|
|
|
|
Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts'
|
2017-07-22 06:03:49 +02:00
|
|
|
$codeCoverageArtifacts | ForEach-Object { Push-AppveyorArtifact $_ }
|
2016-11-23 21:22:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2016-11-24 01:38:50 +01:00
|
|
|
$null = $artifacts.Add($zipTestContentPath)
|
2016-11-23 21:22:18 +01:00
|
|
|
|
|
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
|
|
$resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $PSScriptRoot '..\test\tools\OpenCover'))
|
|
|
|
$zipOpenCoverPath = Join-Path $pwd 'OpenCover.zip'
|
2017-01-16 22:31:14 +01:00
|
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($resolvedPath, $zipOpenCoverPath)
|
2016-11-24 01:38:50 +01:00
|
|
|
$null = $artifacts.Add($zipOpenCoverPath)
|
2016-11-23 21:22:18 +01:00
|
|
|
|
2016-12-15 19:35:55 +01:00
|
|
|
$zipCodeCoveragePath = Join-Path $pwd "CodeCoverage.zip"
|
2016-11-23 21:22:18 +01:00
|
|
|
Write-Verbose "Zipping ${CodeCoverageOutput} into $zipCodeCoveragePath" -verbose
|
|
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($CodeCoverageOutput, $zipCodeCoveragePath)
|
2016-11-24 01:38:50 +01:00
|
|
|
$null = $artifacts.Add($zipCodeCoveragePath)
|
2016-11-23 21:22:18 +01:00
|
|
|
|
|
|
|
return $artifacts
|
|
|
|
}
|
|
|
|
|
2017-11-21 22:51:10 +01:00
|
|
|
function Get-ReleaseTag
|
|
|
|
{
|
|
|
|
$metaDataPath = Join-Path -Path $PSScriptRoot -ChildPath 'metadata.json'
|
|
|
|
$metaData = Get-Content $metaDataPath | ConvertFrom-Json
|
|
|
|
|
|
|
|
$releaseTag = $metadata.NextReleaseTag
|
|
|
|
if($env:APPVEYOR_BUILD_NUMBER)
|
|
|
|
{
|
|
|
|
$releaseTag = $releaseTag.split('.')[0..2] -join '.'
|
|
|
|
$releaseTag = $releaseTag+'.'+$env:APPVEYOR_BUILD_NUMBER
|
|
|
|
}
|
|
|
|
|
|
|
|
return $releaseTag
|
|
|
|
}
|
|
|
|
|
2016-08-29 23:21:48 +02:00
|
|
|
# Implements AppVeyor 'on_finish' step
|
2016-08-29 22:12:01 +02:00
|
|
|
function Invoke-AppveyorFinish
|
|
|
|
{
|
2016-08-31 22:02:12 +02:00
|
|
|
try {
|
2017-11-21 22:51:10 +01:00
|
|
|
$releaseTag = Get-ReleaseTag
|
|
|
|
|
2018-03-08 04:47:21 +01:00
|
|
|
# Build clean before backing to remove files from testing
|
|
|
|
Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag -Clean
|
|
|
|
|
2016-08-29 22:12:01 +02:00
|
|
|
# Build packages
|
2017-12-11 22:57:02 +01:00
|
|
|
$packages = Start-PSPackage -Type msi,nupkg,zip -ReleaseTag $releaseTag -SkipReleaseChecks
|
2016-08-31 22:02:12 +02:00
|
|
|
|
2016-08-29 22:12:01 +02:00
|
|
|
$artifacts = New-Object System.Collections.ArrayList
|
|
|
|
foreach ($package in $packages) {
|
2018-03-08 04:47:21 +01:00
|
|
|
if($package -is [string])
|
|
|
|
{
|
|
|
|
$null = $artifacts.Add($package)
|
|
|
|
}
|
|
|
|
elseif($package -is [pscustomobject] -and $package.msi)
|
|
|
|
{
|
|
|
|
$null = $artifacts.Add($package.msi)
|
|
|
|
$null = $artifacts.Add($package.wixpdb)
|
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
2016-08-31 22:02:12 +02:00
|
|
|
|
2016-08-29 22:12:01 +02:00
|
|
|
if ($env:APPVEYOR_REPO_TAG_NAME)
|
|
|
|
{
|
2017-09-07 00:20:25 +02:00
|
|
|
$preReleaseVersion = $env:APPVEYOR_REPO_TAG_NAME
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-21 22:51:10 +01:00
|
|
|
$previewVersion = $releaseTag.Split('-')
|
2017-09-07 00:20:25 +02:00
|
|
|
$previewPrefix = $previewVersion[0]
|
|
|
|
$previewLabel = $previewVersion[1].replace('.','')
|
|
|
|
|
2016-08-31 22:02:12 +02:00
|
|
|
if(Test-DailyBuild)
|
|
|
|
{
|
2017-09-07 00:20:25 +02:00
|
|
|
$previewLabel= "daily{0}" -f $previewLabel
|
2016-08-31 22:02:12 +02:00
|
|
|
}
|
|
|
|
|
2017-09-07 00:20:25 +02:00
|
|
|
$preReleaseVersion = "$previewPrefix-$previewLabel.$env:APPVEYOR_BUILD_NUMBER"
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-02 19:47:29 +02:00
|
|
|
# the packaging tests find the MSI package using env:PSMsiX64Path
|
|
|
|
$env:PSMsiX64Path = $artifacts | Where-Object { $_.EndsWith(".msi")}
|
2018-03-21 20:23:24 +01:00
|
|
|
|
2018-04-02 19:47:29 +02:00
|
|
|
# Install the latest Pester and import it
|
|
|
|
Install-Module Pester -Force -SkipPublisherCheck
|
|
|
|
Import-Module Pester -Force
|
2018-02-08 00:00:42 +01:00
|
|
|
|
2018-04-02 19:47:29 +02:00
|
|
|
# start the packaging tests and get the results
|
|
|
|
$packagingTestResult = Invoke-Pester -Script (Join-Path $repoRoot '.\test\packaging\windows\') -PassThru
|
2018-03-21 20:23:24 +01:00
|
|
|
|
2018-04-02 19:47:29 +02:00
|
|
|
# fail the CI job if the tests failed, or nothing passed
|
|
|
|
if($packagingTestResult.FailedCount -ne 0 -or !$packagingTestResult.PassedCount)
|
2018-03-21 20:23:24 +01:00
|
|
|
{
|
2018-04-02 19:47:29 +02:00
|
|
|
throw "Packaging tests failed ($($packagingTestResult.FailedCount) failed/$($packagingTestResult.PassedCount) passed)"
|
2018-03-21 20:23:24 +01:00
|
|
|
}
|
|
|
|
|
2017-12-11 22:57:02 +01:00
|
|
|
# only publish assembly nuget packages if it is a daily build and tests passed
|
2016-08-31 22:02:12 +02:00
|
|
|
if((Test-DailyBuild) -and $env:TestPassed -eq 'True')
|
2016-08-29 22:12:01 +02:00
|
|
|
{
|
2017-09-07 00:20:25 +02:00
|
|
|
Publish-NuGetFeed -OutputPath .\nuget-artifacts -ReleaseTag $preReleaseVersion
|
2017-12-11 22:57:02 +01:00
|
|
|
$nugetArtifacts = Get-ChildItem .\nuget-artifacts -ErrorAction SilentlyContinue | ForEach-Object { $_.FullName }
|
|
|
|
if($nugetArtifacts)
|
|
|
|
{
|
|
|
|
$artifacts.AddRange($nugetArtifacts)
|
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
|
|
|
|
2017-12-11 22:57:02 +01:00
|
|
|
if (Test-DailyBuild)
|
2016-12-01 21:58:14 +01:00
|
|
|
{
|
2017-12-11 22:57:02 +01:00
|
|
|
# produce win-arm and win-arm64 packages if it is a daily build
|
2018-03-09 18:50:26 +01:00
|
|
|
Start-PSBuild -Restore -Runtime win-arm -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag
|
2017-12-11 22:57:02 +01:00
|
|
|
$arm32Package = Start-PSPackage -Type zip -WindowsRuntime win-arm -ReleaseTag $releaseTag -SkipReleaseChecks
|
|
|
|
$artifacts.Add($arm32Package)
|
|
|
|
|
2018-03-09 18:50:26 +01:00
|
|
|
Start-PSBuild -Restore -Runtime win-arm64 -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag
|
2017-12-11 22:57:02 +01:00
|
|
|
$arm64Package = Start-PSPackage -Type zip -WindowsRuntime win-arm64 -ReleaseTag $releaseTag -SkipReleaseChecks
|
|
|
|
$artifacts.Add($arm64Package)
|
2016-12-01 21:58:14 +01:00
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
|
|
|
|
$pushedAllArtifacts = $true
|
2017-01-16 22:31:14 +01:00
|
|
|
$artifacts | ForEach-Object {
|
2016-08-29 22:12:01 +02:00
|
|
|
Write-Host "Pushing $_ as Appveyor artifact"
|
|
|
|
if(Test-Path $_)
|
|
|
|
{
|
|
|
|
if($env:Appveyor)
|
|
|
|
{
|
|
|
|
Push-AppveyorArtifact $_
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-31 22:02:12 +02:00
|
|
|
$pushedAllArtifacts = $false
|
|
|
|
Write-Warning "Artifact $_ does not exist."
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
2017-08-01 23:35:50 +02:00
|
|
|
|
|
|
|
if($env:NUGET_KEY -and $env:NUGET_URL -and [system.io.path]::GetExtension($_) -ieq '.nupkg')
|
|
|
|
{
|
2018-03-08 19:47:20 +01:00
|
|
|
Write-Log "pushing $_ to $env:NUGET_URL"
|
2017-08-01 23:35:50 +02:00
|
|
|
Start-NativeExecution -sb {dotnet nuget push $_ --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode
|
2017-09-07 00:20:25 +02:00
|
|
|
}
|
2016-08-31 22:02:12 +02:00
|
|
|
}
|
2016-08-29 22:12:01 +02:00
|
|
|
if(!$pushedAllArtifacts)
|
|
|
|
{
|
2016-08-31 22:02:12 +02:00
|
|
|
throw "Some artifacts did not exist!"
|
2016-08-29 22:12:01 +02:00
|
|
|
}
|
2017-01-16 22:31:14 +01:00
|
|
|
}
|
2016-08-31 22:02:12 +02:00
|
|
|
catch {
|
2016-08-29 22:12:01 +02:00
|
|
|
Write-Host -Foreground Red $_
|
2018-03-09 00:58:59 +01:00
|
|
|
throw $_
|
2018-02-08 00:00:42 +01:00
|
|
|
}
|
2016-08-31 22:02:12 +02:00
|
|
|
}
|