Skip to content

Commit 23535d2

Browse files
User/masudars/microsoft winget create azure pipelines migration to 1 es (#468)
1 parent d7e716c commit 23535d2

File tree

3 files changed

+149
-113
lines changed

3 files changed

+149
-113
lines changed

pipelines/azure-pipelines.yml

Lines changed: 135 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ variables:
2121
# Appx Package Directory
2222
appxPackageDir: '$(Build.ArtifactStagingDirectory)\AppxPackages'
2323

24-
# Agent VM image name
25-
vmImageName: "windows-latest"
24+
# WingetCreate Msix Bundle Directory
25+
wingetCreatePackageDir: '$(appxPackageDir)\WingetCreateMsixBundle'
2626

2727
# Working Directory
2828
workingDirectory: "src"
@@ -36,113 +36,137 @@ variables:
3636
# Target framework
3737
targetFramework: "net6.0-windows10.0.22000.0"
3838

39-
jobs:
40-
- job: GetVersion
41-
variables:
42-
runCodesignValidationInjection: ${{ false }}
43-
skipComponentGovernanceDetection: ${{ true }}
44-
steps:
45-
- powershell: |
46-
[xml]$project = get-content "$(workingDirectory)/WingetCreateCLI/WingetCreateCLI.csproj"
47-
$version = $project.Project.PropertyGroup.Version
48-
echo "##vso[task.setvariable variable=majorMinorVersion;isOutput=true]$version"
49-
name: GetVersionStep
50-
displayName: Get version from CLI project
51-
52-
- job: Build
53-
displayName: Build
54-
dependsOn: GetVersion
55-
variables:
56-
majorMinorVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorVersion']]
57-
# Only update counter for non-PR builds, otherwise just use 0 for the revision
58-
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
59-
buildVersion: 0
60-
${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
61-
buildVersion: $[counter(variables['majorMinorVersion'], 1)]
62-
63-
version: "$(majorMinorVersion).$(buildVersion).0"
64-
appxBundlePath: '$(appxPackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle'
39+
resources:
40+
repositories:
41+
- repository: 1ESPipelineTemplates
42+
type: git
43+
name: 1ESPipelineTemplates/1ESPipelineTemplates
44+
ref: refs/tags/release
45+
46+
extends:
47+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
48+
parameters:
6549
pool:
66-
vmImage: $(vmImageName)
67-
68-
steps:
69-
- checkout: self
70-
lfs: "true"
71-
72-
- powershell: |
73-
echo $(version)
74-
echo $(appxBundlePath)
75-
displayName: Display version and bundle path for diagnosing
76-
77-
- powershell: |
78-
[xml]$manifest = get-content "$(workingDirectory)/WingetCreatePackage/Package.appxmanifest"
79-
$manifest.Package.Identity.Version = "$(version)"
80-
$manifest.save("$(workingDirectory)/WingetCreatePackage/Package.appxmanifest")
81-
displayName: "Update package manifest version"
82-
83-
- task: DotNetCoreCLI@2
84-
displayName: Restore
85-
inputs:
86-
command: "restore"
87-
feedsToUse: "config"
88-
nugetConfigPath: "NuGet.config"
89-
projects: $(workingDirectory)/**/*.csproj
90-
91-
- task: MSBuild@1
92-
displayName: Build Solution
93-
inputs:
94-
platform: "$(buildPlatform)"
95-
solution: "$(solution)"
96-
configuration: "$(buildConfiguration)"
97-
msbuildArguments: '/p:AppxBundleOutput="$(appxBundlePath)"
98-
/p:AppxBundle=Always
99-
/p:UapAppxPackageBuildMode=SideloadOnly
100-
/p:AppxPackageSigningEnabled=false'
101-
102-
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
103-
displayName: 'Generate SBOM'
104-
inputs:
105-
BuildDropPath: '$(appxPackageDir)'
106-
107-
- publish: $(appxBundlePath)
108-
artifact: msixbundle
109-
displayName: Publish msix bundle
110-
111-
- task: ComponentGovernanceComponentDetection@0
112-
displayName: Component Governance
113-
inputs:
114-
scanType: "Register"
115-
verbosity: "Verbose"
116-
alertWarningLevel: "High"
117-
118-
- task: notice@0
119-
displayName: "NOTICE File Generator"
120-
condition: not(eq(variables['Build.Reason'], 'PullRequest'))
121-
inputs:
122-
outputfile: "$(System.DefaultWorkingDirectory)/temp/NOTICE.txt"
123-
outputformat: "text"
124-
125-
- bash: |
126-
echo "Diffing existing NOTICE.txt with generated version"
127-
diff -w NOTICE.txt temp/NOTICE.txt
128-
if [[ $? -ne 0 ]];
129-
then
130-
echo "Notice file modified"
131-
echo "*******************************************************************************************************"
132-
echo "Download the updated NOTICE.txt from the build artifacts and update the file in your PR, then re-submit"
133-
echo "*******************************************************************************************************"
134-
exit 1
135-
else
136-
echo "Notice file not modified."
137-
fi
138-
displayName: "Trigger build warning if NOTICE.txt file needs to be modified."
139-
condition: not(eq(variables['Build.Reason'], 'PullRequest'))
140-
continueOnError: "true"
141-
142-
- task: VSTest@2
143-
displayName: Run Tests
144-
inputs:
145-
testSelector: "testAssemblies"
146-
testAssemblyVer2: 'src\WingetCreateTests\WingetCreateTests\bin\$(buildPlatform)\$(buildConfiguration)\$(targetFramework)\WingetCreateTests.dll'
147-
runSettingsFile: 'src\WingetCreateTests\WingetCreateTests\Test.runsettings'
148-
overrideTestrunParameters: '-WingetPkgsTestRepoOwner microsoft -WingetPkgsTestRepo winget-pkgs-submission-test -GitHubAppPrivateKey "$(GitHubApp_PrivateKey)"'
50+
name: Azure-Pipelines-1ESPT-ExDShared
51+
image: windows-2022
52+
os: windows
53+
customBuildTags:
54+
- ES365AIMigrationTooling
55+
56+
stages:
57+
- stage: GetVersion_Build
58+
59+
jobs:
60+
- job: GetVersion
61+
variables:
62+
runCodesignValidationInjection: ${{ false }}
63+
skipComponentGovernanceDetection: ${{ true }}
64+
steps:
65+
- task: PowerShell@2
66+
name: GetVersionStep
67+
displayName: Get version from CLI project
68+
inputs:
69+
targetType: "inline"
70+
script: |
71+
[xml]$project = get-content "$(workingDirectory)/WingetCreateCLI/WingetCreateCLI.csproj"
72+
$version = $project.Project.PropertyGroup.Version
73+
echo "##vso[task.setvariable variable=majorMinorVersion;isOutput=true]$version"
74+
75+
- job: Build
76+
displayName: Build
77+
dependsOn: GetVersion
78+
variables:
79+
majorMinorVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorVersion']]
80+
# Only update counter for non-PR builds, otherwise just use 0 for the revision
81+
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
82+
buildVersion: 0
83+
${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
84+
buildVersion: $[counter(variables['majorMinorVersion'], 1)]
85+
86+
version: "$(majorMinorVersion).$(buildVersion).0"
87+
appxBundlePath: '$(wingetCreatePackageDir)\Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle'
88+
89+
steps:
90+
- checkout: self
91+
lfs: "true"
92+
93+
- task: PowerShell@2
94+
displayName: Display version and bundle path for diagnosing
95+
inputs:
96+
targetType: inline
97+
script: |
98+
echo $(version)
99+
echo $(appxBundlePath)
100+
101+
- task: PowerShell@2
102+
displayName: "Update package manifest version"
103+
inputs:
104+
targetType: inline
105+
script: |
106+
[xml]$manifest = get-content "$(workingDirectory)/WingetCreatePackage/Package.appxmanifest"
107+
$manifest.Package.Identity.Version = "$(version)"
108+
$manifest.save("$(workingDirectory)/WingetCreatePackage/Package.appxmanifest")
109+
110+
- task: DotNetCoreCLI@2
111+
displayName: Restore
112+
inputs:
113+
command: "restore"
114+
feedsToUse: "config"
115+
nugetConfigPath: "NuGet.config"
116+
projects: $(workingDirectory)/**/*.csproj
117+
118+
- task: MSBuild@1
119+
displayName: Build Solution
120+
inputs:
121+
platform: "$(buildPlatform)"
122+
solution: "$(solution)"
123+
configuration: "$(buildConfiguration)"
124+
msbuildArguments: '/p:AppxBundleOutput="$(appxBundlePath)"
125+
/p:AppxBundle=Always
126+
/p:UapAppxPackageBuildMode=SideloadOnly
127+
/p:AppxPackageSigningEnabled=false'
128+
129+
- task: 1ES.PublishPipelineArtifact@1
130+
inputs:
131+
targetPath: $(wingetCreatePackageDir)
132+
artifactName: wingetcreate_msixbundle
133+
displayName: Publish WingetCreate msix bundle
134+
135+
- task: ComponentGovernanceComponentDetection@0
136+
displayName: Component Governance
137+
inputs:
138+
scanType: "Register"
139+
verbosity: "Verbose"
140+
alertWarningLevel: "High"
141+
142+
- task: notice@0
143+
displayName: "NOTICE File Generator"
144+
condition: not(eq(variables['Build.Reason'], 'PullRequest'))
145+
inputs:
146+
outputfile: "$(System.DefaultWorkingDirectory)/temp/NOTICE.txt"
147+
outputformat: "text"
148+
149+
- bash: |
150+
echo "Diffing existing NOTICE.txt with generated version"
151+
diff -w NOTICE.txt temp/NOTICE.txt
152+
if [[ $? -ne 0 ]];
153+
then
154+
echo "Notice file modified"
155+
echo "*******************************************************************************************************"
156+
echo "Download the updated NOTICE.txt from the build artifacts and update the file in your PR, then re-submit"
157+
echo "*******************************************************************************************************"
158+
exit 1
159+
else
160+
echo "Notice file not modified."
161+
fi
162+
displayName: "Trigger build warning if NOTICE.txt file needs to be modified."
163+
condition: not(eq(variables['Build.Reason'], 'PullRequest'))
164+
continueOnError: "true"
165+
166+
- task: VSTest@2
167+
displayName: Run Tests
168+
inputs:
169+
testSelector: "testAssemblies"
170+
testAssemblyVer2: 'src\WingetCreateTests\WingetCreateTests\bin\$(buildPlatform)\$(buildConfiguration)\$(targetFramework)\WingetCreateTests.dll'
171+
runSettingsFile: 'src\WingetCreateTests\WingetCreateTests\Test.runsettings'
172+
overrideTestrunParameters: '-WingetPkgsTestRepoOwner microsoft -WingetPkgsTestRepo winget-pkgs-submission-test -GitHubAppPrivateKey "$(GitHubApp_PrivateKey)"'

src/WingetCreateCore/WingetCreateCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<PackageReference Include="Microsoft.CorrelationVector" Version="1.0.42" />
2020
<PackageReference Include="Microsoft.Msix.Utils" Version="2.1.1" />
2121
<!--https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#generatepathproperty-->
22-
<PackageReference Include="Microsoft.WindowsPackageManager.Utils" Version="1.5.2" GeneratePathProperty="true" />
22+
<PackageReference Include="Microsoft.WindowsPackageManager.Utils" Version="1.7.1" GeneratePathProperty="true" />
2323
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
2424
<PackageReference Include="NLog" Version="4.7.9" />
2525
<PackageReference Include="NSwag.MSBuild" Version="13.11.1">

src/WingetCreateTests/WingetCreateTests/E2ETests/E2ETests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Microsoft.WingetCreateE2ETests
55
{
6+
using System;
67
using System.IO;
78
using System.Threading.Tasks;
89
using Microsoft.WingetCreateCLI.Commands;
@@ -11,6 +12,8 @@ namespace Microsoft.WingetCreateE2ETests
1112
using Microsoft.WingetCreateTests;
1213
using Microsoft.WingetCreateUnitTests;
1314
using NUnit.Framework;
15+
using Octokit;
16+
using Polly;
1417

1518
/// <summary>
1619
/// This class tests the entire end-to-end flow of the tool, from submitting a PR, retrieving the package from the repo
@@ -68,7 +71,16 @@ private async Task RunSubmitAndUpdateFlow(string packageId, string manifestPath,
6871
};
6972
Assert.IsTrue(await submitCommand.Execute(), "Command should have succeeded");
7073

71-
await this.gitHub.MergePullRequest(submitCommand.PullRequestNumber);
74+
var mergeRetryPolicy = Policy
75+
.Handle<PullRequestNotMergeableException>()
76+
.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(i));
77+
78+
await mergeRetryPolicy.ExecuteAsync(async () =>
79+
{
80+
// Attempting to merge immediately after creating the PR can throw an exception if the branch
81+
// has not completed verification if it can be merged. Wait and retry.
82+
await this.gitHub.MergePullRequest(submitCommand.PullRequestNumber);
83+
});
7284

7385
TestUtils.SetMockHttpResponseContent(installerName);
7486
UpdateCommand updateCommand = new UpdateCommand

0 commit comments

Comments
 (0)