Skip to content

Commit f1b5160

Browse files
authored
Update RC pipeline to use 1ES templates (#904)
Update two powershell scripts to be PS v6 compatible to pass scans
1 parent 2eb4ab3 commit f1b5160

6 files changed

Lines changed: 307 additions & 61 deletions

File tree

Pipelines/Scripts/validatecode.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,11 @@ function GetProjectRelativePath {
245245
)
246246
process {
247247
$normalizedFileName = $FileName.Replace("\", "/")
248-
$substringLength = $Directory.EndsWith("/") ? $Directory.Length : $Directory.Length + 1
248+
if ($Directory.EndsWith("/")) {
249+
$substringLength = $Directory.Length
250+
} else {
251+
$substringLength = $Directory.Length + 1
252+
}
249253
$assetFileName = $normalizedFileName.SubString($substringLength)
250254
$assetFileName
251255
}

Pipelines/Templates/1ES/docs.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright (c) Mixed Reality Toolkit Contributors
2+
# Licensed under the BSD 3-Clause
3+
4+
# [Template] Generate binaries for API reference docs.
5+
6+
parameters:
7+
unityDirectory: "C:/Program Files/Unity/Hub/Editor/2021.3.21f1"
8+
docToolProjectRoot: $(Build.SourcesDirectory)/lib.doctools
9+
mrtkProjectRoot: $(Build.SourcesDirectory)/MixedRealityToolkit-Unity
10+
outputDirectory: $(Build.ArtifactStagingDirectory)/docs
11+
12+
steps:
13+
- task: PowerShell@2
14+
displayName: 'Update package versions'
15+
inputs:
16+
pwsh: true
17+
targetType: filePath
18+
filePath: ${{ parameters.mrtkProjectRoot }}/Pipelines/Scripts/update-versions.ps1
19+
arguments: >
20+
-PackagesRoot: ${{ parameters.mrtkProjectRoot }}
21+
22+
- task: PowerShell@2
23+
displayName: "Generate DocTool Unity asset package"
24+
inputs:
25+
pwsh: true
26+
targetType: filePath
27+
filePath: ${{ parameters.docToolProjectRoot }}/Scripts/exportunitypackage.ps1
28+
arguments: >
29+
-UnityDirectory: "${{ parameters.unityDirectory }}"
30+
31+
- task: PowerShell@2
32+
displayName: "Generate docs binaries using DocTool package"
33+
inputs:
34+
targetType: filePath
35+
pwsh: true
36+
filePath: ${{ parameters.docToolProjectRoot }}/Scripts/importdoctoolgeneratebinaries.ps1
37+
arguments: >
38+
-ProjectDirectory: "${{ parameters.mrtkProjectRoot }}/UnityProjects/MRTKDevTemplate"
39+
-UnityDirectory: "${{ parameters.unityDirectory }}"
40+
-OutputDirectory: "${{ parameters.outputDirectory }}"
41+
-ImportPackagePath: "${{ parameters.docToolProjectRoot }}/Export/DocTool.unitypackage"
42+
-ProductName: "MRTK3"
43+
-TargetPlatform: "WindowsStoreApps"
44+
-DocsPackageMap: @{"MixedReality.Toolkit.Accessibility"="mrtkaccessibility";"MixedReality.Toolkit.Audio"="mrtkaudio";"MixedReality.Toolkit.Core"="mrtkcore";"MixedReality.Toolkit.Data"="mrtkdata";"MixedReality.Toolkit.Diagnostics"="mrtkdiagnostics";"MixedReality.Toolkit.Input"="mrtkinput";"MixedReality.Toolkit.SpatialManipulation"="mrtkspatialmanipulation";"MixedReality.Toolkit.UXComponents"="mrtkuxcomponents";"MixedReality.Toolkit.UXCore"="mrtkuxcore";"MixedReality.Toolkit.Speech.Windows"="mrtkwindowsspeech"}
45+
-IgnoreTestAssemblies: $true
46+
-OutputDirectoryPostfixVersion
47+
-CommonDependenciesDirectory
48+
49+
- task: 1ES.PublishPipelineArtifact@1
50+
displayName: "Publish binaries for API reference docs"
51+
inputs:
52+
path: ${{ parameters.outputDirectory }}
53+
artifact: "docs-binaries"

Pipelines/Templates/1ES/unity.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright (c) Mixed Reality Toolkit Contributors
2+
# Licensed under the BSD 3-Clause
3+
4+
parameters:
5+
- name: UnityVersion
6+
type: string
7+
default: Latest
8+
9+
- name: ProjectName
10+
type: string
11+
default: MRTK3 Sample
12+
13+
- name: CommandLineBuildMethod
14+
type: string
15+
default: MixedReality.Toolkit.Examples.Build.BuildApp.StartCommandLineBuild
16+
17+
- name: PathToProject
18+
type: string
19+
default: $(Build.SourcesDirectory)/MixedRealityToolkit-Unity/UnityProjects/MRTKDevTemplate
20+
21+
- name: RunTests
22+
type: boolean
23+
default: false
24+
25+
- name: Platform
26+
type: string
27+
default: None
28+
values:
29+
- None
30+
- Standalone
31+
- UWP
32+
- Android
33+
34+
steps:
35+
36+
37+
# Standalone x64 tasks
38+
39+
- ${{ if eq(parameters.Platform, 'Standalone') }}:
40+
- template: /Pipelines/Templates/Tasks/build-unity.yaml
41+
parameters:
42+
UnityVersion: ${{ parameters.UnityVersion }}
43+
BuildTarget: StandaloneWindows64
44+
CommandLineBuildMethod: ${{ parameters.CommandLineBuildMethod }}
45+
PathToProject: ${{ parameters.PathToProject }}
46+
OutputPath: $(Build.ArtifactStagingDirectory)/Apps-${{ parameters.Platform }}/exe-x64/${{ parameters.ProjectName }}.exe
47+
AdditionalArguments: -EnableCacheServer -cacheServerEndpoint 10.0.0.6 -cacheServerNamespacePrefix MRTK3 -cacheServerEnableDownload true -cacheServerEnableUpload true
48+
49+
# Run tests early, but don't bother if the standalone build failed.
50+
- ${{ if eq(parameters.RunTests, true) }}:
51+
- template: /Pipelines/Templates/tests.yaml
52+
parameters:
53+
UnityVersion: ${{ parameters.UnityVersion }}
54+
BuildTarget: StandaloneWindows64
55+
PathToProject: ${{ parameters.PathToProject }}
56+
AdditionalArguments: -noGraphics -EnableCacheServer -cacheServerEndpoint 10.0.0.6 -cacheServerNamespacePrefix MRTK3 -cacheServerEnableDownload true
57+
58+
# UWP tasks
59+
60+
- ${{ if eq(parameters.Platform, 'UWP') }}:
61+
- template: /Pipelines/Templates/Tasks/build-unity.yaml
62+
parameters:
63+
UnityVersion: ${{ parameters.UnityVersion }}
64+
BuildTarget: WSAPlayer
65+
CommandLineBuildMethod: ${{ parameters.CommandLineBuildMethod }}
66+
PathToProject: ${{ parameters.PathToProject }}
67+
OutputPath: $(Agent.TempDirectory)/build/uwp
68+
AdditionalArguments: -EnableCacheServer -cacheServerEndpoint 10.0.0.6 -cacheServerNamespacePrefix MRTK3 -cacheServerEnableDownload true -cacheServerEnableUpload true
69+
70+
- pwsh: |
71+
$manifestPath = "$(Agent.TempDirectory)/build/uwp/${{ parameters.ProjectName }}/Package.appxmanifest"
72+
((Get-Content -Path $manifestPath -Raw) -Replace '(<Identity[^\>]*Version=)"[0-9.]+', '$1"$(ProjectVersion).0') | Set-Content -Path $manifestPath -NoNewline
73+
displayName: Patch UWP AppX version
74+
75+
- template: /Pipelines/Templates/Tasks/build-appx.yaml
76+
parameters:
77+
ProjectName: ${{ parameters.ProjectName }}
78+
BuildFolderPath: $(Agent.TempDirectory)/build/uwp
79+
Architectures: [x64, ARM64]
80+
Version: $(ProjectVersion)
81+
TargetFolder: $(Build.ArtifactStagingDirectory)/Apps-${{ parameters.Platform }}
82+
83+
# Android tasks
84+
85+
- ${{ if eq(parameters.Platform, 'Android') }}:
86+
- template: /Pipelines/Templates/Tasks/build-unity.yaml
87+
parameters:
88+
UnityVersion: ${{ parameters.UnityVersion }}
89+
BuildTarget: Android
90+
CommandLineBuildMethod: ${{ parameters.CommandLineBuildMethod }}
91+
PathToProject: ${{ parameters.PathToProject }}
92+
OutputPath: $(Build.ArtifactStagingDirectory)/Apps-${{ parameters.Platform }}/apk/${{ parameters.ProjectName }}.apk
93+
94+
# Publishing tasks
95+
96+
- ${{ if not(eq(parameters.Platform, 'None')) }}:
97+
- task: 1ES.PublishPipelineArtifact@1
98+
displayName: Publish apps
99+
inputs:
100+
path: $(Build.ArtifactStagingDirectory)/Apps-${{ parameters.Platform }}
101+
artifact: Apps-${{ parameters.ProjectName }}-${{ parameters.Platform }}

Pipelines/Templates/1ES/upm.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) Mixed Reality Toolkit Contributors
2+
# Licensed under the BSD 3-Clause
3+
4+
# [Template] Pack and optionally publish UPM packages.
5+
6+
parameters:
7+
projectRoot: $(Build.SourcesDirectory)/MixedRealityToolkit-Unity
8+
outputDirectory: $(Build.ArtifactStagingDirectory)/build/upm/output
9+
buildNumber: $(Version.Revision)
10+
prereleaseTag: $(ReleaseTagPrefix)
11+
publishToArtifacts: true
12+
publishToFeed: true
13+
14+
steps:
15+
- task: PowerShell@2
16+
displayName: 'Pack preview UPM packages'
17+
inputs:
18+
pwsh: true
19+
targetType: filePath
20+
filePath: ${{ parameters.projectRoot }}/Pipelines/Scripts/pack-upm.ps1
21+
arguments: >
22+
-ProjectRoot: ${{ parameters.projectRoot }}
23+
-OutputDirectory: ${{ parameters.outputDirectory }}
24+
-PrereleaseTag: ${{ parameters.prereleaseTag }}
25+
-Revision: $(Version.DateCode).$(Version.DateCodeRevision)
26+
-BuildNumber: ${{ parameters.buildNumber }}
27+
28+
- ${{ if eq(parameters.publishToArtifacts, true) }}:
29+
- task: 1ES.PublishPipelineArtifact@1
30+
displayName: 'Publish UPM artifacts'
31+
inputs:
32+
path: ${{ parameters.outputDirectory }}
33+
artifact: "mrtk-upm"
34+
35+
- ${{ if eq(parameters.publishToFeed, true) }}:
36+
- template: ../Tasks/publish-upm.yaml
37+
parameters:
38+
packageDirectory: ${{ parameters.outputDirectory }}
39+
registryPath: $(UpmRegistry)
40+
authenticationEndpoint: $(ServiceConnectionName)

Pipelines/rc.yaml

Lines changed: 98 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
# Copyright (c) Mixed Reality Toolkit Contributors
22
# Licensed under the BSD 3-Clause
33

4-
# RC build producing release candidate packages.
4+
name: '$(date:yyMM).$(date:dd)$(rev:rr)-MixedRealityToolkit-RC'
5+
6+
7+
schedules:
8+
- cron: "0 4 1,15 * *"
9+
displayName: Run At 04:00 on the 1st and 15th of each month
10+
# run even when there are no code changes
11+
always: true
12+
branches:
13+
include:
14+
- main
15+
16+
trigger: none
17+
pr: none
518

619
variables:
720
- template: Config/settings.yaml
@@ -12,62 +25,89 @@ variables:
1225
- name: Version.DateCodeRevision
1326
value: $[counter(format('{0:yyMMdd}', pipeline.startTime), 0)]
1427

28+
1529
resources:
1630
repositories:
17-
- repository: PipelineTools
18-
type: git
19-
endpoint: ToolsAccess
20-
name: tools.internal
21-
ref: 78ecf591964ecf511b4c7a0cd84d98ce11e8be16
22-
- repository: DocToolUnityProject
23-
type: git
24-
endpoint: ToolsAccess
25-
name: lib.doctools
26-
ref: 26723e6afa6d2adb44a734bd6ce0bc2bd90638b5
27-
28-
trigger: none # only manual runs
29-
30-
jobs:
31-
- job: UnityValidation
32-
pool: Unity_2021.3.21f1_Pool
33-
steps:
34-
- checkout: self
35-
36-
- checkout: PipelineTools
37-
38-
- task: ComponentGovernanceComponentDetection@0
39-
inputs:
40-
scanType: Register
41-
alertWarningLevel: Medium
42-
failOnAlert: true
43-
44-
- template: Templates/unity.yaml
45-
parameters:
46-
Platform: Standalone
47-
48-
- template: Templates/unity.yaml
49-
parameters:
50-
Platform: UWP
51-
52-
- template: Templates/unity.yaml
53-
parameters:
54-
Platform: Android
55-
56-
- template: Templates/upm.yaml
57-
parameters:
58-
prereleaseTag: $(ReleaseTagPrefix)
59-
buildNumber: $(Version.Revision)
60-
publishToFeed: true
61-
62-
- job: DocsBinariesGeneration
63-
pool: Unity_2021.3.21f1_Pool
64-
steps:
65-
- checkout: self
66-
67-
- checkout: PipelineTools
68-
69-
- checkout: DocToolUnityProject
70-
71-
- template: Templates/license-unity.yaml@PipelineTools
72-
73-
- template: Templates/docs.yaml
31+
- repository: 1ESPipelineTemplates
32+
type: git
33+
name: 1ESPipelineTemplates/1ESPipelineTemplates
34+
ref: refs/tags/release
35+
- repository: PipelineTools
36+
type: git
37+
endpoint: ToolsAccess
38+
name: tools.internal
39+
ref: 78ecf591964ecf511b4c7a0cd84d98ce11e8be16
40+
- repository: DocToolUnityProject
41+
type: git
42+
endpoint: ToolsAccess
43+
name: lib.doctools
44+
ref: 26723e6afa6d2adb44a734bd6ce0bc2bd90638b5
45+
46+
extends:
47+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
48+
parameters:
49+
pool:
50+
name: Unity_2021.3.21f1_Pool
51+
sdl:
52+
sourceRepositoriesToScan:
53+
exclude:
54+
- repository: PipelineTools
55+
- repository: DocToolUnityProject
56+
57+
tsa:
58+
enabled: true
59+
config:
60+
codebaseName: $(tsaCodeBasename)
61+
instanceUrl: $(tsaAdoOrg)
62+
projectName: $(tsaAdoProject)
63+
areaPath: $(tsaAreaPath)
64+
interationPath: $(tsaIterationPath)
65+
notificationAliases: $(tsaNotificationAliases)
66+
67+
binskim:
68+
break: false
69+
scanOutputDirectoryOnly: true
70+
stages:
71+
- stage: 'Build'
72+
jobs:
73+
- job: UnityValidation
74+
75+
steps:
76+
- checkout: self
77+
- checkout: PipelineTools
78+
- checkout: DocToolUnityProject
79+
80+
- powershell: Get-ChildItem -Path $(Build.SourcesDirectory) -recurse
81+
displayName: 'Initial source tree'
82+
83+
- pwsh: Install-Module PowerShellGet -Force
84+
displayName: Update PowerShellGet
85+
86+
- pwsh: Install-Module UnitySetup -Scope CurrentUser -Force -AllowPrerelease -RequiredVersion 5.6.161-develop
87+
displayName: Install unitysetup.powershell
88+
89+
- template: Templates/license-unity.yaml@PipelineTools
90+
91+
92+
- template: /Pipelines/Templates/1ES/unity.yaml@self
93+
parameters:
94+
Platform: Standalone
95+
96+
- template: /Pipelines/Templates/1ES/unity.yaml@self
97+
parameters:
98+
Platform: UWP
99+
100+
- template: /Pipelines/Templates/1ES/unity.yaml@self
101+
parameters:
102+
Platform: Android
103+
104+
- template: /Pipelines/Templates/1ES/upm.yaml@self
105+
parameters:
106+
prereleaseTag: $(ReleaseTagPrefix)
107+
buildNumber: $(Version.Revision)
108+
publishToFeed: true
109+
110+
- template: /Pipelines/Templates/1ES/docs.yaml@self
111+
112+
113+

Tooling/find-guids.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Get-ChildItem . -File -Recurse -Include *.unity, *.prefab, *.asset, *.mat, *.met
3030
}
3131
}
3232

33-
Write-Host "`nFound GUIDs in $count file$($count -eq 1 ? '' : 's')"
33+
if ($count -eq 1) {
34+
Write-Host "`nFound GUIDs in $count file"
35+
} else {
36+
Write-Host "`nFound GUIDs in $count files"
37+
}
3438

35-
exit $count -gt 0 ? 1 : 0
39+
if ($count -gt 0) {
40+
exit 1
41+
} else {
42+
exit 0
43+
}

0 commit comments

Comments
 (0)