Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions tools/devops/automation/scripts/TestResults.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TestResult {
[string] $TestStage
[string] $DisplayName
[bool] $IsMacTest
[bool] $VSDropsPublishFailed
hidden [int] $Passed
hidden [int] $Failed
hidden [string[]] $NotTestSummaryLabels = @()
Expand Down Expand Up @@ -339,9 +340,13 @@ class ParallelTestsResults {
}

[string] GetDownloadLinks($testResult) {
$dropsIndex = "$($this.VSDropsIndex)/$($testResult.TestStage)$($testResult.Title)-$($testResult.Attempt)/;/tests/vsdrops_index.html"
$artifactUrl = "$Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$Env:SYSTEM_TEAMPROJECT/_apis/build/builds/$Env:BUILD_BUILDID/artifacts?artifactName=HtmlReport-$($testResult.TestStage)$($testResult.Title)-$($testResult.Attempt)&api-version=6.0&`$format=zip"
$downloadInfo = "[Html Report (VSDrops)]($dropsIndex) [Download]($artifactUrl)"
if ($testResult.VSDropsPublishFailed) {
$downloadInfo = "(Publish failed) [Download]($artifactUrl)"
} else {
$dropsIndex = "$($this.VSDropsIndex)/$($testResult.TestStage)$($testResult.Title)-$($testResult.Attempt)/;/tests/vsdrops_index.html"
$downloadInfo = "[Html Report (VSDrops)]($dropsIndex) [Download]($artifactUrl)"
}
return $downloadInfo
}

Expand Down Expand Up @@ -589,6 +594,7 @@ class ParallelTestsResults {
$platformKey = $outputs.Keys | Where-Object { $_.EndsWith(".TESTS_PLATFORM") }
$attemptKey = $outputs.Keys | Where-Object { $_.EndsWith(".TESTS_ATTEMPT") }
$titleKey = $outputs.Keys | Where-Object { $_.EndsWith(".TESTS_TITLE") }
$vsdropsPublishedKey = $outputs.Keys | Where-Object { $_.EndsWith(".VSDROPS_PUBLISHED") }
} else {
# matrix job
$jobName = $name.Substring(0, $name.IndexOf('.'))
Expand All @@ -597,6 +603,7 @@ class ParallelTestsResults {
$platformKey = $outputs.Keys | Where-Object { $_.StartsWith($jobName + ".") -and $_.EndsWith(".TESTS_PLATFORM") }
$attemptKey = $outputs.Keys | Where-Object { $_.StartsWith($jobName + ".") -and $_.EndsWith(".TESTS_ATTEMPT") }
$titleKey = $outputs.Keys | Where-Object { $_.StartsWith($jobName + ".") -and $_.EndsWith(".TESTS_TITLE") }
$vsdropsPublishedKey = $outputs.Keys | Where-Object { $_.StartsWith($jobName + ".") -and $_.EndsWith(".VSDROPS_PUBLISHED") }
}

Write-Host "Keys for Label='$label' and JobName='$jobName' (dotCount=$dotCount): TitleKey='$titleKey' StatusKey=$statusKey BotKey=$botKey PlatformKey=$platformKey AttemptKey=$attemptKey"
Expand All @@ -611,6 +618,7 @@ class ParallelTestsResults {
$platform = if ($platformKey -eq $null) { "NotFound" } else { $outputs[$platformKey] }
$attempt = if ($attemptKey -eq $null) { -2 } else { [int]$outputs[$attemptKey] }
$title = if ($titleKey -eq $null) { "NotFound" } else { $outputs[$titleKey] }
$vsdropsPublished = if ($vsdropsPublishedKey -eq $null) { $null } else { $outputs[$vsdropsPublishedKey] }
$testResult = [PSCustomObject]@{
Label = $label
Title = $title
Expand All @@ -619,6 +627,7 @@ class ParallelTestsResults {
Platform = $platform
Attempt = $attempt
TestStage = $testStage
VSDropsPublished = $vsdropsPublished
}
if ($tests.Contains($label)) {
$testInfo = $tests[$label]
Expand Down Expand Up @@ -675,6 +684,7 @@ class ParallelTestsResults {
}

$result = [TestResult]::new($testSummaryPath, $status, $testConfig, $testAttempt)
$result.VSDropsPublishFailed = ($testResult.VSDropsPublished -eq "Failed")
}

$testResults += $result
Expand Down
17 changes: 17 additions & 0 deletions tools/devops/automation/templates/mac/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,15 @@ steps:
condition: succeededOrFailed()

# Upload to VSDrops so that the Html Report link in the GitHub comment works.
- bash: |
echo "##vso[task.setvariable variable=JOB_STATUS_BEFORE_VSDROPS]$AGENT_JOBSTATUS"
displayName: 'Capture job status before VSDrops publish'
condition: succeededOrFailed()
continueOnError: true

- task: artifactDropTask@1
displayName: 'Publish to Artifact Services Drop'
name: publishVSDrops
inputs:
dropServiceURI: 'https://devdiv.artifacts.visualstudio.com/DefaultCollection'
dropMetadataContainerName: '${{ parameters.uploadPrefix }}DropMetadata-${{ parameters.stageName }}${{ parameters.label }}-$(System.JobAttempt)'
Expand All @@ -223,6 +230,16 @@ steps:
continueOnError: true
condition: succeededOrFailed()

- bash: |
if [ "$JOB_STATUS_BEFORE_VSDROPS" != "$AGENT_JOBSTATUS" ]; then
echo "VSDrops publish changed job status from '$JOB_STATUS_BEFORE_VSDROPS' to '$AGENT_JOBSTATUS'"
echo "##vso[task.setvariable variable=VSDROPS_PUBLISHED;isOutput=true]Failed"
fi
name: setVSDropsPublishResult
displayName: 'Set VSDrops publish result'
continueOnError: true
condition: succeededOrFailed()

# Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build.
- task: ArchiveFiles@1
displayName: 'Archive HtmlReport'
Expand Down
17 changes: 17 additions & 0 deletions tools/devops/automation/templates/tests/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@ steps:
continueOnError: true
condition: succeededOrFailed()

- bash: |
echo "##vso[task.setvariable variable=JOB_STATUS_BEFORE_VSDROPS]$AGENT_JOBSTATUS"
displayName: 'Capture job status before VSDrops publish'
condition: succeededOrFailed()
continueOnError: true

- task: artifactDropTask@1
displayName: 'Publish to Artifact Services Drop'
name: publishVSDrops
inputs:
dropServiceURI: 'https://devdiv.artifacts.visualstudio.com/DefaultCollection'
dropMetadataContainerName: '${{ parameters.uploadPrefix }}DropMetadata-${{ parameters.testPrefix }}${{ parameters.labelWithPlatform }}-$(System.JobAttempt)'
Expand All @@ -195,6 +202,16 @@ steps:
continueOnError: true
condition: succeededOrFailed()

- bash: |
if [ "$JOB_STATUS_BEFORE_VSDROPS" != "$AGENT_JOBSTATUS" ]; then
echo "VSDrops publish changed job status from '$JOB_STATUS_BEFORE_VSDROPS' to '$AGENT_JOBSTATUS'"
echo "##vso[task.setvariable variable=VSDROPS_PUBLISHED;isOutput=true]Failed"
fi
name: setVSDropsPublishResult
displayName: 'Set VSDrops publish result'
continueOnError: true
condition: succeededOrFailed()

- bash: |
set -ex
find . -name 'vsts-*.xml' || true
Expand Down
Loading