/
azure-pipelines.yml
264 lines (232 loc) · 8.65 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
# ------------------------------------------------------------------------------
# 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
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: stage
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
condition: and(succeeded(), or(eq(variables['isMaster'], 'true'), eq(variables['isDev'], 'true')))
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_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_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"
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