Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DRAFT] [devops/tests] Create a html report for the Windows tests
Browse files Browse the repository at this point in the history
This is very much in progress, no need to review.
rolfbjarne committed Dec 20, 2024
1 parent 677bf86 commit 4627556
Showing 19 changed files with 402 additions and 90 deletions.
177 changes: 177 additions & 0 deletions scripts/create-html-report/create-html-report.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/*
# Expected files:
# Expected files:
#
# $Env:BUILD_SOURCESDIRECTORY/xamarin-macios/jenkins-results/windows-remote-dotnet-tests.trx"
# $(Build.SourcesDirectory)/xamarin-macios/jenkins-results/windows-dotnet-tests.trx"
# $Env:BUILD_SOURCESDIRECTORY/xamarin-macios/jenkins-results/windows/bgen-tests/results.trx
#
# $Env:BUILD_SOURCESDIRECTORY\xamarin-macios\jenkins-results\windows-remote-logs.zip
#
*/

using System.IO;
using System.Text;
using System.Xml;

public class Program {
static string GetOutcomeColor (string outcome)
{
switch (outcome.ToLower ()) {
case "passed":
case "completed":
return "green";
default:
return "red";
}
}

static string FormatHtml (string text)
{
text = text.Replace ("\r", "");
text = text.Replace ("&", "&");
text = text.Replace ("<", "&lt;");
text = text.Replace (">", "&gt;");
text = text.Replace (" ", "&nbsp;&nbsp;");
text = text.Replace (" &nbsp;", "&nbsp;&nbsp;");
text = text.Replace ("&nbsp; ", "&nbsp;&nbsp;");
text = text.Replace ("\n", "<br />\n");
return text;
}

static string GetSourcesDirectory ()
{
var pwd = Environment.CurrentDirectory!;
var dir = pwd;
while (true) {
if (Directory.Exists (Path.Combine (dir, ".git")))
return dir;
var parentDir = Path.GetDirectoryName (dir);
if (string.IsNullOrEmpty (parentDir) || parentDir == dir || parentDir.Length <= 2)
throw new Exception ($"Unable to find a .git subdirectory in any directory up the directory hierarchy from {pwd}");
dir = parentDir;
}
throw new Exception ($"Unable to find a .git subdirectory in any directory up the directory hierarchy from {pwd}");
}

public static int Main (string [] args)
{
var sourcesDirectory = GetSourcesDirectory ();
var allTestsSucceeded = true;
var outputDirectory = Path.Combine (sourcesDirectory, "jenkins-results");
var indexFile = Path.Combine (outputDirectory, "index.html");
var summaryFile = Path.Combine (sourcesDirectory, "tests", "TestSummary.md");

var trxFiles = new [] {
new { Name = "Remote .NET tests", TestResults = Path.Combine (outputDirectory, "windows-remote-dotnet-tests.trx") },
new { Name = "Local .NET tests", TestResults = Path.Combine (outputDirectory, "windows-dotnet-tests.trx") },
new { Name = "Generator tests", TestResults = Path.Combine (outputDirectory, "windows", "bgen-tests", "results.trx") },
};

var extraFiles = new []{
Path.Combine(outputDirectory, "windows-remote-logs.zip"),
};

var indexContents = new StringBuilder ();
var summaryContents = new StringBuilder ();

indexContents.AppendLine ($"<!DOCTYPE html>");
indexContents.AppendLine ($"<html>");
indexContents.AppendLine ($" <head>");
indexContents.AppendLine ($" <meta charset=\"utf-8\"/>");
indexContents.AppendLine ($" <title>Test results</title>");
indexContents.AppendLine ($" <style>");
indexContents.AppendLine ($" .pdiv {{");
indexContents.AppendLine ($" display: table;");
indexContents.AppendLine ($" padding-top: 10px;");
indexContents.AppendLine ($" }}");
indexContents.AppendLine ($" </style>");
indexContents.AppendLine ($" </head>");
indexContents.AppendLine ($" <body>");
indexContents.AppendLine ($" <h1>Test results</h1>");
foreach (var trx in trxFiles) {
var name = trx.Name;
var path = trx.TestResults;
string? outcome;
var messageLines = new List<string> ();

try {
var xml = new XmlDocument ();
xml.Load (path);
outcome = xml.SelectSingleNode ("/*[local-name() = 'TestRun']/*[local-name() = 'ResultSummary']")?.Attributes? ["outcome"]?.Value;
if (outcome is null) {
outcome = $"Could not find outcome in trx file {path}";
} else {
var failedTests = xml.SelectNodes ("/*[local-name() = 'TestRun']/*[local-name() = 'Results']/*[local-name() = 'UnitTestResult'][@outcome != 'Passed']")?.Cast<XmlNode> ();
if (failedTests?.Any () == true) {
messageLines.Add (" <ul>");
foreach (var node in failedTests) {
var testName = node.Attributes? ["testName"]?.Value ?? "<unknown test name>";
var testOutcome = node.Attributes? ["outcome"]?.Value ?? "<unknown test outcome>";
var testMessage = node.SelectSingleNode ("*[local-name() = 'Output']/*[local-name() = 'ErrorInfo']/*[local-name() = 'Message']")?.InnerText;
if (string.IsNullOrEmpty (testMessage)) {
messageLines.Add ($" <li>{testName} (<span style='color: {GetOutcomeColor (testOutcome)}'>{testOutcome}</span>)</li>");
} else {
messageLines.Add ($" <li>{testName} (<span style='color: {GetOutcomeColor (testOutcome)}'>{testOutcome}</span>)</li>");
messageLines.Add ($" <div class='pdiv' style='margin-left: 20px;'>");
messageLines.Add (FormatHtml (testMessage));
messageLines.Add ($" </div>");
}
}
messageLines.Add (" </ul>");
allTestsSucceeded = false;
} else if (outcome != "Completed" && outcome != "Passed") {
messageLines.Add ($" Failed to find any test failures in the trx file {path}");
}
}
var htmlPath = Path.ChangeExtension (path, "html");
if (File.Exists (htmlPath)) {
var relativeHtmlPath = Path.GetRelativePath (outputDirectory, htmlPath);
messageLines.Add ($"Html results: <a href='{relativeHtmlPath}'>{Path.GetFileName (relativeHtmlPath)}</a>");
}
} catch (Exception e) {
outcome = "Failed to parse test results";
messageLines.Add ($"<div>{FormatHtml (e.ToString ())}</div>");
allTestsSucceeded = false;
}

indexContents.AppendLine ($" <div class='pdiv'><span>{name} (</span><span style='color: {GetOutcomeColor (outcome)}'>{outcome}</span><span>)</span></div>");
if (messageLines.Any ()) {
indexContents.AppendLine (" <div class='pdiv' style='margin-left: 20px;'>");
foreach (var line in messageLines)
indexContents.AppendLine ($" {line}");
indexContents.AppendLine (" </div>");
}
}
var existingExtraFiles = extraFiles.Where (File.Exists).ToList ();
if (existingExtraFiles.Any ()) {
indexContents.AppendLine ($" <div class='pdiv'>Extra files:</div>");
indexContents.AppendLine ($" <ul>");
foreach (var ef in existingExtraFiles) {
var relative = Path.GetRelativePath (outputDirectory, ef);
indexContents.AppendLine ($" <li><a href='{relative}'>{Path.GetFileName (ef)}</a></li>");
}
indexContents.AppendLine ($" </ul>");
}
indexContents.AppendLine ($" </body>");
indexContents.AppendLine ($"</html>");

if (allTestsSucceeded) {
summaryContents.AppendLine ($"# :tada: All {trxFiles.Length} tests passed :tada:");
} else {
summaryContents.AppendLine ($"# :tada: All {trxFiles.Length} tests passed :tada:");
}


Directory.CreateDirectory (outputDirectory);
File.WriteAllText (indexFile, indexContents.ToString ());
File.WriteAllText (summaryFile, summaryContents.ToString ());

Console.WriteLine ($"Created {indexFile} successfully.");
Console.WriteLine (indexContents);
Console.WriteLine ($"Created {summaryFile} successfully.");
Console.WriteLine (summaryContents);
Console.WriteLine ($"All tests succeeded: {allTestsSucceeded}");
return allTestsSucceeded ? 0 : 1;
}
}
8 changes: 8 additions & 0 deletions scripts/create-html-report/create-html-report.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -33,3 +33,5 @@ logs
*.generated.cs
x86
*.7z
TestSummary.md

