Skip to content

Commit 203a471

Browse files
authored
Draft PR to Setup OneBranch CI Pipeline (#1636)
WIP
1 parent b8bbce3 commit 203a471

5 files changed

Lines changed: 255 additions & 4 deletions

File tree

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
2+
3+
# https://aka.ms/obpipelines/triggers
4+
trigger: none
5+
6+
parameters: # parameters are shown up in ADO UI in a build queue time
7+
- name: 'debug'
8+
displayName: 'Enable debug output'
9+
type: boolean
10+
default: false
11+
12+
variables:
13+
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
14+
system.debug: ${{ parameters.debug }}
15+
ENABLE_PRS_DELAYSIGN: 1
16+
ROOT: $(Build.SourcesDirectory)
17+
REPOROOT: $(Build.SourcesDirectory)
18+
OUTPUTROOT: $(REPOROOT)\out
19+
NUGET_XMLDOC_MODE: none
20+
21+
# Docker image which is used to build the project https://aka.ms/obpipelines/containers
22+
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2019/vse2022:latest'
23+
24+
Codeql.Enabled: true # CodeQL once every 3 days on the default branch for all languages its applicable to in that pipeline.
25+
26+
resources:
27+
repositories:
28+
- repository: templates
29+
type: git
30+
name: OneBranch.Pipelines/GovernedTemplates
31+
ref: refs/heads/main
32+
33+
extends:
34+
template: v2/OneBranch.Official.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
35+
parameters:
36+
platform:
37+
name: 'windows_undocked'
38+
39+
globalSdl: # Refer the wiki for more options in this parameter: https://aka.ms/obpipelines/sdl
40+
tsa:
41+
enabled: false # onebranch publish all sdl results to TSA. If TSA is disabled all SDL tools will forced into 'break' build mode.
42+
# suppression:
43+
# suppressionFile: $(Build.SourcesDirectory)\.gdn\global.gdnsuppress
44+
featureFlags:
45+
ensureArtifactsDirExists: true
46+
47+
stages:
48+
- stage: build
49+
jobs:
50+
- job: main
51+
pool:
52+
# read more about custom job pool types at https://aka.ms/obpipelines/yaml/jobs
53+
pool:
54+
type: windows
55+
isCustom: true
56+
name: Azure Pipelines
57+
vmImage: 'windows-latest'
58+
59+
variables:
60+
ob_outputDirectory: $(build.artifactStagingDirectory)
61+
ob_artifactSuffix: _$(buildPlatform)_$(buildConfiguration)
62+
63+
solutionGallery: "**/WinUIGallery.sln"
64+
solutionUITests: "**/UITests.sln"
65+
buildPlatform: "x64"
66+
buildConfiguration: "Debug"
67+
appxPackageDir: '$(Build.ArtifactStagingDirectory)\AppxPackages\\'
68+
69+
steps:
70+
# Package Restore
71+
- task: NuGetToolInstaller@1
72+
displayName: Install NuGet 5.8.0
73+
inputs:
74+
versionSpec: 5.8.0
75+
76+
- task: NuGetCommand@2
77+
displayName: Restore NuGet Packages for WinUI Gallery
78+
inputs:
79+
command: 'restore'
80+
restoreSolution: '**/*.sln'
81+
feedsToUse: 'config'
82+
nugetConfigPath: '$(System.DefaultWorkingDirectory)\nuget.config'
83+
84+
- task: UseDotNet@2
85+
continueOnError: true
86+
inputs:
87+
packageType: 'sdk'
88+
performMultiLevelLookup: true
89+
90+
# Signing
91+
- task: PowerShell@2
92+
displayName: Generate Test Signing Certificate
93+
inputs:
94+
targetType: filePath
95+
filePath: build/GenerateTestPFX.ps1
96+
97+
# Build (Product)
98+
- task: DotNetCoreCLI@2
99+
displayName: Build WinUI Gallery Package
100+
inputs:
101+
command: 'publish'
102+
publishWebProjects: false
103+
projects: '$(solutionGallery)'
104+
arguments: '/p:AppxPackageDir="$(appxPackageDir)" /p:platform="$(buildPlatform)" /p:configuration="$(buildConfiguration)" /p:PublishProfile="./WinUIGallery/Properties/PublishProfiles/win-$(buildPlatform).pubxml"'
105+
zipAfterPublish: false
106+
modifyOutputPath: false
107+
108+
- script: |
109+
dir /b /s $(Build.ArtifactStagingDirectory)
110+
dir /b /s $(System.DefaultWorkingDirectory)
111+
displayName: 'List contents of ArtifactStagingDirectory and DefaultWorkingDirectory'
112+
113+
# Install and Run Unit Tests
114+
- task: VSTest@2
115+
displayName: 'Run Sample Unit Tests'
116+
inputs:
117+
testSelector: "testAssemblies"
118+
searchFolder: "$(System.DefaultWorkingDirectory)"
119+
failOnMinTestsNotRun: true
120+
minimumExpectedTests: '3'
121+
testAssemblyVer2: |
122+
**\WinUIGalleryUnitTests.build.appxrecipe
123+
124+
# Build and Run UI Tests
125+
- task: PowerShell@2
126+
displayName: Install WinUI Gallery Package
127+
inputs:
128+
targetType: "inline"
129+
script: |
130+
cd $(appxPackageDir)
131+
132+
$AppBundle = Get-ChildItem -Filter WinUIGallery*Test -Name
133+
cd $AppBundle
134+
135+
.\Install.ps1 -Certificate WinUIGallery.Desktop.cer -Force
136+
errorActionPreference: "continue"
137+
failOnStderr: true
138+
workingDirectory: "$(System.DefaultWorkingDirectory)"
139+
140+
- task: NuGetCommand@2
141+
displayName: Restore Packages for UI Tests Project
142+
inputs:
143+
restoreSolution: "$(solutionUITests)"
144+
145+
- task: VSBuild@1
146+
displayName: Build UI Tests Project
147+
inputs:
148+
platform: "$(buildPlatform)"
149+
solution: "$(solutionUITests)"
150+
configuration: "$(buildConfiguration)"
151+
- task: Windows Application Driver@0
152+
displayName: Start Windows Application Driver
153+
inputs:
154+
OperationType: "Start"
155+
AgentResolution: "1080p"
156+
WADArguments: "4724"
157+
158+
- task: VSTest@2
159+
displayName: Run UI Tests
160+
inputs:
161+
testSelector: "testAssemblies"
162+
testAssemblyVer2: |
163+
**\UITests.dll
164+
!**\*TestAdapter.dll
165+
!**\obj\**
166+
!**\ref\**
167+
platform: '$(buildPlatform)'
168+
configuration: "$(buildConfiguration)"
169+
searchFolder: "$(System.DefaultWorkingDirectory)"
170+
171+
- task: Windows Application Driver@0
172+
displayName: Stop Windows Application Driver
173+
inputs:
174+
OperationType: "Stop"
175+
176+
- task: PublishPipelineArtifact@1
177+
inputs:
178+
targetPath: $(ob_outputDirectory)
179+
artifact: 'drop_build_main_$(buildPlatform)_$(buildConfiguration)'
180+
publishLocation: 'pipeline'
181+
182+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Sync branches in a mirror repository to a base repo by running this pipeline
2+
# from the mirror repo, and supplying the base repo as a parameter
3+
name: $(BuildDefinitionName)_$(date:yyMMdd)$(rev:.r)
4+
5+
parameters:
6+
- name: "SourceToTargetBranches"
7+
type: object
8+
default:
9+
main: main
10+
- name: "SourceRepository"
11+
type: string
12+
default: "https://github.com/microsoft/WinUI-Gallery.git"
13+
14+
resources:
15+
repositories:
16+
- repository: templates
17+
type: git
18+
name: OneBranch.Pipelines/GovernedTemplates
19+
ref: refs/heads/main
20+
- repository: InternalWinUIGallery
21+
type: git
22+
name: WinUI/WinUI-Gallery-Mirror
23+
ref: refs/heads/main
24+
25+
jobs:
26+
- job: SyncMirror
27+
pool:
28+
vmImage: "windows-2022"
29+
strategy:
30+
matrix:
31+
${{ each branches in parameters.SourceToTargetBranches }}:
32+
${{ branches.key }}:
33+
SourceBranch: ${{ branches.key }}
34+
TargetBranch: ${{ branches.value }}
35+
36+
dependsOn: []
37+
steps:
38+
- checkout: self
39+
path: s/
40+
persistCredentials: true
41+
42+
- task: PowerShell@2
43+
inputs:
44+
targetType: 'inline'
45+
script: |
46+
Write-Host "SourceBranch " + "$(SourceBranch)"
47+
Write-Host "TargetBranch " + "$(TargetBranch)"
48+
49+
$repo = "${{ parameters.SourceRepository }}"
50+
git remote add sourcerepo $repo
51+
git remote
52+
53+
$target = "$(TargetBranch)"
54+
git fetch origin $target
55+
git checkout $target
56+
git pull origin $target
57+
58+
$source = "$(SourceBranch)"
59+
60+
git config --global user.email "ControlsGallery@microsoft.com"
61+
git config --global user.name "Controls Gallery"
62+
63+
git fetch sourcerepo $source
64+
git pull sourcerepo $source
65+
66+
- task: CmdLine@2
67+
inputs:
68+
script: |
69+
git push

UITests/SessionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace UITests
2727
[TestClass]
2828
public class SessionManager
2929
{
30-
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
30+
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4724";
3131
private static readonly string[] WinUIGalleryAppIDs = new string[]{
3232
"Microsoft.WinUI3ControlsGallery.Debug_grv3cx5qrw0gp!App",
3333
"Microsoft.WinUI3ControlsGallery_grv3cx5qrw0gp!App"

nuget.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<clear />
88
</disabledPackageSources>
99
<packageSources>
10-
<!-- For more info, see https://docs.nuget.org/consume/nuget-config-file -->
11-
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
10+
<clear />
11+
<add key="MUX-Dependencies" value="https://pkgs.dev.azure.com/shine-oss/microsoft-ui-xaml/_packaging/MUX-Dependencies/nuget/v3/index.json" />
1212

1313
<!-- a local directory to allow testing nupkg files without pushing to a remote feed -->
14-
<add key="gallerystore" value="packagestore" />
14+
<add key="packagestore" value="packagestore" />
1515
</packageSources>
1616
<activePackageSource>
1717
<add key="All" value="(Aggregate source)" />

0 commit comments

Comments
 (0)