From f0fc0c60eb2e6437d366108b0fbc494e5effbcd4 Mon Sep 17 00:00:00 2001 From: ryfu-msft Date: Wed, 14 Feb 2024 10:52:24 -0800 Subject: [PATCH 1/4] only run sdl pipeline on non PRs --- pipelines/azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/pipelines/azure-pipelines.yml b/pipelines/azure-pipelines.yml index 159fab31..4395a8bb 100644 --- a/pipelines/azure-pipelines.yml +++ b/pipelines/azure-pipelines.yml @@ -45,6 +45,7 @@ resources: extends: template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + condition: not(eq(variables['Build.Reason'], 'PullRequest')) parameters: pool: name: Azure-Pipelines-1ESPT-ExDShared From 1ae1120bb4ddf1af64ba786eedc6ce02b6d8f4ec Mon Sep 17 00:00:00 2001 From: ryfu-msft Date: Wed, 14 Feb 2024 12:54:53 -0800 Subject: [PATCH 2/4] try this --- pipelines/azure-pipelines.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pipelines/azure-pipelines.yml b/pipelines/azure-pipelines.yml index 4395a8bb..acb48efc 100644 --- a/pipelines/azure-pipelines.yml +++ b/pipelines/azure-pipelines.yml @@ -43,20 +43,8 @@ resources: name: 1ESPipelineTemplates/1ESPipelineTemplates ref: refs/tags/release -extends: - template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates - condition: not(eq(variables['Build.Reason'], 'PullRequest')) - parameters: - pool: - name: Azure-Pipelines-1ESPT-ExDShared - image: windows-2022 - os: windows - customBuildTags: - - ES365AIMigrationTooling - stages: - stage: GetVersion_Build - jobs: - job: GetVersion variables: @@ -87,6 +75,16 @@ extends: version: "$(majorMinorVersion).$(buildVersion).0" appxBundlePath: '$(wingetCreatePackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle' + extends: + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + parameters: + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-2022 + os: windows + customBuildTags: + - ES365AIMigrationTooling + steps: - checkout: self lfs: "true" From 6cfa809941d74c41a747cda6d0c9ea3c5aec66d6 Mon Sep 17 00:00:00 2001 From: ryfu-msft Date: Wed, 14 Feb 2024 13:00:32 -0800 Subject: [PATCH 3/4] fix alignment --- pipelines/azure-pipelines.yml | 252 +++++++++++++++++----------------- 1 file changed, 126 insertions(+), 126 deletions(-) diff --git a/pipelines/azure-pipelines.yml b/pipelines/azure-pipelines.yml index acb48efc..373bf7f7 100644 --- a/pipelines/azure-pipelines.yml +++ b/pipelines/azure-pipelines.yml @@ -43,129 +43,129 @@ resources: name: 1ESPipelineTemplates/1ESPipelineTemplates ref: refs/tags/release - stages: - - stage: GetVersion_Build - jobs: - - job: GetVersion - variables: - runCodesignValidationInjection: ${{ false }} - skipComponentGovernanceDetection: ${{ true }} - steps: - - task: PowerShell@2 - name: GetVersionStep - displayName: Get version from CLI project - inputs: - targetType: "inline" - script: | - [xml]$project = get-content "$(workingDirectory)/WingetCreateCLI/WingetCreateCLI.csproj" - $version = $project.Project.PropertyGroup.Version - echo "##vso[task.setvariable variable=majorMinorVersion;isOutput=true]$version" - - - job: Build - displayName: Build - dependsOn: GetVersion - variables: - majorMinorVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorVersion']] - # Only update counter for non-PR builds, otherwise just use 0 for the revision - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - buildVersion: 0 - ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}: - buildVersion: $[counter(variables['majorMinorVersion'], 1)] - - version: "$(majorMinorVersion).$(buildVersion).0" - appxBundlePath: '$(wingetCreatePackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle' - - extends: - template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates - parameters: - pool: - name: Azure-Pipelines-1ESPT-ExDShared - image: windows-2022 - os: windows - customBuildTags: - - ES365AIMigrationTooling - - steps: - - checkout: self - lfs: "true" - - - task: PowerShell@2 - displayName: Display version and bundle path for diagnosing - inputs: - targetType: inline - script: | - echo $(version) - echo $(appxBundlePath) - - - task: PowerShell@2 - displayName: "Update package manifest version" - inputs: - targetType: inline - script: | - [xml]$manifest = get-content "$(workingDirectory)/WingetCreatePackage/Package.appxmanifest" - $manifest.Package.Identity.Version = "$(version)" - $manifest.save("$(workingDirectory)/WingetCreatePackage/Package.appxmanifest") - - - task: DotNetCoreCLI@2 - displayName: Restore - inputs: - command: "restore" - feedsToUse: "config" - nugetConfigPath: "NuGet.config" - projects: $(workingDirectory)/**/*.csproj - - - task: MSBuild@1 - displayName: Build Solution - inputs: - platform: "$(buildPlatform)" - solution: "$(solution)" - configuration: "$(buildConfiguration)" - msbuildArguments: '/p:AppxBundleOutput="$(appxBundlePath)" - /p:AppxBundle=Always - /p:UapAppxPackageBuildMode=SideloadOnly - /p:AppxPackageSigningEnabled=false' - - - task: 1ES.PublishPipelineArtifact@1 - inputs: - targetPath: $(wingetCreatePackageDir) - artifactName: wingetcreate_msixbundle - displayName: Publish WingetCreate msix bundle - - - task: ComponentGovernanceComponentDetection@0 - displayName: Component Governance - inputs: - scanType: "Register" - verbosity: "Verbose" - alertWarningLevel: "High" - - - task: notice@0 - displayName: "NOTICE File Generator" - condition: not(eq(variables['Build.Reason'], 'PullRequest')) - inputs: - outputfile: "$(System.DefaultWorkingDirectory)/temp/NOTICE.txt" - outputformat: "text" - - - bash: | - echo "Diffing existing NOTICE.txt with generated version" - diff -w NOTICE.txt temp/NOTICE.txt - if [[ $? -ne 0 ]]; - then - echo "Notice file modified" - echo "*******************************************************************************************************" - echo "Download the updated NOTICE.txt from the build artifacts and update the file in your PR, then re-submit" - echo "*******************************************************************************************************" - exit 1 - else - echo "Notice file not modified." - fi - displayName: "Trigger build warning if NOTICE.txt file needs to be modified." - condition: not(eq(variables['Build.Reason'], 'PullRequest')) - continueOnError: "true" - - - task: VSTest@2 - displayName: Run Tests - inputs: - testSelector: "testAssemblies" - testAssemblyVer2: 'src\WingetCreateTests\WingetCreateTests\bin\$(buildPlatform)\$(buildConfiguration)\$(targetFramework)\WingetCreateTests.dll' - runSettingsFile: 'src\WingetCreateTests\WingetCreateTests\Test.runsettings' - overrideTestrunParameters: '-WingetPkgsTestRepoOwner microsoft -WingetPkgsTestRepo winget-pkgs-submission-test -GitHubAppPrivateKey "$(GitHubApp_PrivateKey)"' \ No newline at end of file +stages: + - stage: GetVersion_Build + jobs: + - job: GetVersion + variables: + runCodesignValidationInjection: ${{ false }} + skipComponentGovernanceDetection: ${{ true }} + steps: + - task: PowerShell@2 + name: GetVersionStep + displayName: Get version from CLI project + inputs: + targetType: "inline" + script: | + [xml]$project = get-content "$(workingDirectory)/WingetCreateCLI/WingetCreateCLI.csproj" + $version = $project.Project.PropertyGroup.Version + echo "##vso[task.setvariable variable=majorMinorVersion;isOutput=true]$version" + + - job: Build + displayName: Build + dependsOn: GetVersion + variables: + majorMinorVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorVersion']] + # Only update counter for non-PR builds, otherwise just use 0 for the revision + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + buildVersion: 0 + ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}: + buildVersion: $[counter(variables['majorMinorVersion'], 1)] + + version: "$(majorMinorVersion).$(buildVersion).0" + appxBundlePath: '$(wingetCreatePackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle' + + extends: + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + parameters: + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-2022 + os: windows + customBuildTags: + - ES365AIMigrationTooling + + steps: + - checkout: self + lfs: "true" + + - task: PowerShell@2 + displayName: Display version and bundle path for diagnosing + inputs: + targetType: inline + script: | + echo $(version) + echo $(appxBundlePath) + + - task: PowerShell@2 + displayName: "Update package manifest version" + inputs: + targetType: inline + script: | + [xml]$manifest = get-content "$(workingDirectory)/WingetCreatePackage/Package.appxmanifest" + $manifest.Package.Identity.Version = "$(version)" + $manifest.save("$(workingDirectory)/WingetCreatePackage/Package.appxmanifest") + + - task: DotNetCoreCLI@2 + displayName: Restore + inputs: + command: "restore" + feedsToUse: "config" + nugetConfigPath: "NuGet.config" + projects: $(workingDirectory)/**/*.csproj + + - task: MSBuild@1 + displayName: Build Solution + inputs: + platform: "$(buildPlatform)" + solution: "$(solution)" + configuration: "$(buildConfiguration)" + msbuildArguments: '/p:AppxBundleOutput="$(appxBundlePath)" + /p:AppxBundle=Always + /p:UapAppxPackageBuildMode=SideloadOnly + /p:AppxPackageSigningEnabled=false' + + - task: 1ES.PublishPipelineArtifact@1 + inputs: + targetPath: $(wingetCreatePackageDir) + artifactName: wingetcreate_msixbundle + displayName: Publish WingetCreate msix bundle + + - task: ComponentGovernanceComponentDetection@0 + displayName: Component Governance + inputs: + scanType: "Register" + verbosity: "Verbose" + alertWarningLevel: "High" + + - task: notice@0 + displayName: "NOTICE File Generator" + condition: not(eq(variables['Build.Reason'], 'PullRequest')) + inputs: + outputfile: "$(System.DefaultWorkingDirectory)/temp/NOTICE.txt" + outputformat: "text" + + - bash: | + echo "Diffing existing NOTICE.txt with generated version" + diff -w NOTICE.txt temp/NOTICE.txt + if [[ $? -ne 0 ]]; + then + echo "Notice file modified" + echo "*******************************************************************************************************" + echo "Download the updated NOTICE.txt from the build artifacts and update the file in your PR, then re-submit" + echo "*******************************************************************************************************" + exit 1 + else + echo "Notice file not modified." + fi + displayName: "Trigger build warning if NOTICE.txt file needs to be modified." + condition: not(eq(variables['Build.Reason'], 'PullRequest')) + continueOnError: "true" + + - task: VSTest@2 + displayName: Run Tests + inputs: + testSelector: "testAssemblies" + testAssemblyVer2: 'src\WingetCreateTests\WingetCreateTests\bin\$(buildPlatform)\$(buildConfiguration)\$(targetFramework)\WingetCreateTests.dll' + runSettingsFile: 'src\WingetCreateTests\WingetCreateTests\Test.runsettings' + overrideTestrunParameters: '-WingetPkgsTestRepoOwner microsoft -WingetPkgsTestRepo winget-pkgs-submission-test -GitHubAppPrivateKey "$(GitHubApp_PrivateKey)"' \ No newline at end of file From ecef67bebc6db56374e37619939de46f76fbc7af Mon Sep 17 00:00:00 2001 From: ryfu-msft Date: Wed, 14 Feb 2024 13:24:13 -0800 Subject: [PATCH 4/4] add skip step --- pipelines/azure-pipelines.yml | 255 +++++++++++++++++----------------- 1 file changed, 129 insertions(+), 126 deletions(-) diff --git a/pipelines/azure-pipelines.yml b/pipelines/azure-pipelines.yml index 373bf7f7..6c441611 100644 --- a/pipelines/azure-pipelines.yml +++ b/pipelines/azure-pipelines.yml @@ -43,129 +43,132 @@ resources: name: 1ESPipelineTemplates/1ESPipelineTemplates ref: refs/tags/release -stages: - - stage: GetVersion_Build - jobs: - - job: GetVersion - variables: - runCodesignValidationInjection: ${{ false }} - skipComponentGovernanceDetection: ${{ true }} - steps: - - task: PowerShell@2 - name: GetVersionStep - displayName: Get version from CLI project - inputs: - targetType: "inline" - script: | - [xml]$project = get-content "$(workingDirectory)/WingetCreateCLI/WingetCreateCLI.csproj" - $version = $project.Project.PropertyGroup.Version - echo "##vso[task.setvariable variable=majorMinorVersion;isOutput=true]$version" - - - job: Build - displayName: Build - dependsOn: GetVersion - variables: - majorMinorVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorVersion']] - # Only update counter for non-PR builds, otherwise just use 0 for the revision - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - buildVersion: 0 - ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}: - buildVersion: $[counter(variables['majorMinorVersion'], 1)] - - version: "$(majorMinorVersion).$(buildVersion).0" - appxBundlePath: '$(wingetCreatePackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle' - - extends: - template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates - parameters: - pool: - name: Azure-Pipelines-1ESPT-ExDShared - image: windows-2022 - os: windows - customBuildTags: - - ES365AIMigrationTooling - - steps: - - checkout: self - lfs: "true" - - - task: PowerShell@2 - displayName: Display version and bundle path for diagnosing - inputs: - targetType: inline - script: | - echo $(version) - echo $(appxBundlePath) - - - task: PowerShell@2 - displayName: "Update package manifest version" - inputs: - targetType: inline - script: | - [xml]$manifest = get-content "$(workingDirectory)/WingetCreatePackage/Package.appxmanifest" - $manifest.Package.Identity.Version = "$(version)" - $manifest.save("$(workingDirectory)/WingetCreatePackage/Package.appxmanifest") - - - task: DotNetCoreCLI@2 - displayName: Restore - inputs: - command: "restore" - feedsToUse: "config" - nugetConfigPath: "NuGet.config" - projects: $(workingDirectory)/**/*.csproj - - - task: MSBuild@1 - displayName: Build Solution - inputs: - platform: "$(buildPlatform)" - solution: "$(solution)" - configuration: "$(buildConfiguration)" - msbuildArguments: '/p:AppxBundleOutput="$(appxBundlePath)" - /p:AppxBundle=Always - /p:UapAppxPackageBuildMode=SideloadOnly - /p:AppxPackageSigningEnabled=false' - - - task: 1ES.PublishPipelineArtifact@1 - inputs: - targetPath: $(wingetCreatePackageDir) - artifactName: wingetcreate_msixbundle - displayName: Publish WingetCreate msix bundle - - - task: ComponentGovernanceComponentDetection@0 - displayName: Component Governance - inputs: - scanType: "Register" - verbosity: "Verbose" - alertWarningLevel: "High" - - - task: notice@0 - displayName: "NOTICE File Generator" - condition: not(eq(variables['Build.Reason'], 'PullRequest')) - inputs: - outputfile: "$(System.DefaultWorkingDirectory)/temp/NOTICE.txt" - outputformat: "text" - - - bash: | - echo "Diffing existing NOTICE.txt with generated version" - diff -w NOTICE.txt temp/NOTICE.txt - if [[ $? -ne 0 ]]; - then - echo "Notice file modified" - echo "*******************************************************************************************************" - echo "Download the updated NOTICE.txt from the build artifacts and update the file in your PR, then re-submit" - echo "*******************************************************************************************************" - exit 1 - else - echo "Notice file not modified." - fi - displayName: "Trigger build warning if NOTICE.txt file needs to be modified." - condition: not(eq(variables['Build.Reason'], 'PullRequest')) - continueOnError: "true" - - - task: VSTest@2 - displayName: Run Tests - inputs: - testSelector: "testAssemblies" - testAssemblyVer2: 'src\WingetCreateTests\WingetCreateTests\bin\$(buildPlatform)\$(buildConfiguration)\$(targetFramework)\WingetCreateTests.dll' - runSettingsFile: 'src\WingetCreateTests\WingetCreateTests\Test.runsettings' - overrideTestrunParameters: '-WingetPkgsTestRepoOwner microsoft -WingetPkgsTestRepo winget-pkgs-submission-test -GitHubAppPrivateKey "$(GitHubApp_PrivateKey)"' \ No newline at end of file +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + parameters: + pool: + name: Azure-Pipelines-1ESPT-ExDShared + image: windows-2022 + os: windows + customBuildTags: + - ES365AIMigrationTooling + settings: + skipBuildTagsForGitHubPullRequests: true + + stages: + - stage: GetVersion_Build + + jobs: + - job: GetVersion + variables: + runCodesignValidationInjection: ${{ false }} + skipComponentGovernanceDetection: ${{ true }} + steps: + - task: PowerShell@2 + name: GetVersionStep + displayName: Get version from CLI project + inputs: + targetType: "inline" + script: | + [xml]$project = get-content "$(workingDirectory)/WingetCreateCLI/WingetCreateCLI.csproj" + $version = $project.Project.PropertyGroup.Version + echo "##vso[task.setvariable variable=majorMinorVersion;isOutput=true]$version" + + - job: Build + displayName: Build + dependsOn: GetVersion + variables: + majorMinorVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorVersion']] + # Only update counter for non-PR builds, otherwise just use 0 for the revision + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + buildVersion: 0 + ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}: + buildVersion: $[counter(variables['majorMinorVersion'], 1)] + + version: "$(majorMinorVersion).$(buildVersion).0" + appxBundlePath: '$(wingetCreatePackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle' + + steps: + - checkout: self + lfs: "true" + + - task: PowerShell@2 + displayName: Display version and bundle path for diagnosing + inputs: + targetType: inline + script: | + echo $(version) + echo $(appxBundlePath) + + - task: PowerShell@2 + displayName: "Update package manifest version" + inputs: + targetType: inline + script: | + [xml]$manifest = get-content "$(workingDirectory)/WingetCreatePackage/Package.appxmanifest" + $manifest.Package.Identity.Version = "$(version)" + $manifest.save("$(workingDirectory)/WingetCreatePackage/Package.appxmanifest") + + - task: DotNetCoreCLI@2 + displayName: Restore + inputs: + command: "restore" + feedsToUse: "config" + nugetConfigPath: "NuGet.config" + projects: $(workingDirectory)/**/*.csproj + + - task: MSBuild@1 + displayName: Build Solution + inputs: + platform: "$(buildPlatform)" + solution: "$(solution)" + configuration: "$(buildConfiguration)" + msbuildArguments: '/p:AppxBundleOutput="$(appxBundlePath)" + /p:AppxBundle=Always + /p:UapAppxPackageBuildMode=SideloadOnly + /p:AppxPackageSigningEnabled=false' + + - task: 1ES.PublishPipelineArtifact@1 + inputs: + targetPath: $(wingetCreatePackageDir) + artifactName: wingetcreate_msixbundle + displayName: Publish WingetCreate msix bundle + + - task: ComponentGovernanceComponentDetection@0 + displayName: Component Governance + inputs: + scanType: "Register" + verbosity: "Verbose" + alertWarningLevel: "High" + + - task: notice@0 + displayName: "NOTICE File Generator" + condition: not(eq(variables['Build.Reason'], 'PullRequest')) + inputs: + outputfile: "$(System.DefaultWorkingDirectory)/temp/NOTICE.txt" + outputformat: "text" + + - bash: | + echo "Diffing existing NOTICE.txt with generated version" + diff -w NOTICE.txt temp/NOTICE.txt + if [[ $? -ne 0 ]]; + then + echo "Notice file modified" + echo "*******************************************************************************************************" + echo "Download the updated NOTICE.txt from the build artifacts and update the file in your PR, then re-submit" + echo "*******************************************************************************************************" + exit 1 + else + echo "Notice file not modified." + fi + displayName: "Trigger build warning if NOTICE.txt file needs to be modified." + condition: not(eq(variables['Build.Reason'], 'PullRequest')) + continueOnError: "true" + + - task: VSTest@2 + displayName: Run Tests + inputs: + testSelector: "testAssemblies" + testAssemblyVer2: 'src\WingetCreateTests\WingetCreateTests\bin\$(buildPlatform)\$(buildConfiguration)\$(targetFramework)\WingetCreateTests.dll' + runSettingsFile: 'src\WingetCreateTests\WingetCreateTests\Test.runsettings' + overrideTestrunParameters: '-WingetPkgsTestRepoOwner microsoft -WingetPkgsTestRepo winget-pkgs-submission-test -GitHubAppPrivateKey "$(GitHubApp_PrivateKey)"' \ No newline at end of file