-
Notifications
You must be signed in to change notification settings - Fork 92
/
azure-pipelines.yml
384 lines (341 loc) · 13.4 KB
/
azure-pipelines.yml
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
# See License in the project root for license information.
# ------------------------------------------------------------------------------
#
# 1. Validates the repository's pull requests and commits
# 2. Builds and publishes release artifacts
# 3. This pipeline will be extended to the OneESPT template
name: $(date:yyyyMMdd)$(rev:.r)
pr:
branches:
include:
- master
- dev
- feature/*
- task/*
- fix/*
paths:
exclude:
- .github/*
- .vscode/*
- build/*
- .gitignore
- .prettierrc
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- README.md
- azure-pipelines.yml
- package-lock.json
variables:
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isDev: $[eq(variables['Build.SourceBranch'], 'refs/heads/dev')]
trigger:
branches:
include:
- master
- dev
- feature/*
- task/*
- fix/*
paths:
exclude:
- .github/*
- .vscode/*
- build/*
- .gitignore
- .prettierrc
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- README.md
- azure-pipelines.yml
- package-lock.json
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
- repository: ReleasePipelines
type: git
name: "Graph Developer Experiences/release-pipelines"
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
sdl:
sourceRepositoriesToScan:
exclude:
- repository: ReleasePipelines
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: BuildTestAndPublish
jobs:
- job: One
displayName: "Build and test validation"
steps:
- task: ComponentGovernanceComponentDetection@0
inputs:
scanType: "Register"
verbosity: "Verbose"
alertWarningLevel: "High"
ignoreDirectories: ".github,.vscode/"
- task: NodeTool@0
inputs:
versionSpec: "18.16.x"
displayName: "Install Node.js"
- script: |
npm install
displayName: "npm install"
- script: |
npm run lint
displayName: "Runs linting checks"
- script: |
npm test
displayName: "Runs Unit tests"
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: "JUnit"
testResultsFiles: "test-report.xml"
displayName: "Publish Test Results"
- script: |
npm run build
displayName: "Run build"
- job: Two
displayName: "Run playwright tests"
condition: eq(variables['isDev'], 'true')
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.16.x"
displayName: "Install npm"
- script: |
npm install
displayName: "npm install"
- script: |
npm install -D @playwright/test
npx playwright install-deps
displayName: "Install playwright dependancies"
- script: |
npx playwright install
displayName: "Install playwright"
- script: |
npm run test-playwright-accessibility
displayName: "Run accessibility tests"
- script: |
set CI=true
npm run test-playwright
env:
REACT_APP_CLIENT_ID: $(REACT_APP_PLAYWRIGHT_TEST_CLIENT_ID)
REACT_APP_INSTRUMENTATION_KEY: $(REACT_APP_STAGING_INSTRUMENTATION_KEY)
REACT_APP_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_STAGING_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NOMINATION_PERIOD: $(REACT_APP_NOMINATION_PERIOD)
REACT_APP_COOLDOWN_PERIOD: $(REACT_APP_COOLDOWN_PERIOD)
REACT_APP_USAGE_TIME: $(REACT_APP_USAGE_TIME)
PLAYWRIGHT_TESTS_BASE_URL: $(PLAYWRIGHT_TESTS_BASE_URL)
PLAYWRIGHT_TESTS_USERNAME: $(PLAYWRIGHT_TESTS_USERNAME)
PLAYWRIGHT_TESTS_PASSWORD: $(PLAYWRIGHT_TESTS_PASSWORD)
displayName: "Run playwright tests"
templateContext:
outputs:
- output: pipelineArtifact
displayName: 'Publish test results'
condition: always()
targetPath: $(System.DefaultWorkingDirectory)/playwright-report
artifactName: playwright-report
- job: Three
displayName: "Publish artifacts"
dependsOn: One
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.16.x"
displayName: "Install Node.js"
- script: |
npm install
displayName: "npm install"
- script: |
npm run build
env:
REACT_APP_CLIENT_ID: $(REACT_APP_STAGING_CLIENT_ID)
REACT_APP_INSTRUMENTATION_KEY: $(REACT_APP_STAGING_INSTRUMENTATION_KEY)
REACT_APP_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_STAGING_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NOMINATION_PERIOD: $(REACT_APP_NOMINATION_PERIOD)
REACT_APP_COOLDOWN_PERIOD: $(REACT_APP_COOLDOWN_PERIOD)
REACT_APP_USAGE_TIME: $(REACT_APP_USAGE_TIME)
REACT_APP_DEVX_API_URL: $(REACT_APP_DEVX_API_URL)
REACT_APP_MIGRATION_PARAMETER: $(REACT_APP_MIGRATION_PARAMETER)
displayName: "Build static assets for staging"
- task: PowerShell@2
displayName: "Set version-number"
condition: and(succeeded(), eq(variables['isMaster'], 'true'))
inputs:
targetType: "inline"
script: |
$lernaPath = "$Env:BUILD_SOURCESDIRECTORY\package.json"
$json = Get-Content "$lernaPath" | Out-String | ConvertFrom-Json
$versionNumber = $json.version;
Write-Host "Setting the build number variable to '$versionNumber'."
Write-Host "##vso[build.updatebuildnumber]$versionNumber"
- script: |
npm run build
condition: and(succeeded(), eq(variables['isMaster'], 'true'))
env:
REACT_APP_CLIENT_ID: $(REACT_APP_PROD_CLIENT_ID)
REACT_APP_INSTRUMENTATION_KEY: $(REACT_APP_INSTRUMENTATION_KEY)
REACT_APP_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID: $(REACT_APP_NPS_FEEDBACK_CAMPAIGN_ID)
REACT_APP_NOMINATION_PERIOD: $(REACT_APP_NOMINATION_PERIOD)
REACT_APP_COOLDOWN_PERIOD: $(REACT_APP_COOLDOWN_PERIOD)
REACT_APP_USAGE_TIME: $(REACT_APP_USAGE_TIME)
REACT_APP_DEVX_API_URL: $(REACT_APP_DEVX_API_URL)
REACT_APP_MIGRATION_PARAMETER: $(REACT_APP_MIGRATION_PARAMETER)
displayName: "Build static assets for prod"
- task: PowerShell@2
displayName: "Create _manifest directory"
inputs:
targetType: "inline"
script: |
$manifestPath = "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/_manifest"
mkdir -p $manifestPath
Write-Host "Created directory '$manifestPath'."
- task: ManifestGeneratorTask@0
inputs:
ManifestDirPath: "$(System.DefaultWorkingDirectory)/_manifest"
BuildComponentPath: "$(System.DefaultWorkingDirectory)/build"
PackageName: "graph-explorer-v2"
PackageVersion: "$(Build.UpdateBuildNumber)"
- task: CopyFiles@1
displayName: "Copy manifest files to artifact staging dir: manifest"
inputs:
SourceFolder: "$(System.DefaultWorkingDirectory)/_manifest"
TargetFolder: "$(Build.ArtifactStagingDirectory)/manifest"
- task: CopyFiles@1
displayName: "Copy files to: $(Build.ArtifactStagingDirectory)/build"
inputs:
SourceFolder: "$(System.DefaultWorkingDirectory)/build"
TargetFolder: "$(Build.ArtifactStagingDirectory)/build"
- task: DeleteFiles@1
inputs:
contents: node_modules
displayName: "Delete node_modules"
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/build'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/build/graph-explorer.zip'
replaceExistingArchive: true
templateContext:
outputs:
- output: pipelineArtifact
displayName: 'Publish Artifact: manifest'
targetPath: "$(Build.ArtifactStagingDirectory)/manifest"
artifactName: manifest
- output: pipelineArtifact
displayName: 'Publish Artifact: drop'
targetPath: "$(build.ArtifactStagingDirectory)/build"
artifactName: drop
- template: pipelines/templates/checkout-and-copy-1es.yml@ReleasePipelines
parameters:
directory: 'microsoft-graph-explorer-v4'
repoName: ReleasePipelines
dependsOn: ['Three']
- stage: DeployStaging
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/dev'), succeeded())
dependsOn: BuildTestAndPublish
jobs:
- deployment: staging
templateContext:
type: releaseJob
isProduction: false
inputs:
- input: pipelineArtifact
artifactName: drop
targetPath: '$(Build.ArtifactStagingDirectory)/drop'
environment: graphexplorer-staging
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Deploy to graphTryIt-staging copy'
inputs:
azureSubscription: 'Federated GE Managed Identity Connection'
appType: webApp
appName: 'graphTryIt-staging'
package: '$(Build.ArtifactStagingDirectory)/drop'
- task: AzureFileCopy@6
displayName: 'Deploy to dev storage -tst'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/drop'
azureSubscription: 'Federated GE Managed Identity Connection'
Destination: AzureBlob
storage: graphexplorerstorage
ContainerName: deployments
BlobPrefix: 'vendor/bower_components/explorer-v2/build'
- stage: DeployProduction
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/master'), succeeded())
dependsOn: BuildTestAndPublish
jobs:
- deployment: production
templateContext:
type: releaseJob
isProduction: true
inputs:
- input: pipelineArtifact
artifactName: drop
targetPath: '$(Build.ArtifactStagingDirectory)/drop'
environment: graphexplorer-production
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Azure Web App Deploy: graphTryIt'
inputs:
azureSubscription: 'Federated GE Managed Identity Connection'
appType: webApp
appName: graphTryIt
package: '$(Build.ArtifactStagingDirectory)/drop'
- task: AzureFileCopy@6
displayName: 'Deploy to portal - staging'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/drop/*'
azureSubscription: 'Federated GE-Portals Managed Identity Connection'
Destination: AzureBlob
storage: graphstagingblobstorage
ContainerName: staging
BlobPrefix: 'vendor/bower_components/explorer$(Build.BuildNumber)/build'
- task: AzureFileCopy@6
displayName: 'Deploy to portal - production'
inputs:
SourcePath: '$(Build.ArtifactStagingDirectory)/drop/*'
azureSubscription: 'Federated GE-Portals Managed Identity Connection'
Destination: AzureBlob
storage: graphprodblobstorage
ContainerName: prod
BlobPrefix: 'vendor/bower_components/explorer$(Build.BuildNumber)/build'
- task: ArchiveFiles@2
displayName: 'Archive built assets'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/drop/'
archiveFile: '$(Build.ArtifactStagingDirectory)/graph-explorer-$(Build.BuildNumber)-$(Build.BuildId).zip'
- task: GitHubRelease@1
displayName: 'GitHub release (v$(Build.BuildNumber)-$(Build.BuildId))'
inputs:
gitHubConnection: 'GitHub - thewahome'
action: edit
tag: 'v$(Build.BuildNumber)'
title: 'Graph Explorer - v$(Build.BuildNumber)'
assets: '$(Build.ArtifactStagingDirectory)/*.zip'
changeLogType: issueBased