From 4ac39b8e6cdf922fe41bb0845c559ae51370f474 Mon Sep 17 00:00:00 2001 From: Josh King Date: Fri, 22 Mar 2024 10:35:45 +1300 Subject: [PATCH 1/3] (ENGTASKS-3098) Create TC build for Unit, Integration, and QA --- .teamcity/settings.kts | 152 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 142 insertions(+), 10 deletions(-) diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index c734b6517..f7055bac8 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -3,16 +3,19 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.powerShell import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.pullRequests import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs +import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.ScheduleTrigger import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot project { buildType(ChocolateyGUI) + buildType(ChocolateyGUISchd) + buildType(ChocolateyGUIQA) } object ChocolateyGUI : BuildType({ id = AbsoluteId("ChocolateyGUI") - name = "Build" + name = "Chocolatey GUI (Built with Unit Tests)" artifactRules = """ code_drop/MsBuild.log @@ -62,8 +65,7 @@ object ChocolateyGUI : BuildType({ script { name = "Call Cake" scriptContent = """ - IF "%teamcity.build.triggeredBy%" == "Schedule Trigger" (SET TestType=all) ELSE (SET TestType=unit) - call build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=%%TestType%% --shouldRunOpenCover=false + build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=unit --shouldRunOpenCover=false """.trimIndent() } } @@ -72,6 +74,77 @@ object ChocolateyGUI : BuildType({ vcs { branchFilter = "" } + } + + features { + pullRequests { + provider = github { + authType = token { + token = "%system.GitHubPAT%" + } + } + } + } +}) + +object ChocolateyGUISchd : BuildType({ + id = AbsoluteId("ChocolateyGUISchd") + name = "Chocolatey GUI (Scheduled Integration Testing)" + + artifactRules = """ + code_drop/MsBuild.log + code_drop/MSBuild.msi.log + code_drop/ChocolateyGUI.msi + code_drop/TestResults/issues-report.html + code_drop/Packages/**/*.nupkg + """.trimIndent() + + params { + param("env.vcsroot.branch", "%vcsroot.branch%") + param("env.Git_Branch", "%teamcity.build.vcs.branch.ChocolateyGUI_ChocolateyGuiVcsRoot%") + param("teamcity.git.fetchAllHeads", "true") + password("env.TRANSIFEX_API_TOKEN", "credentialsJSON:c81283e6-cf59-5c9e-9766-6f465018a295", display = ParameterDisplay.HIDDEN, readOnly = true) + password("env.GITHUB_PAT", "%system.GitHubPAT%", display = ParameterDisplay.HIDDEN, readOnly = true) + } + + vcs { + root(DslContext.settingsRoot) + + branchFilter = """ + +:* + """.trimIndent() + } + + steps { + powerShell { + name = "Prerequisites" + scriptMode = script { + content = """ + # Install Chocolatey Requirements + if ((Get-WindowsFeature -Name NET-Framework-Features).InstallState -ne 'Installed') { + Install-WindowsFeature -Name NET-Framework-Features + } + + choco install windows-sdk-7.1 netfx-4.0.3-devpack visualstudio2019buildtools netfx-4.8-devpack --confirm --no-progress + exit ${'$'}LastExitCode + """.trimIndent() + } + } + + step { + name = "Include Signing Keys" + type = "PrepareSigningEnvironment" + } + + script { + name = "Call Cake" + scriptContent = """ + build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=all --shouldRunOpenCover=false --shouldRunAnalyze=false --shouldRunIlMerge=false --shouldObfuscateOutputAssemblies=false --shouldRunChocolatey=false --shouldRunNuGet=false + """.trimIndent() + } + } + + triggers { schedule { schedulingPolicy = daily { hour = 2 @@ -81,17 +154,76 @@ object ChocolateyGUI : BuildType({ +: """.trimIndent() triggerBuild = always() - withPendingChangesOnly = false + withPendingChangesOnly = false } } +}) - features { - pullRequests { - provider = github { - authType = token { - token = "%system.GitHubPAT%" - } +object ChocolateyGUIQA : BuildType({ + id = AbsoluteId("ChocolateyGUIQA") + name = "Chocolatey GUI (SonarQube)" + + artifactRules = """ + """.trimIndent() + + params { + param("env.vcsroot.branch", "%vcsroot.branch%") + param("env.Git_Branch", "%teamcity.build.vcs.branch.ChocolateyGUI_ChocolateyGuiVcsRoot%") + param("env.SONARQUBE_ID", "chocolateygui") + param("teamcity.git.fetchAllHeads", "true") + password("env.TRANSIFEX_API_TOKEN", "credentialsJSON:c81283e6-cf59-5c9e-9766-6f465018a295", display = ParameterDisplay.HIDDEN, readOnly = true) + password("env.GITHUB_PAT", "%system.GitHubPAT%", display = ParameterDisplay.HIDDEN, readOnly = true) + } + + vcs { + root(DslContext.settingsRoot) + + branchFilter = """ + +:* + """.trimIndent() + } + + steps { + powerShell { + name = "Prerequisites" + scriptMode = script { + content = """ + # Install Chocolatey Requirements + if ((Get-WindowsFeature -Name NET-Framework-Features).InstallState -ne 'Installed') { + Install-WindowsFeature -Name NET-Framework-Features + } + + choco install windows-sdk-7.1 netfx-4.0.3-devpack visualstudio2019buildtools netfx-4.8-devpack --confirm --no-progress + exit ${'$'}LastExitCode + """.trimIndent() } } + + step { + name = "Include Signing Keys" + type = "PrepareSigningEnvironment" + } + + script { + name = "Call Cake" + scriptContent = """ + build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=none --shouldRunAnalyze=false --shouldRunIlMerge=false --shouldObfuscateOutputAssemblies=false --shouldRunChocolatey=false --shouldRunNuGet=false --shouldRunSonarQube=true --shouldRunDependencyCheck=true + """.trimIndent() + } + } + + triggers { + schedule { + schedulingPolicy = weekly { + dayOfWeek = ScheduleTrigger.DAY.Saturday + hour = 2 + minute = 45 + } + branchFilter = """ + +: + """.trimIndent() + triggerBuild = always() + withPendingChangesOnly = false + } } }) \ No newline at end of file From 85c45ba4d66345a182644830cc0d384a6b4c4fb5 Mon Sep 17 00:00:00 2001 From: Josh King Date: Fri, 22 Mar 2024 10:36:04 +1300 Subject: [PATCH 2/3] (build) Bump chocolatey.cake.recipe version to latest Also change gitHubTokenVariable to gitReleaseManagerTokenVariable to reflect change in chocolatey.cake.recipe --- recipe.cake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipe.cake b/recipe.cake index e37c0726b..988ee2f55 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Chocolatey.Cake.Recipe&version=0.25.0 +#load nuget:?package=Chocolatey.Cake.Recipe&version=0.26.3 /////////////////////////////////////////////////////////////////////////////// // MODULES @@ -13,7 +13,7 @@ if (BuildSystem.IsLocalBuild) { Environment.SetVariableNames( - gitHubTokenVariable: "CHOCOLATEYGUI_GITHUB_PAT", + gitReleaseManagerTokenVariable: "CHOCOLATEYGUI_GITHUB_PAT", transifexApiTokenVariable: "CHOCOLATEYGUI_TRANSIFEX_API_TOKEN" ); } From 037cb65358b4f64c8f6afacfea2fd2d2736e8dde Mon Sep 17 00:00:00 2001 From: Josh King Date: Wed, 3 Apr 2024 11:23:16 +1300 Subject: [PATCH 3/3] (build) Specify GHA shell as Windows PowerShell --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a04018c31..2f700f481 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,7 @@ jobs: key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }} - name: Build project + shell: powershell run: | ./build.ps1 --target=CI