25 changes: 24 additions & 1 deletion tools/devops/automation/scripts/TestConfiguration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ Describe 'Get-TestConfiguration' {
"label": "cecil",
"splitByPlatforms": "false",
"testPrefix": "test-prefix_",
"testStage": "simulator",
},
{
"label": "dotnettests",
@@ -66,6 +67,7 @@ Describe 'Get-TestConfiguration' {
"cecil": {
"LABEL": "cecil",
"TESTS_LABELS": "extra-test-labels,run-cecil-tests",
"TEST_STAGE": "simulator",
"LABEL_WITH_PLATFORM": "cecil",
"STATUS_CONTEXT": "status-context - cecil",
"TEST_PREFIX": "test-prefix_cecil",
@@ -74,6 +76,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_iOS": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_iOS",
"STATUS_CONTEXT": "status-context - dotnettests - iOS",
"TEST_PREFIX": "test-prefix_dotnettests_iOS",
@@ -83,6 +86,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_macOS": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_macOS",
"STATUS_CONTEXT": "status-context - dotnettests - macOS",
"TEST_PREFIX": "test-prefix_dotnettests_macOS",
@@ -92,6 +96,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_MacCatalyst": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_MacCatalyst",
"STATUS_CONTEXT": "status-context - dotnettests - MacCatalyst",
"TEST_PREFIX": "test-prefix_dotnettests_MacCatalyst",
@@ -101,6 +106,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_tvOS": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_tvOS",
"STATUS_CONTEXT": "status-context - dotnettests - tvOS",
"TEST_PREFIX": "test-prefix_dotnettests_tvOS",
@@ -110,6 +116,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_Multiple": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_Multiple",
"STATUS_CONTEXT": "status-context - dotnettests - Multiple",
"TEST_PREFIX": "test-prefix_dotnettests_Multiple",
@@ -119,6 +126,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_ios": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_iOS",
"STATUS_CONTEXT": "status-context - monotouchtest - iOS",
"TEST_PREFIX": "test-prefix_monotouchtest_ios",
@@ -128,6 +136,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_macos": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_macOS",
"STATUS_CONTEXT": "status-context - monotouchtest - macOS",
"TEST_PREFIX": "test-prefix_monotouchtest_macos",
@@ -137,6 +146,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_maccatalyst": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_MacCatalyst",
"STATUS_CONTEXT": "status-context - monotouchtest - MacCatalyst",
"TEST_PREFIX": "test-prefix_monotouchtest_maccatalyst",
@@ -146,6 +156,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_tvos": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_tvOS",
"STATUS_CONTEXT": "status-context - monotouchtest - tvOS",
"TEST_PREFIX": "test-prefix_monotouchtest_tvos",
@@ -172,6 +183,7 @@ Describe 'Get-TestConfiguration' {
"cecil": {
"LABEL": "cecil",
"TESTS_LABELS": "extra-test-labels,run-cecil-tests",
"TEST_STAGE": "simulator",
"LABEL_WITH_PLATFORM": "cecil",
"STATUS_CONTEXT": "status-context - cecil",
"TEST_PREFIX": "test-prefix_cecil",
@@ -180,6 +192,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_iOS": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_iOS",
"STATUS_CONTEXT": "status-context - dotnettests - iOS",
"TEST_PREFIX": "test-prefix_dotnettests_iOS",
@@ -189,6 +202,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_ios": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_iOS",
"STATUS_CONTEXT": "status-context - monotouchtest - iOS",
"TEST_PREFIX": "test-prefix_monotouchtest_ios",
@@ -200,7 +214,7 @@ Describe 'Get-TestConfiguration' {

}

It 'suceeds when no dotnet platforms enabled' {
It 'succeeds when no dotnet platforms enabled' {
$EnabledPlatforms = ""

$config = Get-TestConfiguration `
@@ -215,6 +229,7 @@ Describe 'Get-TestConfiguration' {
"cecil": {
"LABEL": "cecil",
"TESTS_LABELS": "extra-test-labels,run-cecil-tests",
"TEST_STAGE": "simulator",
"LABEL_WITH_PLATFORM": "cecil",
"STATUS_CONTEXT": "status-context - cecil",
"TEST_PREFIX": "test-prefix_cecil",
@@ -240,6 +255,7 @@ Describe 'Get-TestConfiguration' {
"cecil": {
"LABEL": "cecil",
"TESTS_LABELS": "extra-test-labels,run-cecil-tests",
"TEST_STAGE": "simulator",
"LABEL_WITH_PLATFORM": "cecil",
"STATUS_CONTEXT": "status-context - cecil",
"TEST_PREFIX": "test-prefix_cecil",
@@ -248,6 +264,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_iOS": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_iOS",
"STATUS_CONTEXT": "status-context - dotnettests - iOS",
"TEST_PREFIX": "test-prefix_dotnettests_iOS",
@@ -257,6 +274,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_macOS": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_macOS",
"STATUS_CONTEXT": "status-context - dotnettests - macOS",
"TEST_PREFIX": "test-prefix_dotnettests_macOS",
@@ -266,6 +284,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_MacCatalyst": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_MacCatalyst",
"STATUS_CONTEXT": "status-context - dotnettests - MacCatalyst",
"TEST_PREFIX": "test-prefix_dotnettests_MacCatalyst",
@@ -275,6 +294,7 @@ Describe 'Get-TestConfiguration' {
"dotnettests_Multiple": {
"LABEL": "dotnettests",
"TESTS_LABELS": "extra-test-labels,run-dotnettests-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "dotnettests_Multiple",
"STATUS_CONTEXT": "status-context - dotnettests - Multiple",
"TEST_PREFIX": "test-prefix_dotnettests_Multiple",
@@ -284,6 +304,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_ios": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_iOS",
"STATUS_CONTEXT": "status-context - monotouchtest - iOS",
"TEST_PREFIX": "test-prefix_monotouchtest_ios",
@@ -293,6 +314,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_macos": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_macOS",
"STATUS_CONTEXT": "status-context - monotouchtest - macOS",
"TEST_PREFIX": "test-prefix_monotouchtest_macos",
@@ -302,6 +324,7 @@ Describe 'Get-TestConfiguration' {
"monotouchtest_maccatalyst": {
"LABEL": "monotouchtest",
"TESTS_LABELS": "extra-test-labels,run-monotouchtest-tests",
"TEST_STAGE": "test-prefix_",
"LABEL_WITH_PLATFORM": "monotouchtest_MacCatalyst",
"STATUS_CONTEXT": "status-context - monotouchtest - MacCatalyst",
"TEST_PREFIX": "test-prefix_monotouchtest_maccatalyst",
4 changes: 3 additions & 1 deletion tools/devops/automation/scripts/TestConfiguration.psm1
Original file line number Diff line number Diff line change
@@ -26,11 +26,13 @@ class TestConfiguration {
$underscoredLabel = $label.Replace('-','_')
$splitByPlatforms = $config.splitByPlatforms
$testPrefix = $config.testPrefix
$testStage = $config.testStage ? $config.testStage : $config.testPrefix

$vars = [ordered]@{}
# set common variables
$vars["LABEL"] = $label
$vars["TESTS_LABELS"] = "$($this.testsLabels),run-$($label)-tests"
$vars["TEST_STAGE"] = $testStage
if ($splitByPlatforms -eq "True") {
if ($enabledPlatformsForConfig.Length -eq 0) {
Write-Host "No enabled platforms, skipping $label"
@@ -111,7 +113,7 @@ function Get-TestConfiguration {

$objTestConfigurations = ConvertFrom-Json -InputObject $TestConfigurations
$objSupportedPlatforms = ConvertFrom-Json -InputObject $SupportedPlatforms
$arrEnabledPlatforms = -split $EnabledPlatforms
$arrEnabledPlatforms = -split $EnabledPlatforms | Where { $_ }
$config = [TestConfiguration]::new($objTestConfigurations, $objSupportedPlatforms, $arrEnabledPlatforms, $TestsLabels, $StatusContext)
return $config.Create()
}
32 changes: 19 additions & 13 deletions tools/devops/automation/scripts/TestResults.Tests.ps1
Original file line number Diff line number Diff line change
@@ -11,14 +11,15 @@ Describe "TestResults tests" {
$platform = "iOS"
$resultContext = "tests"
$suite = [TestSuite]::new($label)
$testConfig = [TestConfiguration]::new($suite, $title, $platform, $resultContext)
$testConfig = [TestConfiguration]::new($suite, $title, $platform, $resultContext, "testStage")
$jobStatus = "Succeeded"
$attempt = 1
$matrix = @"
{
"dotnettests_ios": {
"LABEL": "dotnettests",
"TESTS_LABELS": "--label=skip-all-tests,run-ios-tests,run-ios-simulator-tests,run-tvos-tests,run-mac-tests,run-maccatalyst-tests,run-system-permission-tests,run-dotnettests-tests",
"TEST_STAGE": "testStage",
"LABEL_WITH_PLATFORM": "dotnettests_iOS",
"STATUS_CONTEXT": "VSTS: simulator tests - dotnettests - iOS",
"TEST_simulator_tests": "simulator_dotnettests_ios",
@@ -28,6 +29,7 @@ Describe "TestResults tests" {
"dotnettests_tvos": {
"LABEL": "dotnettests",
"TESTS_LABELS": "--label=skip-all-tests,run-ios-tests,run-ios-simulator-tests,run-tvos-tests,run-mac-tests,run-maccatalyst-tests,run-system-permission-tests,run-dotnettests-tests",
"TEST_STAGE": "testStage",
"LABEL_WITH_PLATFORM": "dotnettests_tvOS",
"STATUS_CONTEXT": "VSTS: simulator tests - dotnettests - tvOS",
"TEST_simulator_tests": "simulator_dotnettests_tvos",
@@ -37,6 +39,7 @@ Describe "TestResults tests" {
"dotnettests_maccatalyst": {
"LABEL": "dotnettests",
"TESTS_LABELS": "--label=skip-all-tests,run-ios-tests,run-ios-simulator-tests,run-tvos-tests,run-mac-tests,run-maccatalyst-tests,run-system-permission-tests,run-dotnettests-tests",
"TEST_STAGE": "testStage",
"LABEL_WITH_PLATFORM": "dotnettests_MacCatalyst",
"STATUS_CONTEXT": "VSTS: simulator tests - dotnettests - MacCatalyst",
"TEST_simulator_tests": "simulator_dotnettests_maccatalyst",
@@ -46,6 +49,7 @@ Describe "TestResults tests" {
"dotnettests_macos": {
"LABEL": "dotnettests",
"TESTS_LABELS": "--label=skip-all-tests,run-ios-tests,run-ios-simulator-tests,run-tvos-tests,run-mac-tests,run-maccatalyst-tests,run-system-permission-tests,run-dotnettests-tests",
"TEST_STAGE": "testStage",
"LABEL_WITH_PLATFORM": "dotnettests_macOS",
"STATUS_CONTEXT": "VSTS: simulator tests - dotnettests - macOS",
"TEST_simulator_tests": "simulator_dotnettests_macos",
@@ -55,6 +59,7 @@ Describe "TestResults tests" {
"dotnettests_multiple": {
"LABEL": "dotnettests",
"TESTS_LABELS": "--label=skip-all-tests,run-ios-tests,run-ios-simulator-tests,run-tvos-tests,run-mac-tests,run-maccatalyst-tests,run-system-permission-tests,run-dotnettests-tests",
"TEST_STAGE": "testStage",
"LABEL_WITH_PLATFORM": "dotnettests_Multiple",
"STATUS_CONTEXT": "VSTS: simulator tests - dotnettests - Multiple",
"TEST_simulator_tests": "simulator_dotnettests_multiple",
@@ -65,6 +70,7 @@ Describe "TestResults tests" {
{
"LABEL": "cecil",
"TESTS_LABELS": "--label=skip-all-tests,run-ios-64-tests,run-ios-simulator-tests,run-tvos-tests,run-mac-tests,run-maccatalyst-tests,run-system-permission-tests,run-cecil-tests",
"TEST_STAGE": "testStage",
"LABEL_WITH_PLATFORM": "cecil",
"STATUS_CONTEXT": "VSTS: simulator tests - cecil",
"TEST_simulator_tests": "simulator_cecil",
@@ -478,15 +484,15 @@ Describe "TestResults tests" {
</details>
[Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_MacCatalyst-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_MacCatalyst-1&api-version=6.0&`$format=zip)
[Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_maccatalyst-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_maccatalyst-1&api-version=6.0&`$format=zip)
## Successes
:white_check_mark: cecil: All 1 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testscecil-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testscecil-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (iOS): All 3 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_iOS-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_iOS-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (macOS): All 6 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_macOS-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_macOS-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (Multiple platforms): All 7 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_Multiple-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_Multiple-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (tvOS): All 4 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_tvOS-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_tvOS-1&api-version=6.0&`$format=zip)
:white_check_mark: cecil: All 1 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagececil-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagececil-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (iOS): All 3 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_ios-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_ios-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (macOS): All 6 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_macos-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_macos-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (Multiple platforms): All 7 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_multiple-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_multiple-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (tvOS): All 4 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_tvos-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_tvos-1&api-version=6.0&`$format=zip)
[comment]: <> (This is a test result report added by Azure DevOps)
"
@@ -532,15 +538,15 @@ Describe "TestResults tests" {
</details>
[Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_MacCatalyst-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_MacCatalyst-1&api-version=6.0&`$format=zip)
[Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_maccatalyst-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_maccatalyst-1&api-version=6.0&`$format=zip)
## Successes
:white_check_mark: cecil: All 1 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testscecil-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testscecil-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (iOS): All 3 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_iOS-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_iOS-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (macOS): All 6 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_macOS-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_macOS-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (Multiple platforms): All 7 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_Multiple-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_Multiple-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (tvOS): All 4 tests passed. [Html Report (VSDrops)](vsdropsIndex/simulator_testsdotnettests_tvOS-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-simulator_testsdotnettests_tvOS-1&api-version=6.0&`$format=zip)
:white_check_mark: cecil: All 1 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagececil-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagececil-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (iOS): All 3 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_ios-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_ios-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (macOS): All 6 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_macos-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_macos-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (Multiple platforms): All 7 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_multiple-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_multiple-1&api-version=6.0&`$format=zip)
:white_check_mark: dotnettests (tvOS): All 4 tests passed. [Html Report (VSDrops)](vsdropsIndex/testStagedotnettests_tvos-1/;/tests/vsdrops_index.html) [Download](/_apis/build/builds//artifacts?artifactName=HtmlReport-testStagedotnettests_tvos-1&api-version=6.0&`$format=zip)
[comment]: <> (This is a test result report added by Azure DevOps)
"
99 changes: 53 additions & 46 deletions tools/devops/automation/scripts/TestResults.psm1
Original file line number Diff line number Diff line change
@@ -22,23 +22,26 @@ class TestConfiguration {
[string] $Title
[string] $Platform
[string] $Context
[string] $TestStage

TestConfiguration (
[TestSuite] $suite,
[string] $title,
[string] $platform,
[string] $context
[string] $context,
[string] $testStage
)
{
$this.Suite = $suite
$this.Title = $title
$this.Platform = $platform
$this.Context = $context
$this.TestStage = $testStage
}

[string]
ToString() {
return "$($this.Suite.Label) : $($this.Title) - $($this.Platform) - $($this.Context)"
return "$($this.Suite.Label) : $($this.Title) - $($this.Platform) - $($this.Context) - $($this.TestStage)"
}
}

@@ -51,6 +54,7 @@ class TestResult {
[string] $Title
[string] $Platform
[string] $Context
[string] $TestStage
hidden [int] $Passed
hidden [int] $Failed
hidden [string[]] $NotTestSummaryLabels = @()
@@ -71,6 +75,7 @@ class TestResult {
$this.Title = $testConfiguration.Title
$this.Platform = $testConfiguration.Platform
$this.Context = $testConfiguration.Context
$this.TestStage = $testConfiguration.TestStage
Write-Host "TestsResult::new($path, $status, $testConfiguration, $attempt) Label: $($this.Label) Platform: $($this.Platform) Title: $($this.Title) Context: $($this.Context)"
}

@@ -249,19 +254,16 @@ class TestResult {
class ParallelTestsResults {
[string] $BuildFailureMessage
[string] $Context
[string] $TestPrefix
[string] $VSDropsIndex
[TestResult[]] $Results

ParallelTestsResults (
[TestResult[]] $results,
[string] $context,
[string] $testPrefix,
[string] $vsDropsIndex
) {
$this.Results = $results
$this.Context = $context
$this.TestPrefix = $testPrefix
$this.VSDropsIndex = $vsDropsIndex
}

@@ -324,8 +326,8 @@ class ParallelTestsResults {
}

[string] GetDownloadLinks($testResult) {
$dropsIndex = "$($this.VSDropsIndex)/$($this.TestPrefix)$($testResult.Title)-$($testResult.Attempt)/;/tests/vsdrops_index.html"
$artifactUrl = "$Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$Env:SYSTEM_TEAMPROJECT/_apis/build/builds/$Env:BUILD_BUILDID/artifacts?artifactName=HtmlReport-$($this.TestPrefix)$($testResult.Title)-$($testResult.Attempt)&api-version=6.0&`$format=zip"
$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)"
return $downloadInfo
}
@@ -447,7 +449,9 @@ function New-TestResults {
[string]
$Context,
[int]
$Attempt
$Attempt,
[string]
$TestStage
)
return [TestResult]::new($Path, $Status, [TestConfiguration]::new($Label, $Title, $Platform, $Context), $Attempt)
}
@@ -486,14 +490,15 @@ function New-ParallelTestsResults {
Write-Host "Got title: $title with entry: $( $entry | ConvertTo-Json -Depth 100 )"
$platform = $entry["TEST_PLATFORM"]
$label = $entry["LABEL"]
$testStage = $entry["TEST_STAGE"]

if ($suites.Contains($label)) {
$suite = $suites[$label]
} else {
$suite = [TestSuite]::new($label)
$suites[$label] = $suite
}
$testConfig = [TestConfiguration]::new($suite, $title, $platform, "$Context - $title")
$testConfig = [TestConfiguration]::new($suite, $title, $platform, "$Context - $title", $testStage)
$suite.TestConfigurations += $testConfig
Write-Host "Added test config: $( $testConfig.Title )"
Write-Host "To suite: $( $suite.Label )"
@@ -504,6 +509,7 @@ function New-ParallelTestsResults {
Write-Host "Test suites:"
Write-Host $suites.Keys

$tests = [System.Collections.SortedList]::new()
foreach ($kvp in $stageDep.GetEnumerator()) {
$candidate = $kvp.Value
if ($candidate.tests.outputs -eq $null) {
@@ -512,12 +518,11 @@ function New-ParallelTestsResults {
}
Write-Host "Stage dependency $($kvp.Name) is a test dependency"

$testPrefix = $kvp.Name
$testStage = $kvp.Name
$outputs = $candidate.tests.outputs

Write-Host "Outputs for $($testPrefix):"
Write-Host "Outputs for $($testStage):"
Write-Host $outputs
$tests = [System.Collections.SortedList]::new()
foreach ($name in $outputs.Keys) {
if ($name.EndsWith(".TESTS_LABEL")) {
$label = $outputs[$name]
@@ -538,6 +543,7 @@ function New-ParallelTestsResults {
Bot = $bot
Platform = $platform
Attempt = $attempt
TestStage = $testStage
}
if ($tests.Contains($label)) {
$testInfo = $tests[$label]
@@ -549,54 +555,55 @@ function New-ParallelTestsResults {
Write-Host "Added $label to tests ($title) Name: $name status: $($testResult.Status) bot: $($testResult.Bot) Platform: $($testResult.Platform) Attempt: $($testResult.Attempt)"
}
}
}

$testResults = [System.Collections.ArrayList]@()
foreach ($suite in $suites.Values | Sort-Object -Property Label) {
$label = $suite.Label
Write-Host "Processing results for $label with $($suite.TestConfigurations.Length) configurations"
foreach ($testConfig in $suite.TestConfigurations | Sort-Object -Property Title) {
$title = $testConfig.Title
$testResult = $null
Write-Host "`tProcessing config $title"
if ($tests.Contains($label)) {
Write-Host "`t`tFound results for label: $label"
$testInfo = $tests[$label]
if ($testInfo.Contains($title)) {
$testResult = $testInfo[$title]
Write-Host "`t`tFound results for title '$title': $testResult"
} else {
Write-Host "`t`tFound NO results for title: $title"
}
$testResults = [System.Collections.ArrayList]@()
foreach ($suite in $suites.Values | Sort-Object -Property Label) {
$label = $suite.Label
Write-Host "Processing results for $label with $($suite.TestConfigurations.Length) configurations"
foreach ($testConfig in $suite.TestConfigurations | Sort-Object -Property Title) {
$title = $testConfig.Title
$testResult = $null
Write-Host "`tProcessing config $title"
if ($tests.Contains($label)) {
Write-Host "`t`tFound results for label: $label"
$testInfo = $tests[$label]
if ($testInfo.Contains($title)) {
$testResult = $testInfo[$title]
Write-Host "`t`tFound results for title '$title': $testResult"
} else {
Write-Host "`tFound NO results for label: $label"
Write-Host "`t`tFound NO results for title: $title"
}
} else {
Write-Host "`tFound NO results for label: $label"
}


$platform = $testConfig.Platform
$title = $testConfig.Title
if ($null -eq $testResult) {
$result = [TestResult]::new($null, "None", $testConfig, -1)
} else {
$status = $testResult.Status
$testAttempt = $testResult.Attempt

$testSummaryPath = Join-Path "$Path" "${UploadPrefix}TestSummary-$TestPrefix$($title.Replace('-','_'))-$testAttempt" "TestSummary.md"
$platform = $testConfig.Platform
$title = $testConfig.Title
if ($null -eq $testResult) {
$result = [TestResult]::new($null, "None", $testConfig, -1)
} else {
$status = $testResult.Status
$testAttempt = $testResult.Attempt
$testStage = $testResult.TestStage

Write-Host "`t`tTest results for $label on attempt $testAttempt is '$status' in $testSummaryPath"
$testSummaryPath = Join-Path "$Path" "${UploadPrefix}TestSummary-$testStage$($title.Replace('-','_'))-$testAttempt" "TestSummary.md"

if (-not (Test-Path -Path $testSummaryPath -PathType Leaf)) {
Write-Host "`t`tWARNING: Path $testSummaryPath does not exist"
}
Write-Host "`t`tTest results for $label on attempt $testAttempt is '$status' in $testSummaryPath"

$result = [TestResult]::new($testSummaryPath, $status, $testConfig, $testAttempt)
if (-not (Test-Path -Path $testSummaryPath -PathType Leaf)) {
Write-Host "`t`tWARNING: Path $testSummaryPath does not exist"
}

$testResults += $result
$result = [TestResult]::new($testSummaryPath, $status, $testConfig, $testAttempt)
}

$testResults += $result
}
}

return [ParallelTestsResults]::new($testResults, $Context, $TestPrefix, $VSDropsIndex)
return [ParallelTestsResults]::new($testResults, $Context, $VSDropsIndex)
}

Export-ModuleMember -Function New-TestResults
44 changes: 28 additions & 16 deletions tools/devops/automation/scripts/VSTS.Tests.ps1
Original file line number Diff line number Diff line change
@@ -213,17 +213,10 @@ Describe 'New-BuildConfiguration' {
$buildConfiguration | ConvertTo-Json | Should -Be "{
""DOTNET_PLATFORMS"": ""iOS tvOS"",
""PARENT_BUILD_BUILD_BUILDID"": ""BUILD_BUILDID"",
""PARENT_BUILD_BUILD_BUILDNUMBER"": null,
""PARENT_BUILD_BUILD_BUILDURI"": null,
""PARENT_BUILD_BUILD_BINARIESDIRECTORY"": null,
""PARENT_BUILD_BUILD_DEFINITIONNAME"": null,
""PARENT_BUILD_BUILD_REASON"": ""BUILD_REASON"",
""PARENT_BUILD_BUILD_REPOSITORY_ID"": null,
""PARENT_BUILD_BUILD_REPOSITORY_NAME"": null,
""PARENT_BUILD_BUILD_REPOSITORY_PROVIDER"": null,
""PARENT_BUILD_BUILD_REPOSITORY_URI"": null,
""PARENT_BUILD_BUILD_SOURCEBRANCH"": ""BUILD_SOURCEBRANCH"",
""PARENT_BUILD_BUILD_SOURCEBRANCHNAME"": ""BUILD_SOURCEBRANCHNAME"",
""ENABLE_DOTNET"": null,
""INCLUDE_DOTNET_IOS"": null,
""IOS_NUGET_VERSION_NO_METADATA"": null,
""IOS_NUGET_SDK_NAME"": ""iOSNuGetSdkName"",
@@ -236,6 +229,19 @@ Describe 'New-BuildConfiguration' {
""TVOS_NUGET_REF_NAME"": ""tvOSNuGetRefName"",
""DOTNET_TVOS_RUNTIME_IDENTIFIERS"": ""tvos-arm64"",
""tvos-arm64_NUGET_RUNTIME_NAME"": null,
""INCLUDE_XAMARIN_LEGACY"": null,
""INCLUDE_LEGACY_IOS"": ""false"",
""INCLUDE_LEGACY_MACOS"": ""false"",
""INCLUDE_LEGACY_TVOS"": ""false"",
""INCLUDE_LEGACY_MACCATALYST"": ""false"",
""INCLUDE_IOS"": null,
""IOS__NUGET_OS_VERSION"": null,
""INCLUDE_MACOS"": null,
""MACOS__NUGET_OS_VERSION"": null,
""INCLUDE_TVOS"": null,
""TVOS__NUGET_OS_VERSION"": null,
""INCLUDE_MACCATALYST"": null,
""MACCATALYST__NUGET_OS_VERSION"": null,
""Commit"": ""BUILD_SOURCEVERSION"",
""Tags"": [
""ciBuild"",
@@ -257,17 +263,10 @@ Describe 'New-BuildConfiguration' {
$buildConfiguration | Should -Be "{
""DOTNET_PLATFORMS"": ""iOS tvOS"",
""PARENT_BUILD_BUILD_BUILDID"": ""BUILD_BUILDID"",
""PARENT_BUILD_BUILD_BUILDNUMBER"": null,
""PARENT_BUILD_BUILD_BUILDURI"": null,
""PARENT_BUILD_BUILD_BINARIESDIRECTORY"": null,
""PARENT_BUILD_BUILD_DEFINITIONNAME"": null,
""PARENT_BUILD_BUILD_REASON"": ""BUILD_REASON"",
""PARENT_BUILD_BUILD_REPOSITORY_ID"": null,
""PARENT_BUILD_BUILD_REPOSITORY_NAME"": null,
""PARENT_BUILD_BUILD_REPOSITORY_PROVIDER"": null,
""PARENT_BUILD_BUILD_REPOSITORY_URI"": null,
""PARENT_BUILD_BUILD_SOURCEBRANCH"": ""BUILD_SOURCEBRANCH"",
""PARENT_BUILD_BUILD_SOURCEBRANCHNAME"": ""BUILD_SOURCEBRANCHNAME"",
""ENABLE_DOTNET"": null,
""INCLUDE_DOTNET_IOS"": null,
""IOS_NUGET_VERSION_NO_METADATA"": null,
""IOS_NUGET_SDK_NAME"": ""iOSNuGetSdkName"",
@@ -280,6 +279,19 @@ Describe 'New-BuildConfiguration' {
""TVOS_NUGET_REF_NAME"": ""tvOSNuGetRefName"",
""DOTNET_TVOS_RUNTIME_IDENTIFIERS"": ""tvos-arm64"",
""tvos-arm64_NUGET_RUNTIME_NAME"": null,
""INCLUDE_XAMARIN_LEGACY"": null,
""INCLUDE_LEGACY_IOS"": ""false"",
""INCLUDE_LEGACY_MACOS"": ""false"",
""INCLUDE_LEGACY_TVOS"": ""false"",
""INCLUDE_LEGACY_MACCATALYST"": ""false"",
""INCLUDE_IOS"": null,
""IOS__NUGET_OS_VERSION"": null,
""INCLUDE_MACOS"": null,
""MACOS__NUGET_OS_VERSION"": null,
""INCLUDE_TVOS"": null,
""TVOS__NUGET_OS_VERSION"": null,
""INCLUDE_MACCATALYST"": null,
""MACCATALYST__NUGET_OS_VERSION"": null,
""Commit"": ""BUILD_SOURCEVERSION"",
""Tags"": [
""ciBuild"",
3 changes: 3 additions & 0 deletions tools/devops/automation/scripts/fetch-remote-binlogs.ps1
Original file line number Diff line number Diff line change
@@ -23,3 +23,6 @@ Invoke-SshDownload `
-RemoteUserName "$Env:MAC_AGENT_USER" `
-Source "/Users/$Env:MAC_AGENT_USER/remote_build_testing/windows-remote-logs.zip" `
-Target "$Env:BUILD_ARTIFACTSTAGINGDIRECTORY\windows-binlogs\windows-remote-logs.zip"

# Copy the binlogs to the html report
Copy-Item "$Env:BUILD_ARTIFACTSTAGINGDIRECTORY\windows-binlogs\windows-remote-logs.zip" -Destination "$Env:BUILD_SOURCESDIRECTORY\xamarin-macios\jenkins-results"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Write-Host "Running tests on $($Env:AGENT_NAME)"

Write-Host "##vso[task.setvariable variable=TESTS_BOT;isOutput=true]$($Env:AGENT_NAME)"
Write-Host "##vso[task.setvariable variable=TESTS_LABEL;isOutput=true]$($Env:TESTS_LABEL)"
Write-Host "##vso[task.setvariable variable=TESTS_PLATFORM;isOutput=true]$($Env:TESTS_PLATFORM)"
Write-Host "##vso[task.setvariable variable=TESTS_ATTEMPT;isOutput=true]$($Env:SYSTEM_JOBATTEMPT)"
10 changes: 10 additions & 0 deletions tools/devops/automation/scripts/prepare-windows-test-results.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Set-Location "$Env:BUILD_SOURCESDIRECTORY\$Env:BUILD_REPOSITORY_TITLE"
$Env:DOTNET = "$Env:BUILD_SOURCESDIRECTORY\$Env:BUILD_REPOSITORY_TITLE\tests\dotnet\Windows\bin\dotnet\dotnet.exe"
& $Env:DOTNET run --project "$Env:BUILD_SOURCESDIRECTORY\$Env:BUILD_REPOSITORY_TITLE\scripts\create-html-report\create-html-report.csproj"

if ($Env:AGENT_JOBSTATUS -eq "Succeeded") {
$jobStatus = "Succeeded"
} else {
$jobStatus = "Failed"
}
Write-Host "##vso[task.setvariable variable=TESTS_JOBSTATUS;isOutput=true]$jobStatus"
13 changes: 13 additions & 0 deletions tools/devops/automation/scripts/run-windows-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$Env:PATH = "$(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet;$env:PATH"
$Env:DOTNET = "$(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe"
& $(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe `
test `
"$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/UnitTests/DotNetUnitTests.csproj" `
--filter Category=Windows `
--verbosity quiet `
--settings $(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/config.runsettings `
"--results-directory:$(Build.SourcesDirectory)/xamarin-macios/jenkins-results/" `
"--logger:console;verbosity=detailed" `
"--logger:trx;LogFileName=$(Build.SourcesDirectory)/xamarin-macios/jenkins-results/windows-dotnet-tests.trx" `
"--logger:html;LogFileName=$(Build.SourcesDirectory)/xamarin-macios/jenkins-results/windows-dotnet-tests.html" `
"-bl:$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/run-dotnet-tests.binlog"
6 changes: 6 additions & 0 deletions tools/devops/automation/templates/main-stage.yml
Original file line number Diff line number Diff line change
@@ -85,6 +85,12 @@ parameters:
# label: bcl,
# splitByPlatforms: false,
# },
{
label: windows,
splitByPlatforms: false,
testPrefix: 'windows_integration',
testStage: 'windows_integration'
},
{
label: cecil,
splitByPlatforms: false,
Original file line number Diff line number Diff line change
@@ -122,6 +122,12 @@ parameters:
# label: bcl,
# splitByPlatforms: false,
# },
{
label: windows,
splitByPlatforms: false,
testPrefix: 'windows_integration',
testStage: 'windows_integration'
},
{
label: cecil,
splitByPlatforms: false,
6 changes: 6 additions & 0 deletions tools/devops/automation/templates/tests-stage.yml
Original file line number Diff line number Diff line change
@@ -77,6 +77,12 @@ parameters:
# label: bcl,
# splitByPlatforms: false,
# },
{
label: windows,
splitByPlatforms: false,
testPrefix: 'windows_integration',
testStage: 'windows_integration'
},
{
label: cecil,
splitByPlatforms: false,
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ stages:
- build_macos_tests
- configure_build
- simulator_tests
- windows_integration
condition: and(succeededOrFailed(), ${{ parameters.condition }})

jobs:
14 changes: 4 additions & 10 deletions tools/devops/automation/templates/tests/run-tests.yml
Original file line number Diff line number Diff line change
@@ -50,17 +50,11 @@ steps:
fi
displayName: Install powershell

- bash: |
set -e
# don't do "set -x" here, because the duplicate vso output might confuse Azure DevOps
echo "Running tests on $AGENT_NAME"
echo "##vso[task.setvariable variable=TESTS_BOT;isOutput=true]$AGENT_NAME"
echo "##vso[task.setvariable variable=TESTS_LABEL;isOutput=true]${{ parameters.label }}"
echo "##vso[task.setvariable variable=TESTS_PLATFORM;isOutput=true]${{ parameters.testPlatform }}"
echo "##vso[task.setvariable variable=TESTS_ATTEMPT;isOutput=true]$SYSTEM_JOBATTEMPT"
# assume something is going to fail
echo "##vso[task.setvariable variable=TESTS_JOBSTATUS;isOutput=true]Failed"
- pwsh: $(Build.SourcesDirectory)/xamarin-macios/tools/devops/automation/scripts/initialize-test-output-variables.ps1
displayName: Set output variables
env:
TESTS_LABEL: ${{ parameters.label }}
TESTS_PLATFORM: ${{ parameters.testPlatform }}

- pwsh: |
Write-Host "##vso[task.setvariable variable=TESTS_USE_SYSTEM]true"
32 changes: 31 additions & 1 deletion tools/devops/automation/templates/windows/build.yml
Original file line number Diff line number Diff line change
@@ -97,7 +97,13 @@ steps:

- task: UseDotNet@2
inputs:
version: 7.0.102
version: 8.x

- pwsh: $(Build.SourcesDirectory)/xamarin-macios/tools/devops/automation/scripts/initialize-test-output-variables.ps1
displayName: Set output variables
env:
TESTS_LABEL: windows
# TESTS_PLATFORM:

- pwsh: |
& dotnet --version
@@ -272,6 +278,30 @@ steps:
- pwsh: $(System.DefaultWorkingDirectory)/$(BUILD_REPOSITORY_TITLE)/tools/devops/automation/scripts/run-generator-tests-on-windows.ps1
displayName: 'Run generator tests'

- pwsh: $(Build.SourcesDirectory)\xamarin-macios\tools\devops\automation\scripts\prepare-windows-test-results.ps1
displayName: 'Prepare tests results and Html Report'
timeoutInMinutes: 5
condition: always()

# Upload TestSummary as an artifact.
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: TestSummary'
inputs:
targetPath: 'xamarin-macios/tests/TestSummary.md'
artifactName: '${{ parameters.uploadPrefix }}TestSummary-windows-integration-$(System.JobAttempt)'
continueOnError: true
condition: succeededOrFailed()

- pwsh: |
$summaryName = "TestSummary-windows-integration.md"
$summaryPath = "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/xamarin-macios/tests/TestSummary.md"
if (Test-Path -Path $summaryPath -PathType Leaf) {
Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=$summaryName;]$summaryPath"
}
displayName: Set TestSummary
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'
4 changes: 2 additions & 2 deletions tools/devops/automation/templates/windows/stage.yml
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ stages:
gitHubToken: ${{ parameters.gitHubToken }}
xqaCertPass: ${{ parameters.xqaCertPass }}

- job: run_tests
- job: "tests"
dependsOn:
- mac_reservation
displayName: 'Dotnet tests'
@@ -110,7 +110,7 @@ stages:
- job: mac_reenable
dependsOn:
- mac_reservation
- run_tests
- tests
displayName: "Re-enable macOS bot for tests"
timeoutInMinutes: 120
condition: always()

0 comments on commit 4627556

Please sign in to comment.