From 7ec75e0761376c2b97aa20c3ca6c5504e9d852b5 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 19 Mar 2021 15:23:57 +0300 Subject: [PATCH 01/33] add xamarin tool version --- azure-pipelines/get-tool-versions-xamarin.yml | 37 +++++++++++++++++++ azure-pipelines/templates/check-versions.yml | 4 +- .../get-new-tool-versions.ps1 | 14 +++++-- .../parsers/parsers-factory.psm1 | 2 + .../parsers/xamarin-parser.psm1 | 30 +++++++++++++++ 5 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 azure-pipelines/get-tool-versions-xamarin.yml create mode 100644 get-new-tool-versions/parsers/xamarin-parser.psm1 diff --git a/azure-pipelines/get-tool-versions-xamarin.yml b/azure-pipelines/get-tool-versions-xamarin.yml new file mode 100644 index 0000000..866f810 --- /dev/null +++ b/azure-pipelines/get-tool-versions-xamarin.yml @@ -0,0 +1,37 @@ +name: $(date:yyyyMMdd)$(rev:.r) +trigger: none +pr: none +schedules: +- cron: "0 8 * * Thu" + displayName: Daily build + branches: + include: + - main + always: true + +variables: + PoolName: 'Azure Pipelines' + VmImage: 'ubuntu-18.04' + +stages: +- stage: Find_New_Versions + dependsOn: [] + jobs: + - job: Find_New_Versions + pool: + name: $(PoolName) + vmImage: $(VmImage) + steps: + - template: /azure-pipelines/templates/get-tool-versions-steps.yml + +- stage: Check_New_Versions + dependsOn: Find_New_Versions + jobs: + - job: Check_New_Versions + pool: + name: $(PoolName) + vmImage: $(VmImage) + variables: + ToolVersions: $[ stageDependencies.Find_New_Versions.Find_New_Versions.outputs['Get_versions.TOOL_VERSIONS'] ] + steps: + - template: /azure-pipelines/templates/check-versions.yml diff --git a/azure-pipelines/templates/check-versions.yml b/azure-pipelines/templates/check-versions.yml index c7ad39f..b6c027a 100644 --- a/azure-pipelines/templates/check-versions.yml +++ b/azure-pipelines/templates/check-versions.yml @@ -21,7 +21,7 @@ steps: TargetType: inline script: | $ToolName = "$(TOOL_NAME)" - if ($ToolName -eq "Python") { + if ($ToolName -in @("Python", "Xamarin") { $PipelineUrl = " " } else { $PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)" @@ -36,7 +36,7 @@ steps: $newBuildName = "[FOUND] $(Build.BuildNumber)" Write-Host "##vso[build.updatebuildnumber]$newBuildName" -- task: PowerShell@2 +- task: PowerShell@2 displayName: 'Send Slack notification' inputs: targetType: filePath diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index e2f0474..bab022b 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -3,7 +3,7 @@ Check and return list of new available tool versions .PARAMETER ToolName -Required parameter. The name of tool for which parser is available (Node, Go, Python) +Required parameter. The name of tool for which parser is available (Node, Go, Python, Xamarin) #> param ( @@ -16,10 +16,18 @@ $ToolVersionParser = Get-ToolVersionsParser -ToolName $ToolName $VersionsFromDist = $ToolVersionParser.GetAvailableVersions() $VersionsFromManifest = $ToolVersionParser.GetUploadedVersions() -$VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } +$joinChars = ", " +if ($ToolName -eq "Xamarin") { + $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object { + '{0,-15} : {1}' -f $_.name, $_.version + } + $joinChars = "\n" +} else { + $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } +} if ($VersionsToBuild) { - $availableVersions = $VersionsToBuild -join ", " + $availableVersions = $VersionsToBuild -join $joinChars Write-Host "The following versions are available to build:`n${availableVersions}" Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" } else { diff --git a/get-new-tool-versions/parsers/parsers-factory.psm1 b/get-new-tool-versions/parsers/parsers-factory.psm1 index eb9b69c..199136c 100644 --- a/get-new-tool-versions/parsers/parsers-factory.psm1 +++ b/get-new-tool-versions/parsers/parsers-factory.psm1 @@ -1,6 +1,7 @@ using module "./node-parser.psm1" using module "./go-parser.psm1" using module "./python-parser.psm1" +using module "./xamarin-parser.psm1" function Get-ToolVersionsParser { param( @@ -12,6 +13,7 @@ function Get-ToolVersionsParser { "Node" { return [NodeVersionsParser]::New() } "Go" { return [GoVersionsParser]::New() } "Python" { return [PythonVersionsParser]::New() } + "Xamarin" { return [XamarinversionsParser]::New() } Default { throw "Unknown tool name" } diff --git a/get-new-tool-versions/parsers/xamarin-parser.psm1 b/get-new-tool-versions/parsers/xamarin-parser.psm1 new file mode 100644 index 0000000..7d69416 --- /dev/null +++ b/get-new-tool-versions/parsers/xamarin-parser.psm1 @@ -0,0 +1,30 @@ +using module "./base-parser.psm1" + +class XamarinVersionsParser: BaseVersionsParser { + [PSCustomObject] GetAvailableVersions() { + $allVersions = $this.ParseAllAvailableVersions() + return $allVersions + } + + [hashtable] GetUploadedVersions() { + $url = $this.BuildGitHubFileUrl("actions", "virtual-environments", "main", "images/macos/toolsets/toolset-11.0.json") + $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds + $xamarin = $releases.xamarin + $xamarinReleases = @{ + 'Mono Framework' = $xamarin.'mono-versions' + 'Xamarin.Android' = $xamarin.'android-versions' + 'Xamarin.iOS' = $xamarin.'ios-versions' + 'Xamarin.Mac' = $xamarin.'mac-versions' + } + return $xamarinReleases + } + + hidden [PSCustomObject] ParseAllAvailableVersions() { + $url = "http://aka.ms/manifest/stable" + $filteredProducts = @('Mono Framework', 'Xamarin.Android', 'Xamarin.iOS', 'Xamarin.Mac') + $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds + $items = $releases.items + $products = $items | Where-Object {$_.name -in $filteredProducts} | Sort-Object name | Select-Object name, version + return $products + } +} \ No newline at end of file From 81507e485bbfb26fc947bea20be17627676e7c0a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 19 Mar 2021 15:45:09 +0300 Subject: [PATCH 02/33] fix format --- get-new-tool-versions/get-new-tool-versions.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index bab022b..75e0353 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -18,10 +18,10 @@ $VersionsFromManifest = $ToolVersionParser.GetUploadedVersions() $joinChars = ", " if ($ToolName -eq "Xamarin") { - $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object { + $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object {[string]::Empty} { '{0,-15} : {1}' -f $_.name, $_.version } - $joinChars = "\n" + $joinChars = "\n\t" } else { $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } } From 725c68b777db34cb2d81aa0468ac5be38fe4567a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 22 Mar 2021 13:44:19 +0300 Subject: [PATCH 03/33] fix message --- get-new-tool-versions/send-slack-notification.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 050af3e..5b5aebb 100644 --- a/get-new-tool-versions/send-slack-notification.ps1 +++ b/get-new-tool-versions/send-slack-notification.ps1 @@ -35,7 +35,7 @@ param( Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking # Create JSON body -$text = "The following versions of '$toolName' are available to upload: $toolVersion" +$text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { $text += "\nLink to the pipeline: $pipelineUrl" } From 77b53792b3ba629483a476d78753abd59102b985 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 22 Mar 2021 21:35:24 +0300 Subject: [PATCH 04/33] update message for Xamarin --- get-new-tool-versions/send-slack-notification.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 5b5aebb..3f3518a 100644 --- a/get-new-tool-versions/send-slack-notification.ps1 +++ b/get-new-tool-versions/send-slack-notification.ps1 @@ -35,7 +35,11 @@ param( Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking # Create JSON body -$text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" +if ($toolName -eq "Xamarin") { + $text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" +} else { + $text = "The following versions of '$toolName' are available to upload: $toolVersion" +} if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { $text += "\nLink to the pipeline: $pipelineUrl" } From 80bbe2ac05c0c2226dec39ff487f3c78b32a9ffa Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Tue, 6 Apr 2021 16:03:15 +0300 Subject: [PATCH 05/33] update regex pattern --- get-new-tool-versions/parsers/go-parser.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-new-tool-versions/parsers/go-parser.psm1 b/get-new-tool-versions/parsers/go-parser.psm1 index 19f3a21..5b9abb0 100644 --- a/get-new-tool-versions/parsers/go-parser.psm1 +++ b/get-new-tool-versions/parsers/go-parser.psm1 @@ -15,7 +15,7 @@ class GoVersionsParser: BaseVersionsParser { hidden [SemVer] FormatVersion([string]$VersionSpec) { $cleanVersion = $VersionSpec -replace "^go", "" - $semanticVersion = $cleanVersion -replace "(\d+\.\d+\.?\d+?)((?:alpha|beta|rc))(\d*)",'$1-$2.$3' + $semanticVersion = $cleanVersion -replace '(\d+\.\d+\.?\d*?)((?:alpha|beta|rc))(\d*)', '$1-$2.$3' return [SemVer]$semanticVersion } From 504e746b969d9a91037f5bf4f2750c37d987aa89 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 5 May 2021 16:47:49 +0300 Subject: [PATCH 06/33] add missing bracket --- azure-pipelines/templates/check-versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/templates/check-versions.yml b/azure-pipelines/templates/check-versions.yml index b6c027a..9af96ef 100644 --- a/azure-pipelines/templates/check-versions.yml +++ b/azure-pipelines/templates/check-versions.yml @@ -21,7 +21,7 @@ steps: TargetType: inline script: | $ToolName = "$(TOOL_NAME)" - if ($ToolName -in @("Python", "Xamarin") { + if ($ToolName -in @("Python", "Xamarin")) { $PipelineUrl = " " } else { $PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)" From e81db48281f5500db66afcbca33cceffe0f9824a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Thu, 20 May 2021 11:07:36 +0300 Subject: [PATCH 07/33] Rename toolset for macOS Big Sur --- get-new-tool-versions/parsers/xamarin-parser.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-new-tool-versions/parsers/xamarin-parser.psm1 b/get-new-tool-versions/parsers/xamarin-parser.psm1 index 7d69416..fb5c135 100644 --- a/get-new-tool-versions/parsers/xamarin-parser.psm1 +++ b/get-new-tool-versions/parsers/xamarin-parser.psm1 @@ -7,7 +7,7 @@ class XamarinVersionsParser: BaseVersionsParser { } [hashtable] GetUploadedVersions() { - $url = $this.BuildGitHubFileUrl("actions", "virtual-environments", "main", "images/macos/toolsets/toolset-11.0.json") + $url = $this.BuildGitHubFileUrl("actions", "virtual-environments", "main", "images/macos/toolsets/toolset-11.json") $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds $xamarin = $releases.xamarin $xamarinReleases = @{ From 41a1acf1a4a54f294bc6b8c9d031936bf4ad0846 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Tue, 15 Jun 2021 19:24:00 +0000 Subject: [PATCH 08/33] first attempt to support lts --- node-manifest-config.json | 8 ++++ packages-generation/manifest-utils.psm1 | 50 +++++++++++++++++++++---- 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 node-manifest-config.json diff --git a/node-manifest-config.json b/node-manifest-config.json new file mode 100644 index 0000000..5562000 --- /dev/null +++ b/node-manifest-config.json @@ -0,0 +1,8 @@ +{ + "regex": "node-\\d+\\.\\d+\\.\\d+-(\\w+)-(x\\d+)", + "groups": { + "arch": 2, + "platform": 1 + }, + "lts_rule_expression": "(Invoke-RestMethod 'https://raw.githubusercontent.com/nodejs/Release/main/schedule.json').PSObject.Properties | Where-Object { $_.Value.codename } | ForEach-Object { @{ Name = $_.Name.TrimStart('v'); Value = $_.Value.codename } }" +} \ No newline at end of file diff --git a/packages-generation/manifest-utils.psm1 b/packages-generation/manifest-utils.psm1 index df2a8b2..71e7f85 100644 --- a/packages-generation/manifest-utils.psm1 +++ b/packages-generation/manifest-utils.psm1 @@ -50,6 +50,7 @@ function Build-VersionsManifest { ) $Releases = $Releases | Sort-Object -Property "published_at" -Descending + $ltsRules = Get-LtsRules -Configuration $Configuration $versionsHash = @{} foreach ($release in $Releases) { @@ -64,17 +65,52 @@ function Build-VersionsManifest { continue } + $ltsStatus = Get-VersionLtsStatus -Version $versionKey -LtsRules $ltsRules $stable = $version.PreReleaseLabel ? $false : $true [array]$releaseAssets = $release.assets | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration } - $versionsHash.Add($versionKey, [PSCustomObject]@{ - version = $versionKey - stable = $stable - release_url = $release.html_url - files = $releaseAssets - }) + $versionHash = [PSCustomObject]@{} + $versionHash | Add-Member -Name "version" -Value $versionKey -MemberType NoteProperty + $versionHash | Add-Member -Name "stable" -Value $stable -MemberType NoteProperty + if ($ltsStatus) { $versionHash | Add-Member -Name "lts" -Value $ltsStatus -MemberType NoteProperty } + $versionHash | Add-Member -Name "release_url" -Value $release.html_url -MemberType NoteProperty + $versionHash | Add-Member -Name "files" -Value $releaseAssets -MemberType NoteProperty + $versionsHash.Add($versionKey, $versionHash) } # Sort versions by descending return $versionsHash.Values | Sort-Object -Property @{ Expression = { [Semver]$_.version }; Descending = $true } -} \ No newline at end of file +} + +function Get-LtsRules { + param ( + [Parameter(Mandatory)][object]$Configuration + ) + + $ruleExpression = $Configuration."lts_rule_expression" + if ($ruleExpression) { + Invoke-Expression $ruleExpression + } else { + @() + } +} + +function Get-VersionLtsStatus { + param ( + [Parameter(Mandatory)][string]$Version, + [array]$LtsRules + ) + + foreach ($ltsRule in $LtsRules) { + if (($Version -eq $ltsRule.Name) -or ($Version.StartsWith("$($ltsRule.Name)."))) { + return $ltsRule.Value + } + } + + return $null + +} + +# Invoke-RestMethod "https://raw.githubusercontent.com/nodejs/Release/main/schedule.json" +# $arr.PSObject.Properties | Where-Object { $_.Value.codename } | ForEach-Object { @( @{ $_.Name = $_.Value.codename }) } +# (Invoke-RestMethod 'https://raw.githubusercontent.com/nodejs/Release/main/schedule.json').PSObject.Properties | Where-Object { $_.Value.codename } | ForEach-Object { @{ Name = $_.Name.TrimStart('v'); Value = $_.Value.codename } } \ No newline at end of file From 878c283d3b631405976a7b2d66d97951b5016cc9 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Jun 2021 05:46:31 +0000 Subject: [PATCH 09/33] implement pester tests --- node-manifest-config.json | 8 --- packages-generation/manifest-utils.Tests.ps1 | 52 +++++++++++++++++++- 2 files changed, 51 insertions(+), 9 deletions(-) delete mode 100644 node-manifest-config.json diff --git a/node-manifest-config.json b/node-manifest-config.json deleted file mode 100644 index 5562000..0000000 --- a/node-manifest-config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "regex": "node-\\d+\\.\\d+\\.\\d+-(\\w+)-(x\\d+)", - "groups": { - "arch": 2, - "platform": 1 - }, - "lts_rule_expression": "(Invoke-RestMethod 'https://raw.githubusercontent.com/nodejs/Release/main/schedule.json').PSObject.Properties | Where-Object { $_.Value.codename } | ForEach-Object { @{ Name = $_.Name.TrimStart('v'); Value = $_.Value.codename } }" -} \ No newline at end of file diff --git a/packages-generation/manifest-utils.Tests.ps1 b/packages-generation/manifest-utils.Tests.ps1 index 0fcaf05..15765d1 100644 --- a/packages-generation/manifest-utils.Tests.ps1 +++ b/packages-generation/manifest-utils.Tests.ps1 @@ -126,7 +126,7 @@ Describe "Build-VersionsManifest" { [PSCustomObject]@{ version = "3.8.3"; stable = $true; release_url = "fake_html_url"; files = $expectedManifestFiles } ) [array]$actualManifest = Build-VersionsManifest -Releases $releases -Configuration $configuration - Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest + Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest } It "take latest published release for each version" { @@ -161,4 +161,54 @@ Describe "Build-VersionsManifest" { [array]$actualManifest = Build-VersionsManifest -Releases $releases -Configuration $configuration Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest } + + It "set correct lts value for versions" { + $releases = @( + @{ name = "14.2.1"; draft = false; prerelease = $false; html_url = "fake_html_url"; published_at = "2020-05-14T09:54:06Z"; assets = $assets }, + @{ name = "12.0.1"; draft = $false; prerelease = false; html_url = "fake_html_url"; published_at = "2020-05-06T11:45:36Z"; assets = $assets }, + @{ name = "16.2.2"; draft = $false; prerelease = $false; html_url = "fake_html_url"; published_at = "2020-05-06T11:43:38Z"; assets = $assets } + ) + $configuration = @{ + regex = "python-\d+\.\d+\.\d+-(\w+)-([\w\.]+)?-?(x\d+)"; + groups = [PSCustomObject]@{ platform = 1; platform_version = 2; arch = "x64"; } + lts_rule_expression = "@(@{ Name = '14'; Value = 'Fermium' }, @{ Name = '12'; Value = 'Erbium' })" + } + $expectedManifest = @( + [PSCustomObject]@{ version = "16.2.2"; stable = $true; release_url = "fake_html_url"; files = $expectedManifestFiles }, + [PSCustomObject]@{ version = "14.2.1"; stable = $true; lts = "Fermium"; release_url = "fake_html_url"; files = $expectedManifestFiles }, + [PSCustomObject]@{ version = "12.0.1"; stable = $true; lts = "Erbium"; release_url = "fake_html_url"; files = $expectedManifestFiles } + ) + [array]$actualManifest = Build-VersionsManifest -Releases $releases -Configuration $configuration + Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest + } +} + +Describe "Get-VersionLtsStatus" { + $ltsRules = @( + @{ Name = "14"; Value = "Fermium" }, + @{ Name = "12"; Value = "Erbium" }, + @{ Name = "10"; Value = $true }, + @{ Name = "8.3"; Value = "LTS 8.3" } + ) + + It "lts label is matched" { + Get-VersionLtsStatus -Version "14.2.2" -LtsRules $ltsRules | Should -Be "Fermium" + Get-VersionLtsStatus -Version "12.3.1" -LtsRules $ltsRules | Should -Be "Erbium" + Get-VersionLtsStatus -Version "10.8.1" -LtsRules $ltsRules | Should -Be $true + Get-VersionLtsStatus -Version "8.3.2" -LtsRules $ltsRules | Should -Be "LTS 8.3" + Get-VersionLtsStatus -Version "14" -LtsRules $ltsRules | Should -Be "Fermium" + } + + It "lts label is not matched" { + Get-VersionLtsStatus -Version "9.1" -LtsRules $ltsRules | Should -Be $null + Get-VersionLtsStatus -Version "13.8" -LtsRules $ltsRules | Should -Be $null + Get-VersionLtsStatus -Version "5" -LtsRules $ltsRules | Should -Be $null + Get-VersionLtsStatus -Version "8.4" -LtsRules $ltsRules | Should -Be $null + Get-VersionLtsStatus -Version "142.5.1" -LtsRules $ltsRules | Should -Be $null + } + + It "no rules" { + Get-VersionLtsStatus -Version "14.2.2" | Should -Be $null + Get-VersionLtsStatus -Version "12.3.1" -LtsRules $null | Should -Be $null + } } \ No newline at end of file From 00039881baf4907b7c4df5c50ce0aa670d24fe0f Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Jun 2021 05:48:00 +0000 Subject: [PATCH 10/33] remove comments --- packages-generation/manifest-utils.psm1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages-generation/manifest-utils.psm1 b/packages-generation/manifest-utils.psm1 index 71e7f85..ea7ecba 100644 --- a/packages-generation/manifest-utils.psm1 +++ b/packages-generation/manifest-utils.psm1 @@ -110,7 +110,3 @@ function Get-VersionLtsStatus { return $null } - -# Invoke-RestMethod "https://raw.githubusercontent.com/nodejs/Release/main/schedule.json" -# $arr.PSObject.Properties | Where-Object { $_.Value.codename } | ForEach-Object { @( @{ $_.Name = $_.Value.codename }) } -# (Invoke-RestMethod 'https://raw.githubusercontent.com/nodejs/Release/main/schedule.json').PSObject.Properties | Where-Object { $_.Value.codename } | ForEach-Object { @{ Name = $_.Name.TrimStart('v'); Value = $_.Value.codename } } \ No newline at end of file From f19d5f4b3c51d47e2a8e3a64d2400cde14aee3a8 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Jun 2021 09:17:33 +0000 Subject: [PATCH 11/33] fix comments --- packages-generation/manifest-utils.psm1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages-generation/manifest-utils.psm1 b/packages-generation/manifest-utils.psm1 index ea7ecba..b0da90b 100644 --- a/packages-generation/manifest-utils.psm1 +++ b/packages-generation/manifest-utils.psm1 @@ -72,7 +72,9 @@ function Build-VersionsManifest { $versionHash = [PSCustomObject]@{} $versionHash | Add-Member -Name "version" -Value $versionKey -MemberType NoteProperty $versionHash | Add-Member -Name "stable" -Value $stable -MemberType NoteProperty - if ($ltsStatus) { $versionHash | Add-Member -Name "lts" -Value $ltsStatus -MemberType NoteProperty } + if ($ltsStatus) { + $versionHash | Add-Member -Name "lts" -Value $ltsStatus -MemberType NoteProperty + } $versionHash | Add-Member -Name "release_url" -Value $release.html_url -MemberType NoteProperty $versionHash | Add-Member -Name "files" -Value $releaseAssets -MemberType NoteProperty $versionsHash.Add($versionKey, $versionHash) @@ -108,5 +110,4 @@ function Get-VersionLtsStatus { } return $null - } From 2a422a2d525852b90cba85c8a7acdb95c91ec6fc Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Thu, 12 Aug 2021 10:06:34 +0300 Subject: [PATCH 12/33] Create validate_manifest.yml --- .github/workflows/validate_manifest.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/validate_manifest.yml diff --git a/.github/workflows/validate_manifest.yml b/.github/workflows/validate_manifest.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.github/workflows/validate_manifest.yml @@ -0,0 +1 @@ + From 6147177edd2267789024fb622864864d8c45fd87 Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Thu, 12 Aug 2021 15:13:40 +0300 Subject: [PATCH 13/33] Added Go validator --- .github/workflows/validate_manifest.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/validate_manifest.yml b/.github/workflows/validate_manifest.yml index 8b13789..11d8665 100644 --- a/.github/workflows/validate_manifest.yml +++ b/.github/workflows/validate_manifest.yml @@ -1 +1,15 @@ +name: Validate manifest + +on: + workflow_dispatch + +jobs: + validation: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Validate Go manifest + shell: pwsh + run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json From 98826eed538e949e1a5335e459fc3c6ea58b61bf Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Thu, 12 Aug 2021 15:34:50 +0300 Subject: [PATCH 14/33] Added node manifest validator --- .github/workflows/validate_manifest.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/validate_manifest.yml b/.github/workflows/validate_manifest.yml index 11d8665..439f656 100644 --- a/.github/workflows/validate_manifest.yml +++ b/.github/workflows/validate_manifest.yml @@ -9,7 +9,12 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Validate Go manifest shell: pwsh run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json + + - name: Validate Node manifest + shell: pwsh + run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json From ab37396421776f90fbcc226fdd93a8d41a29f6a7 Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Thu, 12 Aug 2021 15:54:56 +0300 Subject: [PATCH 15/33] Added python validator --- .github/workflows/validate_manifest.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate_manifest.yml b/.github/workflows/validate_manifest.yml index 439f656..483a460 100644 --- a/.github/workflows/validate_manifest.yml +++ b/.github/workflows/validate_manifest.yml @@ -1,4 +1,4 @@ -name: Validate manifest +name: Validate manifests on: workflow_dispatch @@ -10,11 +10,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Validate Go manifest + - name: Validate go-versions manifest shell: pwsh run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json - - name: Validate Node manifest + - name: Validate node-versions manifest shell: pwsh run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json + - name: Validate python-versions manifest + shell: pwsh + run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json From 8c62a832045ed3cf7cae491e5ea1f063f21ec2cc Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Tue, 17 Aug 2021 17:03:20 +0300 Subject: [PATCH 16/33] Add CancelWorkflow method to github-api.psm1 and update get-new-tool-versions.ps1 --- get-new-tool-versions/get-new-tool-versions.ps1 | 6 +++++- github/github-api.psm1 | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index 75e0353..de31ffd 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -29,7 +29,11 @@ if ($ToolName -eq "Xamarin") { if ($VersionsToBuild) { $availableVersions = $VersionsToBuild -join $joinChars Write-Host "The following versions are available to build:`n${availableVersions}" - Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" + if ($ToolName -eq "Go") { + Write-Host "::set-output name=version_number::${availableVersions}" + } else { + Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" + } } else { Write-Host "There aren't versions to build" } diff --git a/github/github-api.psm1 b/github/github-api.psm1 index 3103ed0..6ba32c7 100644 --- a/github/github-api.psm1 +++ b/github/github-api.psm1 @@ -124,6 +124,11 @@ class GitHubApi } } + [void] CancelWorkflow([string]$WorkflowId) { + $url = "actions/runs/$WorkflowId/cancel" + $this.InvokeRestMethod($url, 'POST', $null, $null) + } + [object] hidden InvokeRestMethod( [string] $Url, [string] $Method, From 6b66054ab678b3824aa1c57f5a0711475897f203 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Thu, 19 Aug 2021 16:11:48 +0300 Subject: [PATCH 17/33] Add new parameter to send-slack-notification.ps1 and update get-new-tool-versions.ps1 --- .../get-new-tool-versions.ps1 | 7 ++--- .../send-slack-notification.ps1 | 30 ++++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index de31ffd..4672876 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -29,11 +29,8 @@ if ($ToolName -eq "Xamarin") { if ($VersionsToBuild) { $availableVersions = $VersionsToBuild -join $joinChars Write-Host "The following versions are available to build:`n${availableVersions}" - if ($ToolName -eq "Go") { - Write-Host "::set-output name=version_number::${availableVersions}" - } else { - Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" - } + Write-Host "::set-output name=version_number::${availableVersions}" + Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" } else { Write-Host "There aren't versions to build" } diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 3f3518a..05be9c6 100644 --- a/get-new-tool-versions/send-slack-notification.ps1 +++ b/get-new-tool-versions/send-slack-notification.ps1 @@ -7,11 +7,13 @@ Required parameter. Incoming Webhook URL to post a message .PARAMETER ToolName Required parameter. The name of tool .PARAMETER ToolVersion -Required parameter. Specifies the version of tool +Optional parameter. Specifies the version of tool .PARAMETER PipelineUrl -Required parameter. The pipeline URL +Optional parameter. The pipeline URL .PARAMETER ImageUrl Optional parameter. The image URL +.PARAMETER Text +Optional parameter. The message to post #> param( @@ -23,25 +25,25 @@ param( [ValidateNotNullOrEmpty()] [System.String]$ToolName, - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] [System.String]$ToolVersion, - [System.String]$PipelineUrl, - [System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png' + [System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png', + [System.String]$Text ) # Import helpers module Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking # Create JSON body -if ($toolName -eq "Xamarin") { - $text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" -} else { - $text = "The following versions of '$toolName' are available to upload: $toolVersion" -} -if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { - $text += "\nLink to the pipeline: $pipelineUrl" +if ([string]::IsNullOrWhiteSpace($Text)) { + if ($toolName -eq "Xamarin") { + $Text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" + } else { + $Text = "The following versions of '$toolName' are available to upload: $toolVersion" + } + if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { + $Text += "\nLink to the pipeline: $pipelineUrl" + } } $jsonBodyMessage = @" { @@ -50,7 +52,7 @@ $jsonBodyMessage = @" "type": "section", "text": { "type": "mrkdwn", - "text": "$text" + "text": "$Text" }, "accessory": { "type": "image", From e9ef44e60c2afb3444cd6490fe34157ec9683299 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Fri, 20 Aug 2021 17:40:16 +0300 Subject: [PATCH 18/33] Rename version_number variable to TOOL_VERSIONS --- get-new-tool-versions/get-new-tool-versions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index 4672876..558dd0f 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -29,7 +29,7 @@ if ($ToolName -eq "Xamarin") { if ($VersionsToBuild) { $availableVersions = $VersionsToBuild -join $joinChars Write-Host "The following versions are available to build:`n${availableVersions}" - Write-Host "::set-output name=version_number::${availableVersions}" + Write-Host "::set-output name=TOOL_VERSIONS::${availableVersions}" Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" } else { Write-Host "There aren't versions to build" From 9b849b3d5afa31a96752c421cb7d5a4c5dfcd08c Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Mon, 23 Aug 2021 18:12:30 +0300 Subject: [PATCH 19/33] Move get-xamarin-versions pipeline --- .github/workflows/get-xamarin-versions.yml | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/get-xamarin-versions.yml diff --git a/.github/workflows/get-xamarin-versions.yml b/.github/workflows/get-xamarin-versions.yml new file mode 100644 index 0000000..8f0c6b3 --- /dev/null +++ b/.github/workflows/get-xamarin-versions.yml @@ -0,0 +1,68 @@ +name: Get Xamarin versions +on: + schedule: + - cron: '0 8 * * THU' + workflow_dispatch: + +env: + TOOL_NAME: "Xamarin" +defaults: + run: + shell: pwsh + +jobs: + find_new_versions: + name: Find new versions + runs-on: ubuntu-latest + outputs: + versions_output: ${{ steps.Get_new_versions.outputs.TOOL_VERSIONS }} + steps: + - uses: actions/checkout@v2 + + - id: Get_new_versions + name: Get new versions + run: ./get-new-tool-versions/get-new-tool-versions.ps1 -ToolName ${{ env.TOOL_NAME }} + + check_new_versions: + name: Check new versions + runs-on: ubuntu-latest + needs: find_new_versions + env: + TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}} + steps: + - uses: actions/checkout@v2 + + - name: Check Versions + if: success() && env.TOOL_VERSIONS == '' + run: | + Write-Host "No new versions were found" + Import-Module "./github/github-api.psm1" + $gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" ` + -AccessToken "${{ secrets.GITHUB_TOKEN }}" + + $gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID") + Start-Sleep -Seconds 60 + + - name: Send Slack notification + run: | + ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` + -ToolName "${{ env.TOOL_NAME }}" ` + -ToolVersion "${{ env.TOOL_VERSIONS }}" ` + -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" + + check_build: + name: Check build for failures + runs-on: ubuntu-latest + needs: [find_new_versions, check_new_versions] + if: failure() + steps: + - uses: actions/checkout@v2 + + - name: Send Slack notification if build fails + run: | + $pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" + $Message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" + ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` + -ToolName "${{ env.TOOL_NAME }}" ` + -Text "$Message" ` + -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" From 5a00becf4740a9c1444cb2ad127100415f001af5 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Wed, 25 Aug 2021 15:45:33 +0300 Subject: [PATCH 20/33] Update Send Slack notification step to send a custom message --- .github/workflows/get-xamarin-versions.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/get-xamarin-versions.yml b/.github/workflows/get-xamarin-versions.yml index 8f0c6b3..2e8960e 100644 --- a/.github/workflows/get-xamarin-versions.yml +++ b/.github/workflows/get-xamarin-versions.yml @@ -45,10 +45,11 @@ jobs: - name: Send Slack notification run: | + $message = "The following versions of '${{ env.TOOL_NAME }}' are available, consider adding them to toolset: ${{ env.TOOL_VERSIONS }}" ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` -ToolName "${{ env.TOOL_NAME }}" ` - -ToolVersion "${{ env.TOOL_VERSIONS }}" ` - -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" + -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" ` + -Text "$message" check_build: name: Check build for failures @@ -61,8 +62,8 @@ jobs: - name: Send Slack notification if build fails run: | $pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" - $Message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" + $message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` -ToolName "${{ env.TOOL_NAME }}" ` - -Text "$Message" ` + -Text "$message" ` -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" From 3d09ce1d1983839631e042ac7295fdefbd440f64 Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Fri, 3 Sep 2021 11:54:24 +0300 Subject: [PATCH 21/33] Delete validate_manifest.yml --- .github/workflows/validate_manifest.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/workflows/validate_manifest.yml diff --git a/.github/workflows/validate_manifest.yml b/.github/workflows/validate_manifest.yml deleted file mode 100644 index 483a460..0000000 --- a/.github/workflows/validate_manifest.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Validate manifests - -on: - workflow_dispatch - -jobs: - validation: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Validate go-versions manifest - shell: pwsh - run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json - - - name: Validate node-versions manifest - shell: pwsh - run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json - - - name: Validate python-versions manifest - shell: pwsh - run: .\packages-generation\manifest-validator.ps1 -ManifestUrl https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json From f72b7a85c7fde3007f51df66879947160d9304d8 Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Fri, 3 Sep 2021 11:55:56 +0300 Subject: [PATCH 22/33] Update manifest-validator.ps1 --- packages-generation/manifest-validator.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 7266e11..6e82ae7 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -3,6 +3,7 @@ param ( [string] $AccessToken ) +$Global:validationFailed = $false $authorizationHeaderValue = "Basic $AccessToken" $webRequestHeaders = @{} if ($AccessToken) { @@ -14,9 +15,13 @@ function Publish-Error { [string] $ErrorDescription, [object] $Exception ) - Write-Host "##vso[task.logissue type=error]ERROR: $ErrorDescription." - Write-Host "##vso[task.logissue type=error] $Exception" - Write-Host "##vso[task.complete result=Failed;]" + + echo "::error ::$ErrorDescription" + if(-not [string]::IsNullOrEmpty($Exception)) + { + Write-Output "Exception: $Exception" + } + $Global:validationFailed = $true } function Test-DownloadUrl { @@ -61,3 +66,8 @@ $manifestJson | ForEach-Object { } } } + +if($Global:validationFailed) +{ + exit 1 +} From f07ff8ddf9946290b2cd62700194520271bc3213 Mon Sep 17 00:00:00 2001 From: Yuriy-Kukushkin <87432006+Yuriy-Kukushkin@users.noreply.github.com> Date: Thu, 9 Sep 2021 18:03:55 +0300 Subject: [PATCH 23/33] Refactoring --- packages-generation/manifest-validator.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 6e82ae7..0065c3a 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -17,7 +17,7 @@ function Publish-Error { ) echo "::error ::$ErrorDescription" - if(-not [string]::IsNullOrEmpty($Exception)) + if (-not [string]::IsNullOrEmpty($Exception)) { Write-Output "Exception: $Exception" } @@ -67,7 +67,6 @@ $manifestJson | ForEach-Object { } } -if($Global:validationFailed) -{ +if ($Global:validationFailed) { exit 1 } From 7114ad2b9418eb28f6f16a14f90e99455f480883 Mon Sep 17 00:00:00 2001 From: Nikolay Frolov Date: Tue, 5 Oct 2021 13:54:40 +0300 Subject: [PATCH 24/33] Add retry strategy --- packages-generation/manifest-validator.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 0065c3a..9daf876 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -40,7 +40,7 @@ function Test-DownloadUrl { Write-Host "Downloading manifest json from '$ManifestUrl'..." try { - $manifestResponse = Invoke-WebRequest -Method Get -Uri $ManifestUrl -Headers $webRequestHeaders + $manifestResponse = Invoke-WebRequest -Method Get -Uri $ManifestUrl -Headers $webRequestHeaders -MaximumRetryCount 5 -RetryIntervalSec 10 } catch { Publish-Error "Unable to download manifest json from '$ManifestUrl'" $_ exit 1 From b5a05e45d5c3a86fcb19ef80b20d7556d8de6e69 Mon Sep 17 00:00:00 2001 From: Nikolay Frolov Date: Tue, 12 Oct 2021 10:35:17 +0300 Subject: [PATCH 25/33] Change way for versions-manifest.json gathering --- packages-generation/manifest-validator.ps1 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 9daf876..bb64643 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -1,5 +1,5 @@ param ( - [Parameter(Mandatory)][string] $ManifestUrl, + [Parameter(Mandatory)][string] $ManifestPath, [string] $AccessToken ) @@ -38,19 +38,16 @@ function Test-DownloadUrl { } } -Write-Host "Downloading manifest json from '$ManifestUrl'..." -try { - $manifestResponse = Invoke-WebRequest -Method Get -Uri $ManifestUrl -Headers $webRequestHeaders -MaximumRetryCount 5 -RetryIntervalSec 10 -} catch { - Publish-Error "Unable to download manifest json from '$ManifestUrl'" $_ +if (-not (Test-Path $ManifestPath)) { + Publish-Error "Unable to find manifest json file at '$ManifestPath'" exit 1 } -Write-Host "Parsing manifest json content from '$ManifestUrl'..." +Write-Host "Parsing manifest json content from '$ManifestPath'..." try { - $manifestJson = $manifestResponse.Content | ConvertFrom-Json + $manifestJson = $( Get-Content $ManifestPath ) | ConvertFrom-Json } catch { - Publish-Error "Unable to parse manifest json content '$ManifestUrl'" $_ + Publish-Error "Unable to parse manifest json content '$ManifestPath'" $_ exit 1 } From fa4964171990762315b9c1ad5f2406362d4b0fe0 Mon Sep 17 00:00:00 2001 From: "Nikolai Frolov (Akvelon INC)" Date: Tue, 12 Oct 2021 16:00:52 +0300 Subject: [PATCH 26/33] Minor code improvement according to comments --- packages-generation/manifest-validator.ps1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index bb64643..043eca5 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -4,11 +4,6 @@ param ( ) $Global:validationFailed = $false -$authorizationHeaderValue = "Basic $AccessToken" -$webRequestHeaders = @{} -if ($AccessToken) { - $webRequestHeaders.Add("Authorization", $authorizationHeaderValue) -} function Publish-Error { param( @@ -16,7 +11,7 @@ function Publish-Error { [object] $Exception ) - echo "::error ::$ErrorDescription" + Write-Output "::error ::$ErrorDescription" if (-not [string]::IsNullOrEmpty($Exception)) { Write-Output "Exception: $Exception" @@ -26,6 +21,7 @@ function Publish-Error { function Test-DownloadUrl { param([string] $DownloadUrl) + $authorizationHeaderValue = "Basic $AccessToken" $request = [System.Net.WebRequest]::Create($DownloadUrl) if ($AccessToken) { $request.Headers.Add("Authorization", $authorizationHeaderValue) From 359c2548cb61c09363a4be0f820f19ae34ddaba5 Mon Sep 17 00:00:00 2001 From: "Nikolai Frolov (Akvelon INC)" Date: Tue, 12 Oct 2021 17:19:45 +0300 Subject: [PATCH 27/33] Minor code improvement according to comments --- packages-generation/manifest-validator.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 043eca5..e2fd71c 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -20,10 +20,10 @@ function Publish-Error { } function Test-DownloadUrl { - param([string] $DownloadUrl) - $authorizationHeaderValue = "Basic $AccessToken" + param([string] $DownloadUrl) $request = [System.Net.WebRequest]::Create($DownloadUrl) if ($AccessToken) { + $authorizationHeaderValue = "Basic $AccessToken" $request.Headers.Add("Authorization", $authorizationHeaderValue) } try { @@ -41,7 +41,7 @@ if (-not (Test-Path $ManifestPath)) { Write-Host "Parsing manifest json content from '$ManifestPath'..." try { - $manifestJson = $( Get-Content $ManifestPath ) | ConvertFrom-Json + $manifestJson = Get-Content $ManifestPath | ConvertFrom-Json } catch { Publish-Error "Unable to parse manifest json content '$ManifestPath'" $_ exit 1 From e98e069ca6f26c2e85456b1b068999c3556268fa Mon Sep 17 00:00:00 2001 From: nikolai-frolov Date: Wed, 13 Oct 2021 15:56:14 +0300 Subject: [PATCH 28/33] Remove Access Token usage --- packages-generation/manifest-validator.ps1 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index e2fd71c..c50bceb 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -1,6 +1,5 @@ param ( - [Parameter(Mandatory)][string] $ManifestPath, - [string] $AccessToken + [Parameter(Mandatory)][string] $ManifestPath ) $Global:validationFailed = $false @@ -10,7 +9,7 @@ function Publish-Error { [string] $ErrorDescription, [object] $Exception ) - + Write-Output "::error ::$ErrorDescription" if (-not [string]::IsNullOrEmpty($Exception)) { @@ -20,12 +19,11 @@ function Publish-Error { } function Test-DownloadUrl { - param([string] $DownloadUrl) + param( + [string] $DownloadUrl + ) + $request = [System.Net.WebRequest]::Create($DownloadUrl) - if ($AccessToken) { - $authorizationHeaderValue = "Basic $AccessToken" - $request.Headers.Add("Authorization", $authorizationHeaderValue) - } try { $response = $request.GetResponse() return ([int]$response.StatusCode -eq 200) From a7532795547eaf24ad4955c18ee0cac5b7add50f Mon Sep 17 00:00:00 2001 From: Maksim Shilov <89912354+shilovmaksim@users.noreply.github.com> Date: Wed, 27 Oct 2021 10:31:19 +0300 Subject: [PATCH 29/33] New parser for xamarin and python. Reworked workflow with composite actions (#41) --- .../send-slack-notification/action.yml | 39 +++++++++ .github/workflows/get-tools-new-versions.yml | 82 +++++++++++++++++++ .github/workflows/get-xamarin-versions.yml | 69 ---------------- .../send-slack-notification.ps1 | 14 ++-- ...verify-new-tool-version-added-to-image.ps1 | 48 +++++++++++ 5 files changed, 178 insertions(+), 74 deletions(-) create mode 100644 .github/actions/send-slack-notification/action.yml create mode 100644 .github/workflows/get-tools-new-versions.yml delete mode 100644 .github/workflows/get-xamarin-versions.yml create mode 100644 get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 diff --git a/.github/actions/send-slack-notification/action.yml b/.github/actions/send-slack-notification/action.yml new file mode 100644 index 0000000..42062d3 --- /dev/null +++ b/.github/actions/send-slack-notification/action.yml @@ -0,0 +1,39 @@ +name: 'Send Slack notification' +description: 'SendSlack notification about new versions of a tool' +inputs: + url: + required: true + description: 'Slack channel url' + tool-name: + required: true + description: 'Name of a tool to send notification for. Like Xamarin or Python' + default: 'Xamarin' + tool-version: + required: false + description: 'New versions of a tool' + pipeline-url: + required: false + description: 'Url of a pipeline' + image-url: + required: false + description: 'Image url for message' + default: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png' + 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: + - id: send-slack-notification + name: Send Slack notification + shell: pwsh + run: ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ inputs.url }}" ` + -ToolName "${{ inputs.tool-name }}" ` + -ToolVersion "${{ inputs.tool-version }}" ` + -PipelineUrl "${{ inputs.pipeline-url }}" ` + -ImageUrl "${{ inputs.image-url }}" ` + -Text "${{ inputs.text }}" ` + ${{ inputs.add-to-toolset-flag }} diff --git a/.github/workflows/get-tools-new-versions.yml b/.github/workflows/get-tools-new-versions.yml new file mode 100644 index 0000000..729ac15 --- /dev/null +++ b/.github/workflows/get-tools-new-versions.yml @@ -0,0 +1,82 @@ +name: Get tools new versions +on: + schedule: + - cron: '0 8 * * THU' + workflow_dispatch: + +defaults: + run: + shell: pwsh + +jobs: + find-new-xamarin-versions: + name: Searching for new Xamarin versions + runs-on: ubuntu-latest + outputs: + versions-output: ${{ steps.get-new-xamarin-versions.outputs.versions-output }} + steps: + - uses: actions/checkout@v2 + - id: get-new-xamarin-versions + name: Get new Xamarin versions + run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName Xamarin)" + + check-new-xamarin-versions: + name: Verifying new Xamarin versions exist + runs-on: ubuntu-latest + needs: find-new-xamarin-versions + steps: + - uses: actions/checkout@v2 + - name: Check Versions + if: needs.find-new-xamarin-versions.outputs.versions-output == '' + run: Write-Host "No new versions found" + - uses: ./.github/actions/send-slack-notification + if: needs.find-new-xamarin-versions.outputs.versions-output != '' + with: + url: ${{ secrets.SLACK_CHANNEL_URL }} + tool-name: 'Xamarin' + tool-version: ${{ needs.find-new-xamarin-versions.outputs.versions-output }} + image-url: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' + add-to-toolset-flag: '-AddToToolsetFlag' + + find-new-python-versions: + name: Searching for new Python versions + runs-on: ubuntu-latest + outputs: + versions-output: ${{ steps.get-new-python-versions.outputs.versions-output }} + steps: + - uses: actions/checkout@v2 + - id: get-new-python-versions + name: Get new Python versions + run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName Python)" + + check-new-python-versions: + name: Verifying new Python versions exist + runs-on: ubuntu-latest + needs: find-new-python-versions + steps: + - uses: actions/checkout@v2 + - name: Check Versions + if: needs.find-new-python-versions.outputs.versions-output == '' + run: Write-Host "No new versions found" + - uses: ./.github/actions/send-slack-notification + if: needs.find-new-python-versions.outputs.versions-output != '' + with: + url: ${{ secrets.SLACK_CHANNEL_URL }} + tool-name: 'Python' + tool-version: ${{ needs.find-new-python-versions.outputs.versions-output }} + image-url: 'https://www.python.org/static/community_logos/python-powered-h-100x130.png' + add-to-toolset-flag: '-AddToToolsetFlag' + + check_build: + name: Check build for failures + runs-on: ubuntu-latest + needs: [check-new-xamarin-versions, check-new-python-versions] + if: failure() + steps: + - uses: actions/checkout@v2 + - uses: ./.github/actions/send-slack-notification + with: + url: ${{ secrets.SLACK_CHANNEL_URL }} + 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/.github/workflows/get-xamarin-versions.yml b/.github/workflows/get-xamarin-versions.yml deleted file mode 100644 index 2e8960e..0000000 --- a/.github/workflows/get-xamarin-versions.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Get Xamarin versions -on: - schedule: - - cron: '0 8 * * THU' - workflow_dispatch: - -env: - TOOL_NAME: "Xamarin" -defaults: - run: - shell: pwsh - -jobs: - find_new_versions: - name: Find new versions - runs-on: ubuntu-latest - outputs: - versions_output: ${{ steps.Get_new_versions.outputs.TOOL_VERSIONS }} - steps: - - uses: actions/checkout@v2 - - - id: Get_new_versions - name: Get new versions - run: ./get-new-tool-versions/get-new-tool-versions.ps1 -ToolName ${{ env.TOOL_NAME }} - - check_new_versions: - name: Check new versions - runs-on: ubuntu-latest - needs: find_new_versions - env: - TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}} - steps: - - uses: actions/checkout@v2 - - - name: Check Versions - if: success() && env.TOOL_VERSIONS == '' - run: | - Write-Host "No new versions were found" - Import-Module "./github/github-api.psm1" - $gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" ` - -AccessToken "${{ secrets.GITHUB_TOKEN }}" - - $gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID") - Start-Sleep -Seconds 60 - - - name: Send Slack notification - run: | - $message = "The following versions of '${{ env.TOOL_NAME }}' are available, consider adding them to toolset: ${{ env.TOOL_VERSIONS }}" - ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` - -ToolName "${{ env.TOOL_NAME }}" ` - -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" ` - -Text "$message" - - check_build: - name: Check build for failures - runs-on: ubuntu-latest - needs: [find_new_versions, check_new_versions] - if: failure() - steps: - - uses: actions/checkout@v2 - - - name: Send Slack notification if build fails - run: | - $pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" - $message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" - ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` - -ToolName "${{ env.TOOL_NAME }}" ` - -Text "$message" ` - -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 05be9c6..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( @@ -28,7 +30,8 @@ param( [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 @@ -36,15 +39,16 @@ Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking # Create JSON body if ([string]::IsNullOrWhiteSpace($Text)) { - if ($toolName -eq "Xamarin") { + if ($AddToToolsetFlag) { $Text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" } 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 new file mode 100644 index 0000000..da09401 --- /dev/null +++ b/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 @@ -0,0 +1,48 @@ +<# +.SYNOPSIS +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 (Python, Xamarin) +#> + +param ( + [Parameter(Mandatory)] + [ValidateSet("Python", "Xamarin")] + [string]$ToolName +) + +if ($ToolName -eq "Python") { + $pythonVesionsManifestUrl = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" + $builtStableMinorVersions = (Invoke-RestMethod $pythonVesionsManifestUrl) | + Where-Object stable -eq $true | + ForEach-Object {$_.version.split(".")[0,1] -join"."} | + Select-Object -Unique + $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 + $versionsToAdd = $builtStableMinorVersions | Where-Object {[version]$_ -gt [version]$latestExistingMinorVesion} +} + +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 + $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' + 'Xamarin.iOS' = $uploadedReleases.'ios-versions' + 'Xamarin.Mac' = $uploadedReleases.'mac-versions' + } + $versionsToAdd = $filteredReleases | Where-Object {$releasesOnImage[$_.name] -notcontains $_.version } | ForEach-Object {[string]::Empty} { + '{0,-15} : {1}' -f $_.name, $_.version + } + $joinChars = "\n\t" +} +$versionsToAdd = $versionsToAdd -join $joinChars + +return $versionsToAdd From de5faa4d9ca297882251ae99e5edb865a146cbcb Mon Sep 17 00:00:00 2001 From: Maksim Shilov <89912354+shilovmaksim@users.noreply.github.com> Date: Thu, 11 Nov 2021 10:23:00 +0300 Subject: [PATCH 30/33] Adding pypy notifications and optimizing workflow and parsers (#42) --- .github/workflows/get-tools-new-versions.yml | 86 ++++++++----------- azure-pipelines/get-tool-versions-xamarin.yml | 37 -------- azure-pipelines/templates/check-versions.yml | 2 +- .../get-new-tool-versions.ps1 | 14 +-- .../parsers/parsers-factory.psm1 | 2 - .../verify-python-parser.psm1 | 21 +++++ .../verify-xamarin-parser.psm1 | 19 ++++ .../parsers/xamarin-parser.psm1 | 30 ------- ...verify-new-tool-version-added-to-image.ps1 | 45 ++++------ 9 files changed, 97 insertions(+), 159 deletions(-) delete mode 100644 azure-pipelines/get-tool-versions-xamarin.yml create mode 100644 get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 create mode 100644 get-new-tool-versions/parsers/verify-added-to-image/verify-xamarin-parser.psm1 delete mode 100644 get-new-tool-versions/parsers/xamarin-parser.psm1 diff --git a/.github/workflows/get-tools-new-versions.yml b/.github/workflows/get-tools-new-versions.yml index 729ac15..ad06994 100644 --- a/.github/workflows/get-tools-new-versions.yml +++ b/.github/workflows/get-tools-new-versions.yml @@ -9,74 +9,56 @@ defaults: shell: pwsh jobs: - find-new-xamarin-versions: - name: Searching for new Xamarin versions + find-new-tool-versions: + strategy: + fail-fast: false + matrix: + tool: + - name: 'Xamarin' + image: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' + - name: 'Python' + image: 'https://avatars.githubusercontent.com/u/1525981?s=200&v=4' + - name: 'PyPy' + image: 'https://avatars.githubusercontent.com/u/318667?s=200&v=4' + name: 'Searching for new versions of ${{ matrix.tool.name }}' runs-on: ubuntu-latest - outputs: - versions-output: ${{ steps.get-new-xamarin-versions.outputs.versions-output }} steps: - uses: actions/checkout@v2 - - id: get-new-xamarin-versions - name: Get new Xamarin versions - run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName Xamarin)" - - check-new-xamarin-versions: - name: Verifying new Xamarin versions exist - runs-on: ubuntu-latest - needs: find-new-xamarin-versions - steps: - - uses: actions/checkout@v2 - - name: Check Versions - if: needs.find-new-xamarin-versions.outputs.versions-output == '' - run: Write-Host "No new versions found" - - uses: ./.github/actions/send-slack-notification - if: needs.find-new-xamarin-versions.outputs.versions-output != '' - with: - url: ${{ secrets.SLACK_CHANNEL_URL }} - tool-name: 'Xamarin' - tool-version: ${{ needs.find-new-xamarin-versions.outputs.versions-output }} - image-url: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' - add-to-toolset-flag: '-AddToToolsetFlag' - - find-new-python-versions: - name: Searching for new Python versions - runs-on: ubuntu-latest - outputs: - versions-output: ${{ steps.get-new-python-versions.outputs.versions-output }} - steps: - - uses: actions/checkout@v2 - - id: get-new-python-versions - name: Get new Python versions - run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName Python)" - - check-new-python-versions: - name: Verifying new Python versions exist - runs-on: ubuntu-latest - needs: find-new-python-versions - steps: - - uses: actions/checkout@v2 - - name: Check Versions - if: needs.find-new-python-versions.outputs.versions-output == '' + - id: get-new-tool-versions + name: Get new tool versions + run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName ${{ matrix.tool.name }})" + - name: Check versions + if: steps.get-new-tool-versions.outputs.versions-output == '' run: Write-Host "No new versions found" - uses: ./.github/actions/send-slack-notification - if: needs.find-new-python-versions.outputs.versions-output != '' + name: Send Slack notification + if: steps.get-new-tool-versions.outputs.versions-output != '' with: url: ${{ secrets.SLACK_CHANNEL_URL }} - tool-name: 'Python' - tool-version: ${{ needs.find-new-python-versions.outputs.versions-output }} - image-url: 'https://www.python.org/static/community_logos/python-powered-h-100x130.png' + tool-name: '${{ matrix.tool.name }}' + tool-version: ${{ steps.get-new-tool-versions.outputs.versions-output }} + image-url: '${{ matrix.tool.image }}' add-to-toolset-flag: '-AddToToolsetFlag' check_build: name: Check build for failures runs-on: ubuntu-latest - needs: [check-new-xamarin-versions, check-new-python-versions] + needs: [find-new-tool-versions] if: failure() steps: - uses: actions/checkout@v2 + - id: get-failed-jobs + name: Get failed jobs + run: | + $jobs_url = "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID/jobs" + $failedJobs = (Invoke-RestMethod -Uri $jobs_url).jobs | + Where-Object conclusion -eq "failure" | + ForEach-Object {"\n\t" + $_.name.split(" ")[-1] + ": $($_.html_url)"} + echo "::set-output name=failed-jobs::$failedJobs" - uses: ./.github/actions/send-slack-notification + name: Send Slack notification about failure with: url: ${{ secrets.SLACK_CHANNEL_URL }} - tool-name: 'Python or Xamarin' + tool-name: 'Tool name' 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:" + text: "Missing toolset tool versions checker pipeline has failed jobs:/n/t${{ steps.get-failed-jobs.outputs.failed-jobs }}" \ No newline at end of file diff --git a/azure-pipelines/get-tool-versions-xamarin.yml b/azure-pipelines/get-tool-versions-xamarin.yml deleted file mode 100644 index 866f810..0000000 --- a/azure-pipelines/get-tool-versions-xamarin.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: $(date:yyyyMMdd)$(rev:.r) -trigger: none -pr: none -schedules: -- cron: "0 8 * * Thu" - displayName: Daily build - branches: - include: - - main - always: true - -variables: - PoolName: 'Azure Pipelines' - VmImage: 'ubuntu-18.04' - -stages: -- stage: Find_New_Versions - dependsOn: [] - jobs: - - job: Find_New_Versions - pool: - name: $(PoolName) - vmImage: $(VmImage) - steps: - - template: /azure-pipelines/templates/get-tool-versions-steps.yml - -- stage: Check_New_Versions - dependsOn: Find_New_Versions - jobs: - - job: Check_New_Versions - pool: - name: $(PoolName) - vmImage: $(VmImage) - variables: - ToolVersions: $[ stageDependencies.Find_New_Versions.Find_New_Versions.outputs['Get_versions.TOOL_VERSIONS'] ] - steps: - - template: /azure-pipelines/templates/check-versions.yml diff --git a/azure-pipelines/templates/check-versions.yml b/azure-pipelines/templates/check-versions.yml index 9af96ef..084c913 100644 --- a/azure-pipelines/templates/check-versions.yml +++ b/azure-pipelines/templates/check-versions.yml @@ -21,7 +21,7 @@ steps: TargetType: inline script: | $ToolName = "$(TOOL_NAME)" - if ($ToolName -in @("Python", "Xamarin")) { + if ($ToolName -eq "Python") { $PipelineUrl = " " } else { $PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)" diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index 558dd0f..e8342ed 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -3,7 +3,7 @@ Check and return list of new available tool versions .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 (Node, Go, Python) #> param ( @@ -16,18 +16,10 @@ $ToolVersionParser = Get-ToolVersionsParser -ToolName $ToolName $VersionsFromDist = $ToolVersionParser.GetAvailableVersions() $VersionsFromManifest = $ToolVersionParser.GetUploadedVersions() -$joinChars = ", " -if ($ToolName -eq "Xamarin") { - $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object {[string]::Empty} { - '{0,-15} : {1}' -f $_.name, $_.version - } - $joinChars = "\n\t" -} else { - $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } -} +$VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } if ($VersionsToBuild) { - $availableVersions = $VersionsToBuild -join $joinChars + $availableVersions = $VersionsToBuild -join ", " Write-Host "The following versions are available to build:`n${availableVersions}" Write-Host "::set-output name=TOOL_VERSIONS::${availableVersions}" Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" diff --git a/get-new-tool-versions/parsers/parsers-factory.psm1 b/get-new-tool-versions/parsers/parsers-factory.psm1 index 199136c..eb9b69c 100644 --- a/get-new-tool-versions/parsers/parsers-factory.psm1 +++ b/get-new-tool-versions/parsers/parsers-factory.psm1 @@ -1,7 +1,6 @@ using module "./node-parser.psm1" using module "./go-parser.psm1" using module "./python-parser.psm1" -using module "./xamarin-parser.psm1" function Get-ToolVersionsParser { param( @@ -13,7 +12,6 @@ function Get-ToolVersionsParser { "Node" { return [NodeVersionsParser]::New() } "Go" { return [GoVersionsParser]::New() } "Python" { return [PythonVersionsParser]::New() } - "Xamarin" { return [XamarinversionsParser]::New() } Default { throw "Unknown tool name" } diff --git a/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 b/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 new file mode 100644 index 0000000..d8c6a55 --- /dev/null +++ b/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 @@ -0,0 +1,21 @@ +function Search-PythonVersionsNotOnImage { + param ( + [string]$ToolName, + [string]$ReleasesUrl, + [string]$FilterParameter, + [string]$FilterArch + ) + + $stableReleases = (Invoke-RestMethod $ReleasesUrl) | + Where-Object stable -eq $true | + ForEach-Object {$_.$FilterParameter.split(".")[0,1] -join"."} | + Select-Object -Unique + $toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2022.json" + $latestVersion = ((Invoke-RestMethod $toolsetUrl).toolcache | + Where-Object {$_.name -eq $ToolName -and $_.arch -eq $FilterArch}).versions | + Select-Object -Last 1 + $latestMinorVesion = $latestVersion.TrimEnd(".*") + $versionsToAdd = $stableReleases | Where-Object {[version]$_ -gt [version]$latestMinorVesion} + + return $versionsToAdd +} \ No newline at end of file diff --git a/get-new-tool-versions/parsers/verify-added-to-image/verify-xamarin-parser.psm1 b/get-new-tool-versions/parsers/verify-added-to-image/verify-xamarin-parser.psm1 new file mode 100644 index 0000000..4999217 --- /dev/null +++ b/get-new-tool-versions/parsers/verify-added-to-image/verify-xamarin-parser.psm1 @@ -0,0 +1,19 @@ +function Search-XamarinVersionsNotOnImage { + param ( + [string]$ReleasesUrl, + [array]$FilterProducts + ) + + $xamarinReleases = (Invoke-RestMethod $ReleasesUrl).items + $filteredReleases = $xamarinReleases | Where-Object {$_.name -in $FilterProducts.name} | Sort-Object name | Select-Object name, version + $toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/macos/toolsets/toolset-11.json" + $uploadedReleases = (Invoke-RestMethod $toolsetUrl).xamarin + $releasesOnImage = @() + foreach ($FilterProduct in $FilterProducts) { + $releasesOnImage += @{$FilterProduct.name = $uploadedReleases.($FilterProduct.property)} + } + $versionsToAdd = $filteredReleases | Where-Object {$releasesOnImage.($_.name) -notcontains $_.version} | ForEach-Object {[string]::Empty} { + '{0,-15} : {1}' -f $_.name, $_.version + } + return $versionsToAdd +} \ No newline at end of file diff --git a/get-new-tool-versions/parsers/xamarin-parser.psm1 b/get-new-tool-versions/parsers/xamarin-parser.psm1 deleted file mode 100644 index fb5c135..0000000 --- a/get-new-tool-versions/parsers/xamarin-parser.psm1 +++ /dev/null @@ -1,30 +0,0 @@ -using module "./base-parser.psm1" - -class XamarinVersionsParser: BaseVersionsParser { - [PSCustomObject] GetAvailableVersions() { - $allVersions = $this.ParseAllAvailableVersions() - return $allVersions - } - - [hashtable] GetUploadedVersions() { - $url = $this.BuildGitHubFileUrl("actions", "virtual-environments", "main", "images/macos/toolsets/toolset-11.json") - $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds - $xamarin = $releases.xamarin - $xamarinReleases = @{ - 'Mono Framework' = $xamarin.'mono-versions' - 'Xamarin.Android' = $xamarin.'android-versions' - 'Xamarin.iOS' = $xamarin.'ios-versions' - 'Xamarin.Mac' = $xamarin.'mac-versions' - } - return $xamarinReleases - } - - hidden [PSCustomObject] ParseAllAvailableVersions() { - $url = "http://aka.ms/manifest/stable" - $filteredProducts = @('Mono Framework', 'Xamarin.Android', 'Xamarin.iOS', 'Xamarin.Mac') - $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds - $items = $releases.items - $products = $items | Where-Object {$_.name -in $filteredProducts} | Sort-Object name | Select-Object name, version - return $products - } -} \ No newline at end of file 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 da09401..c4b088c 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 @@ -3,46 +3,39 @@ 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 (Python, Xamarin) +Required parameter. The name of tool for which parser is available (Python, Xamarin, PyPy) #> param ( [Parameter(Mandatory)] - [ValidateSet("Python", "Xamarin")] + [ValidateSet("Python", "Xamarin", "PyPy")] [string]$ToolName ) +Get-ChildItem "$PSScriptRoot/parsers/verify-added-to-image/" | ForEach-Object {Import-Module $_.FullName} + if ($ToolName -eq "Python") { $pythonVesionsManifestUrl = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" - $builtStableMinorVersions = (Invoke-RestMethod $pythonVesionsManifestUrl) | - Where-Object stable -eq $true | - ForEach-Object {$_.version.split(".")[0,1] -join"."} | - Select-Object -Unique - $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 - $versionsToAdd = $builtStableMinorVersions | Where-Object {[version]$_ -gt [version]$latestExistingMinorVesion} + $versionsToAdd = Search-PythonVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $pythonVesionsManifestUrl -FilterParameter "version" -FilterArch "x64" +} + +if ($ToolName -eq "PyPy") { + $pypyReleases = "https://downloads.python.org/pypy/versions.json" + $versionsToAdd = Search-PythonVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $pypyReleases -FilterParameter "python_version" -FilterArch "x86" } 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 - $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' - 'Xamarin.iOS' = $uploadedReleases.'ios-versions' - 'Xamarin.Mac' = $uploadedReleases.'mac-versions' - } - $versionsToAdd = $filteredReleases | Where-Object {$releasesOnImage[$_.name] -notcontains $_.version } | ForEach-Object {[string]::Empty} { - '{0,-15} : {1}' -f $_.name, $_.version - } + $xamarinReleases = "http://aka.ms/manifest/stable" + $xamarinProducts = @( + [PSCustomObject] @{name = 'Mono Framework'; property = 'mono-versions'} + [PSCustomObject] @{name = 'Xamarin.Android'; property = 'android-versions'} + [PSCustomObject] @{name = 'Xamarin.iOS'; property = 'ios-versions'} + [PSCustomObject] @{name = 'Xamarin.Mac'; property = 'mac-versions'} + ) + $versionsToAdd = Search-XamarinVersionsNotOnImage -ReleasesUrl $xamarinReleases -FilterProducts $xamarinProducts $joinChars = "\n\t" } + $versionsToAdd = $versionsToAdd -join $joinChars return $versionsToAdd From 33b79844a603ef2a6f070b30ae91b88f5a20ec76 Mon Sep 17 00:00:00 2001 From: Maksim Shilov <89912354+shilovmaksim@users.noreply.github.com> Date: Fri, 10 Dec 2021 16:44:19 +0300 Subject: [PATCH 31/33] Notifications for Node and Go versions not on image (#44) --- .github/workflows/get-tools-new-versions.yml | 27 ++++++++++++++++++- .../verify-common-tool-parser.psm1 | 25 +++++++++++++++++ .../verify-python-parser.psm1 | 21 --------------- ...verify-new-tool-version-added-to-image.ps1 | 19 ++++++------- 4 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 delete mode 100644 get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 diff --git a/.github/workflows/get-tools-new-versions.yml b/.github/workflows/get-tools-new-versions.yml index ad06994..aeaaf74 100644 --- a/.github/workflows/get-tools-new-versions.yml +++ b/.github/workflows/get-tools-new-versions.yml @@ -16,17 +16,42 @@ jobs: tool: - name: 'Xamarin' image: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' + releases-url: 'null' + filter-parameter: 'null' + filter-arch: 'null' - name: 'Python' image: 'https://avatars.githubusercontent.com/u/1525981?s=200&v=4' + releases-url: 'https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json' + filter-parameter: 'version' + filter-arch: 'x64' - name: 'PyPy' image: 'https://avatars.githubusercontent.com/u/318667?s=200&v=4' + releases-url: 'https://downloads.python.org/pypy/versions.json' + filter-parameter: 'python_version' + filter-arch: 'x86' + - name: 'Node' + image: 'https://avatars.githubusercontent.com/u/9950313?s=200&v=4' + releases-url: 'https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json' + filter-parameter: 'version' + filter-arch: 'x64' + - name: 'Go' + image: 'https://avatars.githubusercontent.com/u/4314092?s=200&v=4' + releases-url: 'https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json' + filter-parameter: 'version' + filter-arch: 'x64' name: 'Searching for new versions of ${{ matrix.tool.name }}' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - id: get-new-tool-versions name: Get new tool versions - run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName ${{ matrix.tool.name }})" + run: | + $versionsOutput = ./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 ` + -ToolName ${{ matrix.tool.name }} ` + -ReleasesUrl ${{ matrix.tool.releases-url }} ` + -FilterParameter ${{ matrix.tool.filter-parameter }} ` + -FilterArch ${{ matrix.tool.filter-arch }} + echo "::set-output name=versions-output::$versionsOutput" - name: Check versions if: steps.get-new-tool-versions.outputs.versions-output == '' run: Write-Host "No new versions found" diff --git a/get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 b/get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 new file mode 100644 index 0000000..3723390 --- /dev/null +++ b/get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 @@ -0,0 +1,25 @@ +function Search-ToolsVersionsNotOnImage { + param ( + [string]$ToolName, + [string]$ReleasesUrl, + [string]$FilterParameter, + [string]$FilterArch + ) + + $stableReleases = (Invoke-RestMethod $ReleasesUrl) | Where-Object stable -eq $true + $stableReleaseVersions = $stableReleases | ForEach-Object { + if ($ToolName -eq "Node") { + $_.$FilterParameter.split(".")[0] + ".0" + } else { + $_.$FilterParameter.split(".")[0,1] -join"." + } + } | Select-Object -Unique + $toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2022.json" + $latestMinorVersion = (Invoke-RestMethod $toolsetUrl).toolcache | + Where-Object {$_.name -eq $ToolName -and $_.arch -eq $FilterArch} | + ForEach-Object {$_.versions.Replace("*","0")} | + Select-Object -Last 1 + $versionsToAdd = $stableReleaseVersions | Where-Object {[version]$_ -gt [version]$latestMinorVersion} + + return $versionsToAdd +} \ No newline at end of file diff --git a/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 b/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 deleted file mode 100644 index d8c6a55..0000000 --- a/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 +++ /dev/null @@ -1,21 +0,0 @@ -function Search-PythonVersionsNotOnImage { - param ( - [string]$ToolName, - [string]$ReleasesUrl, - [string]$FilterParameter, - [string]$FilterArch - ) - - $stableReleases = (Invoke-RestMethod $ReleasesUrl) | - Where-Object stable -eq $true | - ForEach-Object {$_.$FilterParameter.split(".")[0,1] -join"."} | - Select-Object -Unique - $toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2022.json" - $latestVersion = ((Invoke-RestMethod $toolsetUrl).toolcache | - Where-Object {$_.name -eq $ToolName -and $_.arch -eq $FilterArch}).versions | - Select-Object -Last 1 - $latestMinorVesion = $latestVersion.TrimEnd(".*") - $versionsToAdd = $stableReleases | Where-Object {[version]$_ -gt [version]$latestMinorVesion} - - return $versionsToAdd -} \ No newline at end of file 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 c4b088c..664729d 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 @@ -3,25 +3,22 @@ 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 (Python, Xamarin, PyPy) +Required parameter. The name of tool for which parser is available (Python, Xamarin, PyPy, Node, Go) #> param ( [Parameter(Mandatory)] - [ValidateSet("Python", "Xamarin", "PyPy")] - [string]$ToolName + [ValidateSet("Python", "Xamarin", "PyPy", "Node", "Go")] + [string] $ToolName, + [string] $ReleasesUrl, + [string] $FilterParameter, + [string] $FilterArch ) Get-ChildItem "$PSScriptRoot/parsers/verify-added-to-image/" | ForEach-Object {Import-Module $_.FullName} -if ($ToolName -eq "Python") { - $pythonVesionsManifestUrl = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" - $versionsToAdd = Search-PythonVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $pythonVesionsManifestUrl -FilterParameter "version" -FilterArch "x64" -} - -if ($ToolName -eq "PyPy") { - $pypyReleases = "https://downloads.python.org/pypy/versions.json" - $versionsToAdd = Search-PythonVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $pypyReleases -FilterParameter "python_version" -FilterArch "x86" +if ($ToolName -in "Python", "PyPy", "Node", "Go") { + $versionsToAdd = Search-ToolsVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $ReleasesUrl -FilterParameter $FilterParameter -FilterArch $FilterArch } if ($ToolName -eq "Xamarin") { From d6df4dfaedd4583f5e5dc43c40f56117c5fbc731 Mon Sep 17 00:00:00 2001 From: misamoo Date: Thu, 30 Dec 2021 17:20:14 +0100 Subject: [PATCH 32/33] Create blank.yml e --- .github/workflows/blank.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000..30a4bc1 --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,36 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From 57c76f1935b0d5a3831f02658c46834701324313 Mon Sep 17 00:00:00 2001 From: misamoo Date: Thu, 30 Dec 2021 17:24:25 +0100 Subject: [PATCH 33/33] Create azure-webapps-node.yml --- .github/workflows/azure-webapps-node.yml | 74 ++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/azure-webapps-node.yml diff --git a/.github/workflows/azure-webapps-node.yml b/.github/workflows/azure-webapps-node.yml new file mode 100644 index 0000000..723da35 --- /dev/null +++ b/.github/workflows/azure-webapps-node.yml @@ -0,0 +1,74 @@ +# This workflow will build and push a node.js application to an Azure Web App when a commit is pushed to your default branch. +# +# This workflow assumes you have already created the target Azure App Service web app. +# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=linux&pivots=development-environment-cli +# +# To configure this workflow: +# +# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal. +# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials +# +# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. +# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret +# +# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the AZURE_WEBAPP_PACKAGE_PATH and NODE_VERSION environment variables below. +# +# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions +# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples + +on: + push: + branches: + - main + workflow_dispatch: + +env: + AZURE_WEBAPP_NAME: your-app-name # set this to your application's name + AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root + NODE_VERSION: '14.x' # set this to the node version to use + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm run test --if-present + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: node-app + path: . + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Development' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: node-app + + - name: 'Deploy to Azure WebApp' + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}