817f598e20
Moves PGO runs to supported Helix pools. We need to match Microsoft-UI-XAML on which Helix pools we used for each type of activities. ## PR Checklist * [x] Closes #10850 * [x] I work here * [x] If it builds, it sits. ## Validation Steps Performed * [x] Run PGO build against this branch
131 lines
4.9 KiB
PowerShell
131 lines
4.9 KiB
PowerShell
Param(
|
|
[string]$AccessToken = $env:SYSTEM_ACCESSTOKEN,
|
|
[string]$HelixAccessToken = $env:HelixAccessToken,
|
|
[string]$CollectionUri = $env:SYSTEM_COLLECTIONURI,
|
|
[string]$TeamProject = $env:SYSTEM_TEAMPROJECT,
|
|
[string]$BuildUri = $env:BUILD_BUILDURI,
|
|
[string]$OutputFolder = "HelixOutput"
|
|
)
|
|
|
|
$helixLinkFile = "$OutputFolder\LinksToHelixTestFiles.html"
|
|
|
|
|
|
function Generate-File-Links
|
|
{
|
|
Param ([Array[]]$files,[string]$sectionName)
|
|
if($files.Count -gt 0)
|
|
{
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "<div class=$sectionName>"
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "<h4>$sectionName</h4>"
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "<ul>"
|
|
foreach($file in $files)
|
|
{
|
|
$url = Append-HelixAccessTokenToUrl $file.Link "{Your-Helix-Access-Token-Here}"
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "<li>$($url)</li>"
|
|
}
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "</ul>"
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "</div>"
|
|
}
|
|
}
|
|
|
|
function Append-HelixAccessTokenToUrl
|
|
{
|
|
Param ([string]$url, [string]$token)
|
|
if($token)
|
|
{
|
|
if($url.Contains("?"))
|
|
{
|
|
$url = "$($url)&access_token=$($token)"
|
|
}
|
|
else
|
|
{
|
|
$url = "$($url)?access_token=$($token)"
|
|
}
|
|
}
|
|
return $url
|
|
}
|
|
|
|
#Create output directory
|
|
New-Item $OutputFolder -ItemType Directory
|
|
|
|
$azureDevOpsRestApiHeaders = @{
|
|
"Accept"="application/json"
|
|
"Authorization"="Basic $([System.Convert]::ToBase64String([System.Text.ASCIIEncoding]::ASCII.GetBytes(":$AccessToken")))"
|
|
}
|
|
|
|
. "$PSScriptRoot/AzurePipelinesHelperScripts.ps1"
|
|
|
|
$queryUri = GetQueryTestRunsUri -CollectionUri $CollectionUri -TeamProject $TeamProject -BuildUri $BuildUri -IncludeRunDetails
|
|
Write-Host "queryUri = $queryUri"
|
|
|
|
$testRuns = Invoke-RestMethodWithRetries $queryUri -Headers $azureDevOpsRestApiHeaders
|
|
$webClient = New-Object System.Net.WebClient
|
|
[System.Collections.Generic.List[string]]$workItems = @()
|
|
|
|
foreach ($testRun in $testRuns.value)
|
|
{
|
|
Write-Host "testRunUri = $testRun.url"
|
|
$testResults = Invoke-RestMethodWithRetries "$($testRun.url)/results?api-version=5.0" -Headers $azureDevOpsRestApiHeaders
|
|
$isTestRunNameShown = $false
|
|
|
|
foreach ($testResult in $testResults.value)
|
|
{
|
|
$info = ConvertFrom-Json $testResult.comment
|
|
$helixJobId = $info.HelixJobId
|
|
$helixWorkItemName = $info.HelixWorkItemName
|
|
|
|
$workItem = "$helixJobId-$helixWorkItemName"
|
|
|
|
Write-Host "Helix Work Item = $workItem"
|
|
|
|
if (-not $workItems.Contains($workItem))
|
|
{
|
|
$workItems.Add($workItem)
|
|
$filesQueryUri = "https://helix.dot.net/api/2019-06-17/jobs/$helixJobId/workitems/$helixWorkItemName/files"
|
|
$filesQueryUri = Append-HelixAccessTokenToUrl $filesQueryUri $helixAccessToken
|
|
$files = Invoke-RestMethodWithRetries $filesQueryUri
|
|
|
|
$screenShots = $files | where { $_.Name.EndsWith(".jpg") }
|
|
$dumps = $files | where { $_.Name.EndsWith(".dmp") }
|
|
$pgcFiles = $files | where { $_.Name.EndsWith(".pgc") }
|
|
if ($screenShots.Count + $dumps.Count + $pgcFiles.Count -gt 0)
|
|
{
|
|
if(-Not $isTestRunNameShown)
|
|
{
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "<h2>$($testRun.name)</h2>"
|
|
$isTestRunNameShown = $true
|
|
}
|
|
Out-File -FilePath $helixLinkFile -Append -InputObject "<h3>$helixWorkItemName</h3>"
|
|
Generate-File-Links $screenShots "Screenshots"
|
|
Generate-File-Links $dumps "CrashDumps"
|
|
Generate-File-Links $pgcFiles "PGC files"
|
|
$misc = $files | where { ($screenShots -NotContains $_) -And ($dumps -NotContains $_) -And ($visualTreeVerificationFiles -NotContains $_) -And ($pgcFiles -NotContains $_) }
|
|
Generate-File-Links $misc "Misc"
|
|
|
|
foreach($pgcFile in $pgcFiles)
|
|
{
|
|
$flavorPath = $testResult.automatedTestName.Split('.')[0]
|
|
$archPath = $testResult.automatedTestName.Split('.')[1]
|
|
$fileName = $pgcFile.Name
|
|
$fullPath = "$OutputFolder\PGO\$flavorPath\$archPath"
|
|
$destination = "$fullPath\$fileName"
|
|
|
|
Write-Host "Copying $($pgcFile.Name) to $destination"
|
|
|
|
if (-Not (Test-Path $fullPath))
|
|
{
|
|
New-Item $fullPath -ItemType Directory
|
|
}
|
|
|
|
$link = $pgcFile.Link
|
|
|
|
Write-Host "Downloading $link to $destination"
|
|
|
|
$link = Append-HelixAccessTokenToUrl $link $HelixAccessToken
|
|
Download-FileWithRetries $link $destination
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|