Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build pipeline refactor #10513

Closed
wants to merge 14 commits into from
4 changes: 2 additions & 2 deletions pipelines/ci-daily.yml
Expand Up @@ -16,10 +16,10 @@ jobs:
- SDK_18362 -equals TRUE
- VS2019 -equals TRUE
steps:
- template: templates/common-Unity2019.yml
- template: templates/common.yml
parameters:
packagingEnabled: false
UnityVersion: $(Unity2019Version)
buildUWPArm64: true

- job: Unity2018Validation
timeoutInMinutes: 120
Expand Down
4 changes: 1 addition & 3 deletions pipelines/pr-2020.yaml
Expand Up @@ -24,9 +24,7 @@ jobs:
# the specific flavors below that are experiencing failures in CI (for example,
# if we're actively working on features that have a lot of churn on underlying
# WMR APIs, buildUWPArm would be a good candidate to re-enable)
buildUWPX86: false
buildUWPArm: false
buildUWPDotNet: false
buildStandalone: true
UnityVersion: $(Unity2020Version)

- template: templates/end.yml
8 changes: 2 additions & 6 deletions pipelines/pr.yaml
Expand Up @@ -23,9 +23,7 @@ jobs:
# the specific flavors below that are experiencing failures in CI (for example,
# if we're actively working on features that have a lot of churn on underlying
# WMR APIs, buildUWPArm would be a good candidate to re-enable)
buildUWPX86: false
buildUWPArm: false
buildUWPDotNet: false
buildStandalone: true
UnityVersion: $(Unity2018Version)

- job: Unity2019Validation
Expand All @@ -40,8 +38,6 @@ jobs:
steps:
- template: templates/common.yml
parameters:
buildUWPX86: false
buildUWPArm: false
buildUWPDotNet: false
buildStandalone: true
UnityVersion: $(Unity2019Version)
- template: templates/end.yml
4 changes: 3 additions & 1 deletion pipelines/templates/ci-common.yml
Expand Up @@ -9,8 +9,10 @@ parameters:
steps:
- template: common.yml
parameters:
buildUWPDotNet: false
UnityVersion: ${{ parameters.UnityVersion }}
buildStandalone: true
buildUWPx86: true
buildUWPArm: true
- template: tasks/versionmetadata.yml
- ${{ if eq(parameters.packagingEnabled, true) }}:
- ${{ if eq(parameters.packageNuGet, true) }}:
Expand Down
20 changes: 0 additions & 20 deletions pipelines/templates/common-Unity2019.yml

This file was deleted.

94 changes: 63 additions & 31 deletions pipelines/templates/common.yml
Expand Up @@ -2,23 +2,31 @@

parameters:
UnityVersion: ""
buildStandalone: true
buildUWPArm: true
buildUWPDotNet: true
buildUWPX86: true
buildStandalone: false
buildUWPx86: false
buildUWPArm: false
buildUWPArm64: false
runTests: true

steps:
- powershell: |
# Module management requires TLS 1.2.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not (Get-InstalledModule -Name UnitySetup)) {
Install-Module -Name UnitySetup -Scope CurrentUser -Force
}
displayName: Install unitysetup.powershell

# Build Standalone x64.
# This must happen before tests run, because if the build fails and tests attempt
# to get run, Unity will hang showing a dialog (even when in batch mode).
# This is the fastest build, since it doesn't produce an AppX.
- ${{ if eq(parameters.buildStandalone, true) }}:
- template: tasks/unitybuild.yml
- template: unity.yaml
parameters:
Arch: 'x64'
Platform: 'Standalone'
UnityVersion: ${{ parameters.UnityVersion }}
BuildTarget: StandaloneWindows64
OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-exe-x64/MixedRealityToolkit.exe

# Tests should run earlier in the process, so that engineers can get test failure
# notifications earlier in the CI process.
Expand All @@ -27,31 +35,55 @@ steps:
parameters:
UnityVersion: ${{ parameters.UnityVersion }}

# Build UWP x86
- ${{ if eq(parameters.buildUWPX86, true) }}:
- template: tasks/unitybuild.yml
# Build UWP.
- ${{ if or(eq(parameters.buildUWPx86, true), eq(parameters.buildUWPArm, true), eq(parameters.buildUWPArm64, true)) }}:
- template: unity.yaml
parameters:
Arch: 'x86'
Platform: 'UWP'
PublishArtifacts: true
UnityVersion: ${{ parameters.UnityVersion }}
BuildTarget: WSAPlayer
OutputPath: $(Agent.TempDirectory)/build/uwp

# Build UWP ARM
- ${{ if eq(parameters.buildUWPArm, true) }}:
- template: tasks/unitybuild.yml
parameters:
Arch: 'arm'
Platform: 'UWP'
PublishArtifacts: true
PackagingDir: 'ARM'
UnityVersion: ${{ parameters.UnityVersion }}
# Build UWP x86.
- ${{ if eq(parameters.buildUWPx86, true) }}:
- template: tasks/build-appx.yaml
parameters:
ProjectName: MixedRealityToolkit
Architectures: [x86]
BuildFolderPath: $(Agent.TempDirectory)/build/uwp
Version: $(MRTKVersion)

