From 89a0912ffb39d13899f39f6b34e671cfc1ca4112 Mon Sep 17 00:00:00 2001 From: Maksim Shilov Date: Mon, 25 Oct 2021 15:58:53 +0300 Subject: [PATCH] Resolving comments --- .../actions/send-slack-notification/action.yml | 8 ++++---- .github/workflows/get-xamarin-versions.yml | 7 +++---- .../send-slack-notification.ps1 | 13 ++++++++----- .../verify-new-tool-version-added-to-image.ps1 | 16 +++++++++------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/actions/send-slack-notification/action.yml b/.github/actions/send-slack-notification/action.yml index 2a8790c..42062d3 100644 --- a/.github/actions/send-slack-notification/action.yml +++ b/.github/actions/send-slack-notification/action.yml @@ -8,9 +8,6 @@ inputs: required: true description: 'Name of a tool to send notification for. Like Xamarin or Python' default: 'Xamarin' - add-to-toolset-flag: - required: false - description: 'Flag to use notification for adding new versions to toolset' tool-version: required: false description: 'New versions of a tool' @@ -24,6 +21,9 @@ inputs: text: required: false description: 'Message text' + add-to-toolset-flag: + required: false + description: 'Flag to use notification for adding new versions to toolset' runs: using: "composite" steps: @@ -36,4 +36,4 @@ runs: -PipelineUrl "${{ inputs.pipeline-url }}" ` -ImageUrl "${{ inputs.image-url }}" ` -Text "${{ inputs.text }}" ` - "${{ inputs.add-to-toolset-flag }}" + ${{ inputs.add-to-toolset-flag }} diff --git a/.github/workflows/get-xamarin-versions.yml b/.github/workflows/get-xamarin-versions.yml index 13fb5c8..729ac15 100644 --- a/.github/workflows/get-xamarin-versions.yml +++ b/.github/workflows/get-xamarin-versions.yml @@ -77,7 +77,6 @@ jobs: - uses: ./.github/actions/send-slack-notification with: url: ${{ secrets.SLACK_CHANNEL_URL }} - tool-name: 'Xamarin or Python' - pipeline-url: '${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}' - image-url: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' - text: "The build of the Xamarin or Python detection pipeline failed :progress-error:" + tool-name: 'Python or Xamarin' + pipeline-url: '$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID' + text: "The build of the Xamarin or Python detection pipeline has failed stages:" diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 5dce061..c609a4b 100644 --- a/get-new-tool-versions/send-slack-notification.ps1 +++ b/get-new-tool-versions/send-slack-notification.ps1 @@ -14,6 +14,8 @@ Optional parameter. The pipeline URL Optional parameter. The image URL .PARAMETER Text Optional parameter. The message to post +.PARAMETER AddToToolsetFlag +Optional parameter. Flag to alternate message text for adding new version of a tool to toolset notification #> param( @@ -25,11 +27,11 @@ param( [ValidateNotNullOrEmpty()] [System.String]$ToolName, - [Switch]$AddToToolsetFlag, [System.String]$ToolVersion, [System.String]$PipelineUrl, [System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png', - [System.String]$Text + [System.String]$Text, + [Switch]$AddToToolsetFlag ) # Import helpers module @@ -42,10 +44,11 @@ if ([string]::IsNullOrWhiteSpace($Text)) { } else { $Text = "The following versions of '$toolName' are available to upload: $toolVersion" } - if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { - $Text += "\nLink to the pipeline: $pipelineUrl" - } } +if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { + $Text += "\nLink to the pipeline: $pipelineUrl" +} + $jsonBodyMessage = @" { "blocks": [ diff --git a/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 b/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 index 9634ecd..da09401 100644 --- a/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 +++ b/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 @@ -1,13 +1,15 @@ <# .SYNOPSIS -Check and return list of new available tool versions +Check and return list of new available tool versions that not added to toolsets yet .PARAMETER ToolName -Required parameter. The name of tool for which parser is available (Node, Go, Python, Xamarin) +Required parameter. The name of tool for which parser is available (Python, Xamarin) #> param ( - [Parameter(Mandatory)] [string] $ToolName + [Parameter(Mandatory)] + [ValidateSet("Python", "Xamarin")] + [string]$ToolName ) if ($ToolName -eq "Python") { @@ -16,8 +18,8 @@ if ($ToolName -eq "Python") { Where-Object stable -eq $true | ForEach-Object {$_.version.split(".")[0,1] -join"."} | Select-Object -Unique - $toolsetManifestUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2019.json" - $latestExistingMinorVesion = ((Invoke-RestMethod $toolsetManifestUrl).toolcache | + $toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2019.json" + $latestExistingMinorVesion = ((Invoke-RestMethod $toolsetUrl).toolcache | Where-Object {$_.name -eq "Python" -and $_.arch -eq "x64"}).versions | ForEach-Object {$_.split(".")[0,1] -join"."} | Select-Object -Last 1 @@ -28,8 +30,8 @@ if ($ToolName -eq "Xamarin") { $xamarinReleases = (Invoke-RestMethod "http://aka.ms/manifest/stable").items $xamarinProducts = @('Mono Framework', 'Xamarin.Android', 'Xamarin.iOS', 'Xamarin.Mac') $filteredReleases = $xamarinReleases | Where-Object {$_.name -in $xamarinProducts} | Sort-Object name | Select-Object name, version - $toolsetManifestUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/macos/toolsets/toolset-11.json" - $uploadedReleases = (Invoke-RestMethod $toolsetManifestUrl).xamarin + $toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/macos/toolsets/toolset-11.json" + $uploadedReleases = (Invoke-RestMethod $toolsetUrl).xamarin $releasesOnImage = @{ 'Mono Framework' = $uploadedReleases.'mono-versions' 'Xamarin.Android' = $uploadedReleases.'android-versions'