From 8e1bb933d1d5e868a8d4c8d360805542a1680c80 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 15 Jan 2021 12:58:45 -0500 Subject: [PATCH 1/4] [CI][VSTS] Add logging and new check to add links. --- tools/devops/automation/scripts/GitHub.psm1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/devops/automation/scripts/GitHub.psm1 b/tools/devops/automation/scripts/GitHub.psm1 index 2210224a95a1..b5c2ce668cf1 100644 --- a/tools/devops/automation/scripts/GitHub.psm1 +++ b/tools/devops/automation/scripts/GitHub.psm1 @@ -381,7 +381,7 @@ function New-GitHubSummaryComment { $TestSummaryPath, [string] - $Artifacts + $Artifacts="" ) $envVars = @{ @@ -410,7 +410,8 @@ function New-GitHubSummaryComment { # we did generate an index with the files in vsdrops $sb.AppendLine("* [Html Report (VSDrops)]($Env:VSDROPS_INDEX)") } - if ($Artifacts) { + if (-not [string]::IsNullOrEmpty($Artifacts)) { + Write-Host "Parsing artifacts" if (-not (Test-Path $Artifacts -PathType Leaf)) { $sb.AppendLine("Path $Artifacts was not found!") } else { @@ -423,6 +424,7 @@ function New-GitHubSummaryComment { if ($url.EndsWith(".pkg") -or $url.EndsWith(".nupkg")) { try { $fileName = $a.url.Substring($a.url.LastIndexOf("/" + 1)) + Write-Host "Adding link for $fileName" $sb.AppendLine("* [$fileName]($($a.url))") } catch { Write-Host "Could not get file name for url $url" @@ -434,6 +436,8 @@ function New-GitHubSummaryComment { $sb.AppendLine("No packages found.") } } + } else { + Write-Host "Artifacts were not provided." } $headerLinks = $sb.ToString() From 88785985902a5df2cb9ae3629349e292f90b530b Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Sat, 16 Jan 2021 12:50:49 -0500 Subject: [PATCH 2/4] We do have the pkgs when we have not been triggered by a PR. --- tools/devops/automation/templates/build/publish-html.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/devops/automation/templates/build/publish-html.yml b/tools/devops/automation/templates/build/publish-html.yml index c178b0c86de9..809d852155ff 100644 --- a/tools/devops/automation/templates/build/publish-html.yml +++ b/tools/devops/automation/templates/build/publish-html.yml @@ -79,7 +79,11 @@ steps: $env:VSDROPS_INDEX="$Env:VSDROPSPREFIX/$Env:BUILD_BUILDNUMBER/$Env:BUILD_BUILDID/$Env:DEVICE_PREFIX/;/tests/vsdrops_index.html" Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\GitHub.psm1 Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\VSTS.psm1 - if ($Env:BUILD_PACKAGE -eq "True") { + + $buildReason = "$(Build.Reason)" + $buildSourceBranchName = "$(Build.SourceBranchName)" + + if ($buildReason -ne "PullRequest" -or $Env:BUILD_PACKAGE -eq "True") { Write-Host "Json path is $Env:ARTIFACTS_JSON_PATH" $response = New-GitHubSummaryComment -Context "$Env:CONTEXT" -TestSummaryPath "$Env:TESTS_SUMMARY" -Artifacts "$Env:ARTIFACTS_JSON_PATH" Write-Host $response From 6561f85f6ad443df5df8ae5c1c91b58b5b6ab459 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Mon, 18 Jan 2021 09:29:29 -0500 Subject: [PATCH 3/4] That ( out of place. --- tools/devops/automation/scripts/GitHub.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devops/automation/scripts/GitHub.psm1 b/tools/devops/automation/scripts/GitHub.psm1 index b5c2ce668cf1..ec403199e58d 100644 --- a/tools/devops/automation/scripts/GitHub.psm1 +++ b/tools/devops/automation/scripts/GitHub.psm1 @@ -423,7 +423,7 @@ function New-GitHubSummaryComment { $url = $a.url if ($url.EndsWith(".pkg") -or $url.EndsWith(".nupkg")) { try { - $fileName = $a.url.Substring($a.url.LastIndexOf("/" + 1)) + $fileName = $a.url.Substring($a.url.LastIndexOf("/") + 1) Write-Host "Adding link for $fileName" $sb.AppendLine("* [$fileName]($($a.url))") } catch { From 63c743fcfb63683185262787fac1881365cbf97a Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 20 Jan 2021 07:58:54 -0500 Subject: [PATCH 4/4] Fix rendering and add notarized to those links that need it. --- tools/devops/automation/scripts/GitHub.psm1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/devops/automation/scripts/GitHub.psm1 b/tools/devops/automation/scripts/GitHub.psm1 index ec403199e58d..a73443d970ef 100644 --- a/tools/devops/automation/scripts/GitHub.psm1 +++ b/tools/devops/automation/scripts/GitHub.psm1 @@ -419,13 +419,19 @@ function New-GitHubSummaryComment { $json = Get-Content $Artifacts | ConvertFrom-Json if ($json.Count -gt 0) { $sb.AppendLine("
View packages") + $sb.AppendLine("") # no new line results in a bad rendering in the links foreach ($a in $json) { $url = $a.url if ($url.EndsWith(".pkg") -or $url.EndsWith(".nupkg")) { try { $fileName = $a.url.Substring($a.url.LastIndexOf("/") + 1) Write-Host "Adding link for $fileName" - $sb.AppendLine("* [$fileName]($($a.url))") + if ($a.url.Contains("notarized")) { + $link = "* [$fileName (notarized)]($($a.url))" + } else { + $link = "* [$fileName]($($a.url))" + } + $sb.AppendLine($link) } catch { Write-Host "Could not get file name for url $url" }