From 93d957551b3095f1360d5e4bf27e36453d483123 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Thu, 19 Sep 2024 16:11:46 -0500 Subject: [PATCH] port precheck, clean it up --- .../ci/templates/build-powertoys-precheck.yml | 38 ------------------- .pipelines/v2/ci.yml | 4 +- .pipelines/v2/templates/job-ci-precheck.yml | 30 +++++++++++++++ 3 files changed, 32 insertions(+), 40 deletions(-) delete mode 100644 .pipelines/ci/templates/build-powertoys-precheck.yml create mode 100644 .pipelines/v2/templates/job-ci-precheck.yml diff --git a/.pipelines/ci/templates/build-powertoys-precheck.yml b/.pipelines/ci/templates/build-powertoys-precheck.yml deleted file mode 100644 index 760128965222..000000000000 --- a/.pipelines/ci/templates/build-powertoys-precheck.yml +++ /dev/null @@ -1,38 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json -jobs: -- job: Precheck - pool: - demands: ImageOverride -equals SHINE-VS17-Latest - ${{ if eq(variables['System.CollectionId'], 'cb55739e-4afe-46a3-970f-1b49d8ee7564') }}: - name: SHINE-INT-L - ${{ else }}: - name: SHINE-OSS-L - steps: - - checkout: none - - - task: PowerShell@2 - displayName: Verify Build Request - inputs: - targetType: 'inline' - script: | - try { - # Try based on pull request first - $pullRequestNumber = "$(system.pullRequest.pullRequestNumber)"; - $gitHubPullRequest = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/pulls/$pullRequestNumber/files" - # If there are no files updated in the commit that are .md, set skipBuild variable - if(([array]($gitHubPullRequest.filename) -notmatch ".md|.txt").Length -eq 0) { - Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes' - Write-Host 'Skipping Build' - } - } - catch { - # Fall back to the latest commit otherwise. - $commit = "$(build.sourceVersion)"; - $gitHubCommit = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/commits/$commit" - if(([array]($githubCommit.files.filename) -notmatch ".md|.txt").Length -eq 0) { - Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes' - Write-Host 'Skipping Build' - } - } - pwsh: true - name: verifyBuildRequest diff --git a/.pipelines/v2/ci.yml b/.pipelines/v2/ci.yml index 0e2aee14587d..1f1af9a964f1 100644 --- a/.pipelines/v2/ci.yml +++ b/.pipelines/v2/ci.yml @@ -39,7 +39,7 @@ parameters: stages: - stage: Precheck jobs: - - template: /.pipelines/ci/templates/build-powertoys-precheck.yml@self + - template: ./templates/job-ci-precheck.yml - ${{ each platform in parameters.buildPlatforms }}: @@ -49,7 +49,7 @@ stages: jobs: - template: ./templates/job-build-project.yml parameters: - condition: and(succeeded(),ne(stageDependencies.Precheck.Precheck.outputs['verifyBuildRequest.skipBuild'], 'Yes')) + condition: and(succeeded(), ne(stageDependencies.Precheck.Precheck.outputs['verifyBuildRequest.skipBuild'], 'Yes')) pool: ${{ if eq(variables['System.CollectionId'], 'cb55739e-4afe-46a3-970f-1b49d8ee7564') }}: name: SHINE-INT-L diff --git a/.pipelines/v2/templates/job-ci-precheck.yml b/.pipelines/v2/templates/job-ci-precheck.yml new file mode 100644 index 000000000000..6d3616ff69e5 --- /dev/null +++ b/.pipelines/v2/templates/job-ci-precheck.yml @@ -0,0 +1,30 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json +jobs: +- job: Precheck + pool: + vmImage: windows-2022 + steps: + - checkout: none + + - pwsh: |- + try { + # Try based on pull request first + $pullRequestNumber = "$(system.pullRequest.pullRequestNumber)"; + $gitHubPullRequest = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/pulls/$pullRequestNumber/files" + # If there are no files updated in the commit that are .md, set skipBuild variable + if(([array]($gitHubPullRequest.filename) -notmatch ".md|.txt").Length -eq 0) { + Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes' + Write-Host 'Skipping Build' + } + } + catch { + # Fall back to the latest commit otherwise. + $commit = "$(build.sourceVersion)"; + $gitHubCommit = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/commits/$commit" + if(([array]($githubCommit.files.filename) -notmatch ".md|.txt").Length -eq 0) { + Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes' + Write-Host 'Skipping Build' + } + } + displayName: Verify whether we need to build at all + name: verifyBuildRequest