From ae808160ad3af9097d074572d21ba6f8b2d3102a Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 17 May 2024 02:06:30 -0700 Subject: [PATCH] (#154) Verify PowerShell scripts on develop branch In the previous release, a change was made to try to control "when" the verification of PowerShell scripts would be completed. This change neglected to allow running of this task on the develop branch, and instead only ran on "releaseable" branches, namely master, hotfix and release. To allow catching of PowerShell scripts that haven't been signed, we need to run the verification task on all "main" branches, i.e. master, develop, release, hotfix and support. In other words, any branches that a PR can be merged into. This commit fixes the criteria for this to be in place, and also adds the concept of Support branches to the BranchType enumeration, which wasn't included previously. --- Chocolatey.Cake.Recipe/Content/parameters.cake | 7 ++++++- Chocolatey.Cake.Recipe/Content/sign.cake | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Chocolatey.Cake.Recipe/Content/parameters.cake b/Chocolatey.Cake.Recipe/Content/parameters.cake index 3a77a68..98c4bdc 100644 --- a/Chocolatey.Cake.Recipe/Content/parameters.cake +++ b/Chocolatey.Cake.Recipe/Content/parameters.cake @@ -19,7 +19,8 @@ public enum BranchType HotFix, Release, Develop, - Master + Master, + Support } public static class BuildParameters @@ -870,6 +871,10 @@ public static class BuildParameters { BranchType = BranchType.HotFix; } + else if (branchName != null && branchName.StartsWith("support", StringComparison.OrdinalIgnoreCase)) + { + BranchType = BranchType.Support; + } else { BranchType = BranchType.Unknown; diff --git a/Chocolatey.Cake.Recipe/Content/sign.cake b/Chocolatey.Cake.Recipe/Content/sign.cake index ab7914d..c89fea8 100644 --- a/Chocolatey.Cake.Recipe/Content/sign.cake +++ b/Chocolatey.Cake.Recipe/Content/sign.cake @@ -16,7 +16,7 @@ BuildParameters.Tasks.VerifyPowerShellScriptsTask = Task("Verify-PowerShellScripts") .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping due to not running on Windows") .WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because current build is from a Pull Request") - .WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix, "Skipping because this is not a releasable branch") + .WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix || BuildParameters.BranchType == BranchType.Support || BuildParameters.BranchType == BranchType.Develop, "Skipping because this is not a 'main' branch, i.e. master, develop, release, hotfix, or support, where scripts need to be verified.") .WithCriteria(() => BuildParameters.ShouldVerifyPowerShellScripts, "Skipping since verifying PowerShell scripts has been disabled") .Does(() => {