Skip to content

Commit

Permalink
[devops] Move the reporting of test results to a separate stage. (#20011
Browse files Browse the repository at this point in the history
)

This paves the way for collecting test results from multiple stages (and
eventually we'll have a single GitHub comment with all the test results,
instead of multiple comments like we have now).
  • Loading branch information
rolfbjarne committed Feb 23, 2024
1 parent e7fc1ad commit 8f868e6
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 350 deletions.
15 changes: 7 additions & 8 deletions tools/devops/automation/scripts/TestConfiguration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ Describe 'Get-TestConfiguration' {
"splitByPlatforms": "false",
"containsDotNetTests": "true",
"containsLegacyTests": "true",
"testPrefix": "test-prefix_",
},
{
"label": "dotnettests",
"splitByPlatforms": "true",
"containsDotNetTests": "true",
"containsLegacyTests": "false",
"needsMultiplePlatforms": "true",
"testPrefix": "test-prefix_",
},
{
"label": "monotouchtest",
"splitByPlatforms": "true",
"containsDotNetTests": "true",
"containsLegacyTests": "true",
"needsMultiplePlatforms": "false",
"testPrefix": "test-prefix_",
}
]
"@
Expand Down Expand Up @@ -80,8 +83,7 @@ Describe 'Get-TestConfiguration' {
-SupportedPlatforms $SupportedPlatforms `
-EnabledPlatforms $EnabledPlatforms `
-TestsLabels "extra-test-labels" `
-StatusContext "status-context" `
-TestPrefix "test-prefix_"
-StatusContext "status-context"
Write-Host $config
$config | Should -Be @"
{
Expand Down Expand Up @@ -196,8 +198,7 @@ Describe 'Get-TestConfiguration' {
-SupportedPlatforms $SupportedPlatforms `
-EnabledPlatforms $EnabledPlatforms `
-TestsLabels "extra-test-labels" `
-StatusContext "status-context" `
-TestPrefix "test-prefix_"
-StatusContext "status-context"
Write-Host $config
$config | Should -Be @"
{
Expand Down Expand Up @@ -249,8 +250,7 @@ Describe 'Get-TestConfiguration' {
-SupportedPlatforms $SupportedPlatforms `
-EnabledPlatforms $EnabledPlatforms `
-TestsLabels "extra-test-labels" `
-StatusContext "status-context" `
-TestPrefix "test-prefix_"
-StatusContext "status-context"
Write-Host $config
$config | Should -Be @"
{
Expand Down Expand Up @@ -284,8 +284,7 @@ Describe 'Get-TestConfiguration' {
-SupportedPlatforms $SupportedPlatforms `
-EnabledPlatforms $EnabledPlatforms `
-TestsLabels "extra-test-labels" `
-StatusContext "status-context" `
-TestPrefix "test-prefix_"
-StatusContext "status-context"
Write-Host $config
$config | Should -Be @"
{
Expand Down
17 changes: 6 additions & 11 deletions tools/devops/automation/scripts/TestConfiguration.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ class TestConfiguration {
[string[]] $enabledPlatforms
[string] $testsLabels
[string] $statusContext
[string] $testPrefix

TestConfiguration (
[object] $testConfigurations,
[object] $supportedPlatforms,
[string[]] $enabledPlatforms,
[string] $testsLabels,
[string] $statusContext,
[string] $testPrefix) {
[string] $statusContext) {
$this.testConfigurations = $testConfigurations
$this.supportedPlatforms = $supportedPlatforms
$this.enabledPlatforms = $enabledPlatforms
$this.testsLabels = $testsLabels
$this.statusContext = $statusContext
$this.testPrefix = $testPrefix
}

[string] Create() {
Expand All @@ -28,6 +25,7 @@ class TestConfiguration {
$label = $config.label
$underscoredLabel = $label.Replace('-','_')
$splitByPlatforms = $config.splitByPlatforms
$testPrefix = $config.testPrefix

$vars = [ordered]@{}
# set common variables
Expand Down Expand Up @@ -92,7 +90,7 @@ class TestConfiguration {
# set platform-specific variables
$platformVars["LABEL_WITH_PLATFORM"] = "$($label)_$($platform)"
$platformVars["STATUS_CONTEXT"] = "$($this.statusContext) - $($label) - $($platform)"
$platformVars["TEST_PREFIX"] = "$($this.testPrefix)$($underscoredLabel)_$($platform.ToLower())"
$platformVars["TEST_PREFIX"] = "$($testPrefix)$($underscoredLabel)_$($platform.ToLower())"
if ($platform -eq "Multiple") {
$platformVars["TEST_PLATFORM"] = ""
$platformVars["TEST_FILTER"] = "Category = MultiPlatform"
Expand All @@ -107,7 +105,7 @@ class TestConfiguration {
# set non-platform specific variables
$vars["LABEL_WITH_PLATFORM"] = "$label"
$vars["STATUS_CONTEXT"] = "$($this.statusContext) - $($label)"
$vars["TEST_PREFIX"] = "$($this.testPrefix)$($underscoredLabel)"
$vars["TEST_PREFIX"] = "$($testPrefix)$($underscoredLabel)"
$vars["TEST_PLATFORM"] = ""
$rv[$label] = $vars
}
Expand Down Expand Up @@ -138,16 +136,13 @@ function Get-TestConfiguration {
$TestsLabels,

[string]
$StatusContext,

[string]
$TestPrefix
$StatusContext
)

$objTestConfigurations = ConvertFrom-Json -InputObject $TestConfigurations
$objSupportedPlatforms = ConvertFrom-Json -InputObject $SupportedPlatforms
$arrEnabledPlatforms = -split $EnabledPlatforms
$config = [TestConfiguration]::new($objTestConfigurations, $objSupportedPlatforms, $arrEnabledPlatforms, $TestsLabels, $StatusContext, $TestPrefix)
$config = [TestConfiguration]::new($objTestConfigurations, $objSupportedPlatforms, $arrEnabledPlatforms, $TestsLabels, $StatusContext)
return $config.Create()
}

Expand Down
Loading

8 comments on commit 8f868e6

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.