From c4cf36cb582e078dcaa1237046ab9f2f979309fd Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Mon, 15 Apr 2024 08:54:16 +0200 Subject: [PATCH] Allow PullRequestHandler to use ubuntu-latest (#1030) Fixes #1008 Allow Update AL-Go System Files to update runs-on in PullRequestHandler.yaml, except for PregateCheck. PregateCheck is set to use runs-on: windows-latest which will not be updated. Update AL-Go System Files will update occurances of "runs-on: [ windows-latest ]" with "runs-on: [ (runs-on setting) ]" Co-authored-by: freddydk --- .../CheckForUpdates.HelperFunctions.ps1 | 2 +- RELEASENOTES.md | 1 + .../.github/workflows/PullRequestHandler.yaml | 2 +- .../.github/workflows/PullRequestHandler.yaml | 2 +- .../WorkflowSanitation/WorkflowFileContent.Test.ps1 | 12 ++++++++++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 b/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 index a9812b070..fe3d8eeff 100644 --- a/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 +++ b/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 @@ -244,7 +244,7 @@ function GetWorkflowContentWithChangesFromSettings { ModifyPullRequestHandlerWorkflow -yaml $yaml -repoSettings $repoSettings } - if ($baseName -ne "UpdateGitHubGoSystemFiles" -and $baseName -ne "PullRequestHandler" -and $baseName -ne 'Troubleshooting') { + if ($baseName -ne "UpdateGitHubGoSystemFiles" -and $baseName -ne 'Troubleshooting') { ModifyRunsOnAndShell -yaml $yaml -repoSettings $repoSettings } diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9e68b7d91..5581878ec 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -13,6 +13,7 @@ Note that when using the preview version of AL-Go for GitHub, we recommend you U - Issue 997 'Deliver to AppSource' action fails for projects containing a space - Issue 987 Resource not accessible by integration when creating release from specific version - Issue 979 Publish to AppSource Documentation +- Issue 1008 Allow PullRequestHandler to use ubuntu or self hosted runners for all jobs except for pregateCheck ### New Settings - `deliverToAppSource`: a JSON object containing the following properties diff --git a/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml b/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml index abe6f5bcb..56ab98022 100644 --- a/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml +++ b/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml @@ -25,7 +25,7 @@ env: jobs: PregateCheck: if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request') - runs-on: [ windows-latest ] + runs-on: windows-latest steps: - uses: microsoft/AL-Go-Actions/VerifyPRChanges@main diff --git a/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml b/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml index abe6f5bcb..56ab98022 100644 --- a/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml +++ b/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml @@ -25,7 +25,7 @@ env: jobs: PregateCheck: if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request') - runs-on: [ windows-latest ] + runs-on: windows-latest steps: - uses: microsoft/AL-Go-Actions/VerifyPRChanges@main diff --git a/Tests/WorkflowSanitation/WorkflowFileContent.Test.ps1 b/Tests/WorkflowSanitation/WorkflowFileContent.Test.ps1 index 9a90d4d55..6e4e238f5 100644 --- a/Tests/WorkflowSanitation/WorkflowFileContent.Test.ps1 +++ b/Tests/WorkflowSanitation/WorkflowFileContent.Test.ps1 @@ -13,3 +13,15 @@ Describe "All AL-GO workflows should have similar content" { } } } + +Describe "PreGateCheck in PullRequestHandler should use runs-on: windows-latest" { + It 'Check PullRequestHandler.yaml for runs-on: windows-latest' { + # Check that PullRequestHandler.yaml in both templates uses runs-on: windows-latest, which doesn't get updated by the Update AL-Go System Files action + $ScriptRoot = $PSScriptRoot + . (Join-Path $ScriptRoot "../../Actions/CheckForUpdates/yamlclass.ps1") + foreach($template in @('Per Tenant Extension','AppSource App')) { + $yaml = [Yaml]::load((Join-Path $ScriptRoot "..\..\Templates\$template\.github\workflows\PullRequestHandler.yaml" -Resolve)) + $yaml.Get('jobs:/PregateCheck:/runs-on').content | Should -Be 'runs-on: windows-latest' -Because "PreGateCheck in $template/PullRequestHandler.yaml should use runs-on: windows-latest" + } + } +}