# Build UWP x86 .NET backend
- ${{ if eq(parameters.buildUWPDotNet, true) }}:
- template: tasks/unitybuild.yml
parameters:
Arch: 'x86'
Platform: 'UWP'
PublishArtifacts: true
ScriptingBackend: '.NET'
UnityVersion: ${{ parameters.UnityVersion }}
- task: PublishBuildArtifacts@1
displayName: Publish x86 AppX
inputs:
ArtifactName: mrtk-build-x86
PathToPublish: $(Build.ArtifactStagingDirectory)/Apps/uwp-x86

# Build UWP ARM.
- ${{ if eq(parameters.buildUWPArm, true) }}:
- template: tasks/build-appx.yaml
parameters:
ProjectName: MixedRealityToolkit
Architectures: [ARM]
BuildFolderPath: $(Agent.TempDirectory)/build/uwp
Version: $(MRTKVersion)

- task: PublishBuildArtifacts@1
displayName: Publish ARM AppX
inputs:
ArtifactName: mrtk-build-arm
PathToPublish: $(Build.ArtifactStagingDirectory)/Apps/uwp-arm

# Build UWP ARM64.
- ${{ if eq(parameters.buildUWPArm64, true) }}:
- template: tasks/build-appx.yaml
parameters:
ProjectName: MixedRealityToolkit
Architectures: [ARM64]
BuildFolderPath: $(Agent.TempDirectory)/build/uwp
Version: $(MRTKVersion)

- task: PublishBuildArtifacts@1
displayName: Publish ARM64 AppX
inputs:
ArtifactName: mrtk-build-arm64
PathToPublish: $(Build.ArtifactStagingDirectory)/Apps/uwp-arm64
6 changes: 4 additions & 2 deletions pipelines/templates/tasks/assetretargeting.yml
Expand Up @@ -5,9 +5,11 @@ parameters:

steps:
- powershell: |
# Some machines require that the protocol be explicitly set to Tls12
# Module management requires TLS 1.2.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name UnitySetup -Scope CurrentUser -Force
if (-not (Get-InstalledModule -Name UnitySetup)) {
Install-Module -Name UnitySetup -Scope CurrentUser -Force
}
displayName: Install unitysetup.powershell

- powershell: |
Expand Down
36 changes: 36 additions & 0 deletions pipelines/templates/tasks/build-appx.yaml
@@ -0,0 +1,36 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# [Template] Build appx from a Unity-built sln.

parameters:
- name: ProjectName
type: string

- name: Architectures
type: object
default: []

- name: BuildFolderPath
type: string

- name: Version
type: string

steps:
- ${{ each arch in parameters.Architectures }}:
- task: MSBuild@1
displayName: Build ${{ arch }} AppX
inputs:
solution: ${{ parameters.BuildFolderPath }}/${{ parameters.ProjectName }}.sln
platform: ${{ arch }}
configuration: Master

- task: CopyFiles@2
displayName: Copy ${{ arch }} AppX to artifacts staging directory
inputs:
${{ if eq(arch, 'x86') }}:
sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_${{ parameters.Version }}.0_Win32_Master_Test
${{ if not(eq(arch, 'x86')) }}:
sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_${{ parameters.Version }}.0_${{ arch }}_Master_Test
targetFolder: $(Build.ArtifactStagingDirectory)/Apps/uwp-${{ arch }}
68 changes: 68 additions & 0 deletions pipelines/templates/tasks/build-unity.yaml
@@ -0,0 +1,68 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# [Template] Build project inside Unity.

parameters:
- name: UnityVersion
type: string

- name: BuildTarget
type: string
values:
- StandaloneWindows64
- WSAPlayer
- Android

- name: CommandLineBuildMethod
type: string

- name: PathToProject
type: string

- name: OutputPath
type: string

- name: AdditionalArguments
type: string
default: ''

steps:
- powershell: |
$logFile = Join-Path $(Agent.TempDirectory) "build_${{ parameters.BuildTarget }}.log"
New-Item -Path $logFile -ItemType File -Force
$proc = Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -PassThru -LogFile $logFile -BuildTarget ${{ parameters.BuildTarget }} -OutputPath ${{ parameters.OutputPath }} -AdditionalArguments "${{ parameters.AdditionalArguments }}"
$ljob = Start-Job -ScriptBlock { param($log) Get-Content "$log" -Wait } -ArgumentList $logFile

while (-not $proc.HasExited -and $ljob.HasMoreData) {
Receive-Job $ljob
Start-Sleep -Milliseconds 200
}

Stop-Job $ljob
Remove-Job $ljob
Stop-Process $proc

Write-Output '====================================================='
Write-Output ' Unity Build Player Finished '
Write-Output '====================================================='

if (Test-Path $logFile) {
Write-Output '====================================================='
Write-Output ' Begin Unity Player Log '
Write-Output '====================================================='

Get-Content $logFile

Write-Output '====================================================='
Write-Output ' End Unity Player Log '
Write-Output '====================================================='
}
else {
Write-Output 'Unity Player log missing!'
}

if ($proc.ExitCode -ne 0) {
exit $proc.ExitCode
}
displayName: Build ${{ parameters.BuildTarget }}
6 changes: 4 additions & 2 deletions pipelines/templates/tasks/generate-projects.yml
Expand Up @@ -5,9 +5,11 @@ parameters:

steps:
- powershell: |
# Some machines require that the protocol be explicitly set to Tls12
# Module management requires TLS 1.2.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name UnitySetup -Scope CurrentUser -Force
if (-not (Get-InstalledModule -Name UnitySetup)) {
Install-Module -Name UnitySetup -Scope CurrentUser -Force
}
displayName: Install unitysetup.powershell

- powershell: |
Expand Down