Repository navigation
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
199 lines (188 loc) · 8.66 KB
/
Copy pathazure-pipelines.yml
File metadata and controls
199 lines (188 loc) · 8.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
trigger:
- master
pr:
autoCancel: true
branches:
include:
- master
stages:
# Full multi-TFM build + unit tests. The unit test project targets .NET Framework
# (net462/net472) as well as net8/net9/net10, so it needs the complete multi-TFM
# solution build. E2E and managed-identity tests run in their own stages below.
- stage: Build
displayName: 'Build & Unit Tests'
jobs:
- job: PR_build
variables:
# Load the LabAuth client certificate from the local certificate store
# (installed into LocalMachine/My by template-install-dependencies.yaml)
# instead of the msidlabs KeyVault. Microsoft-hosted agents have no managed
# identity that can read the KeyVault, so DefaultAzureCredential would fail.
# The official OneBranch/Wilson pipeline does not set this and keeps using
# the KeyVault source.
UseLabAuthCertFromStore: true
pool:
vmImage: 'windows-2022'
demands:
- msbuild
- visualstudio
steps:
- template: build/template-install-dependencies.yaml
- template: build/template-build.yaml
- template: build/template-test-unit.yaml
- task: BuildQualityChecks@10
displayName: 'Check Warnings'
inputs:
checkWarnings: true
warningFailOption: 'build'
showStatistics: true
# Integration tests only depend on .NET 8, so build just that project and run them
# in parallel with the full Build stage (dependsOn: [] -> no dependency on Build).
- stage: IntegrationTests
displayName: 'Integration Tests (.NET 8)'
dependsOn: []
jobs:
- job: IntegrationTests
variables:
UseLabAuthCertFromStore: true
pool:
vmImage: 'windows-2022'
demands:
- msbuild
- visualstudio
steps:
- template: build/template-install-dependencies.yaml
- template: build/template-build-test-project.yaml
parameters:
Project: 'tests/Microsoft.Identity.Web.Test.Integration/Microsoft.Identity.Web.Test.Integration.csproj'
TargetFramework: 'net8.0'
- template: build/template-test-integration.yaml
# Browser/host E2E tests (excluding managed identity). The E2E projects target
# net8.0 and pull their sample apps in as project references, so build just those
# projects and run in parallel with Build (dependsOn: []).
- stage: E2ETests
displayName: 'E2E Tests (.NET 8)'
dependsOn: []
jobs:
- job: E2ETests
variables:
UseLabAuthCertFromStore: true
pool:
vmImage: 'windows-2022'
demands:
- msbuild
- visualstudio
steps:
- template: build/template-install-dependencies.yaml
- template: build/template-build-test-project.yaml
parameters:
Project: 'tests/E2E Tests/WebAppUiTests/WebAppUiTests.csproj'
TargetFramework: 'net8.0'
- template: build/template-build-test-project.yaml
parameters:
Project: 'tests/E2E Tests/TokenAcquirerTests/TokenAcquirerTests.csproj'
TargetFramework: 'net8.0'
- template: build/template-test-e2e.yaml
parameters:
# Exclude managed-identity E2E tests: they require an MI assigned to the
# host (IMDS), which Microsoft-hosted agents do not have. They run in the
# ManagedIdentityE2E stage below on the MISEManagedIdentity VM pool.
e2eTestFilterCriteria: 'Category!=MI_E2E'
# Managed-identity E2E tests require a VM with an assigned managed identity (IMDS),
# which Microsoft-hosted agents do not have. They run on the MISEManagedIdentity VM pool and
# build only the E2E project (.NET 8), independent of the Build stage.
- stage: ManagedIdentityE2E
displayName: 'Managed Identity E2E (MISEManagedIdentity)'
dependsOn: []
jobs:
- job: ManagedIdentityE2E
pool:
name: 'MISEManagedIdentity'
steps:
- template: build/template-run-managed-identity-e2e-tests.yaml
parameters:
TargetFramework: 'net8.0'
# App Service managed-identity coverage on .NET Framework (net48): deploys the
# ManagedIdentityWebApp dev app to an Easy Auth-protected App Service and verifies system- and
# user-assigned managed identity token acquisition through Microsoft.Identity.Web. Runs on a
# Microsoft-hosted agent (the managed identity lives on the App Service, not the agent) and is
# gated by the RunManagedIdentityWebAppDeploy variable so normal PR builds are unaffected.
- stage: ManagedIdentityWebAppNetFx
displayName: 'MI WebApp net48 (App Service, Easy Auth)'
dependsOn: []
jobs:
- job: ManagedIdentityWebAppNetFx
pool:
vmImage: 'windows-2022'
demands:
- msbuild
- visualstudio
condition: and(succeeded(), eq(variables['RunManagedIdentityWebAppDeploy'], 'true'))
steps:
- template: build/template-deploy-managed-identity-webapp-and-test.yaml
# Live benchmarks use lab credentials and must not run on pull-request builds.
- stage: Performance
displayName: 'Performance (.NET 8, certificate)'
dependsOn: []
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.Reason'], 'Manual')))
jobs:
- job: TokenAcquisitionBenchmark
variables:
BenchmarkCertificateSubject: 'CN=LabAuth.MSIDLab.com'
pool:
vmImage: 'windows-2022'
steps:
- template: build/template-install-dependencies.yaml
- powershell: |
$ErrorActionPreference = 'Stop'
$now = [DateTime]::UtcNow
$certificate = Get-ChildItem -Path 'Cert:\LocalMachine\My' |
Where-Object {
$_.Subject -eq $env:BENCHMARK_CERTIFICATE_SUBJECT -and
$_.NotBefore.ToUniversalTime() -le $now -and
$_.NotAfter.ToUniversalTime() -gt $now
} |
Sort-Object -Property NotBefore -Descending |
Select-Object -First 1
if ($null -eq $certificate) {
throw "No currently valid benchmark certificate with subject '$env:BENCHMARK_CERTIFICATE_SUBJECT' was found."
}
if (-not $certificate.HasPrivateKey) {
throw 'The benchmark certificate does not have a private key.'
}
Write-Host "Using benchmark certificate $($certificate.Subject), expires $($certificate.NotAfter.ToUniversalTime().ToString('o'))."
displayName: 'Validate benchmark certificate'
env:
BENCHMARK_CERTIFICATE_SUBJECT: $(BenchmarkCertificateSubject)
- powershell: |
$ErrorActionPreference = 'Stop'
$artifactsDirectory = Join-Path (Get-Location) 'BenchmarkDotNet.Artifacts'
New-Item -ItemType Directory -Path $artifactsDirectory -Force | Out-Null
Write-Host '##vso[task.setvariable variable=BenchmarkStarted]true'
dotnet run --configuration Release --framework net8.0 -- --filter 'Benchmarks.TokenAcquisitionBenchmark.*' --exporters json
if ($LASTEXITCODE -ne 0) {
throw "Token acquisition benchmarks failed with exit code $LASTEXITCODE."
}
$reportPath = Join-Path $artifactsDirectory 'results\Benchmarks.TokenAcquisitionBenchmark-report-full-compressed.json'
$report = Get-Content -LiteralPath $reportPath -Raw | ConvertFrom-Json
$results = @($report.Benchmarks)
if ($results.Count -ne 2 -or @($results | Where-Object { $null -eq $_.Statistics -or $_.Statistics.N -le 0 -or $_.Statistics.Mean -le 0 }).Count -ne 0) {
throw 'Both token acquisition benchmarks must produce measurements.'
}
$summaryPath = Join-Path $artifactsDirectory 'results\Benchmarks.TokenAcquisitionBenchmark-report-github.md'
if (-not (Test-Path -LiteralPath $summaryPath)) {
throw 'The benchmark summary report was not generated.'
}
Write-Host "##vso[task.uploadsummary]$summaryPath"
displayName: 'Run token acquisition benchmarks'
workingDirectory: '$(Build.SourcesDirectory)\benchmark'
env:
AzureAd__ClientCredentials__0__SourceType: StoreWithDistinguishedName
AzureAd__ClientCredentials__0__CertificateStorePath: LocalMachine/My
AzureAd__ClientCredentials__0__CertificateDistinguishedName: $(BenchmarkCertificateSubject)
- task: PublishPipelineArtifact@1
displayName: 'Publish benchmark reports and logs'
condition: and(succeededOrFailed(), eq(variables['BenchmarkStarted'], 'true'))
inputs:
targetPath: '$(Build.SourcesDirectory)\benchmark\BenchmarkDotNet.Artifacts'
artifact: 'token-acquisition-benchmarks'