-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
366 lines (317 loc) · 11.3 KB
/
azure-pipelines.yml
File metadata and controls
366 lines (317 loc) · 11.3 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
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
trigger:
batch: 'true'
branches:
include:
- master
- hotfix/*
- development
- development-*
resources:
pipelines:
- pipeline: 'intent'
source: 'Intent Architect'
trigger:
branches:
include:
- 'refs/tags/publish/client/*'
variables:
- group: 'Intent Architect Credentials'
- group: 'NuGet.org API Keys'
- group: 'Pipeline Agent Pool Names'
- name: 'isDevelopment'
value: $[or(startsWith(variables['Build.SourceBranch'], 'refs/heads/development-'), in(variables['Build.SourceBranch'], 'refs/heads/development'))]
- name: 'isMaster'
value: $[in(variables['Build.SourceBranch'], 'refs/heads/master')]
- name: 'isHotfix'
value: $[in(variables['Build.SourceBranch'], 'refs/heads/hotfix')]
- name: 'vstsFeed'
value: '4bb4c1b9-5b56-4972-8bac-0ad3fa64204e/intentarchitect-feed'
- name: 'vstsFeedUrl'
value: 'https://pkgs.dev.azure.com/intentarchitect/4bb4c1b9-5b56-4972-8bac-0ad3fa64204e/_packaging/intentarchitect-feed/nuget/v3/index.json'
- name: 'targetsToBuild'
value: '**/*.sln'
- name: 'intent-solution'
value: 'Tests/Intent.Modules.Java.Tests.isln'
- name: 'intent-module-solution'
value: 'Modules/Intent.Modules.Java.isln'
- name: 'warning-logging-command'
value: '##vso[task.logissue type=warning;]{@m} {@x}\n'
- name: 'error-logging-command'
value: '##vso[task.logissue type=error;]{@m} {@x}\n'
- name: 'buildStamp'
value: $[ format('{0:yyyyMMddHHmmss}', pipeline.startTime) ]
pool:
name: $(BuildPool.AzureManaged)
demands:
- 'ImageOverride -equals ubuntu-latest'
steps:
- task: CmdLine@2
inputs:
script: |
git config --global core.longpaths true
- checkout: 'self'
clean: true
persistCredentials: 'true'
fetchDepth: '1'
submodules: 'recursive'
- task: PowerShell@2
displayName: 'Pre-build validations'
inputs:
pwsh: true
filePath: 'PipelineScripts/pre-build-validations.ps1'
arguments: >
-ModulesFolder
"Modules"
-TestsFolder
"Tests"
- task: UseDotNet@2
displayName: 'Install latest .NET 8 SDK'
inputs:
version: '8.x'
# Required for the Software Factory CLI
- task: UseDotNet@2
displayName: 'Install latest .NET 9 SDK'
inputs:
version: '9.x'
- task: UseDotNet@2
displayName: 'Install latest .NET 10 SDK'
inputs:
version: '10.x'
# Required for entry in NuGet.Config that is generated as part of 'dotnet pack'.
- task: NuGetAuthenticate@1
# We pack upfront as projects may rely on NuGet packages from this same solution
- task: PowerShell@2
displayName: 'dotnet pack'
inputs:
pwsh: true
failOnStderr: true
ignoreLASTEXITCODE: true
filePath: 'PipelineScripts/dotnet-pack-all.ps1'
arguments: >
-dotnetPackOutputDirectory $(Build.ArtifactStagingDirectory)
-vstsFeedUrl $(vstsFeedUrl)
# Push the NuGet packages to the DevOps artifact feed so that they're available to this build and other pipelines
- task: DotNetCoreCLI@2
displayName: 'Push Intent Nuget Packages to DevOps Artifacts'
condition: and(succeeded(), in('True', variables.isMaster, variables.isHotfix, variables.isDevelopment))
inputs:
command: 'custom'
custom: 'nuget'
arguments: >
push $(Build.ArtifactStagingDirectory)/*.nupkg
-s $(vstsFeedUrl)
-k none
--skip-duplicate
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
env:
DOTNET_NOLOGO: '1'
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: $(vstsFeed)
projects: $(targetsToBuild)
restoreArguments: >
--no-cache
- task: PowerShell@2
displayName: 'Update Project URLs in imodspecs'
condition: and(succeeded(), in('True', variables.isMaster))
inputs:
targetType: 'inline'
pwsh: true
script: |
Get-ChildItem -Recurse -Filter "*.imodspec" | ForEach-Object {
(Get-Content $_.FullName) -replace '/development/', '/master/' | Set-Content $_.FullName
}
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
env:
DOTNET_NOLOGO: 1
inputs:
command: 'build'
projects: $(targetsToBuild)
arguments: >
--no-restore
-p:IntentModuleOutputPath=$(Build.ArtifactStagingDirectory)
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
env:
DOTNET_NOLOGO: 1
inputs:
command: 'test'
publishTestResults: false
projects: $(targetsToBuild)
arguments: >
--results-directory $(Agent.TempDirectory)/TestResults
--diag:$(Agent.TempDirectory)/TestResults/diag.log
--logger trx
--blame-crash
--blame-hang
--blame-hang-timeout:10m
--no-build
--filter Requirement!=CosmosDB
- task: PublishPipelineArtifact@1
displayName: 'Publish test results as pipeline artifact (on failure)'
condition: failed()
inputs:
targetPath: '$(Agent.TempDirectory)/TestResults'
artifact: 'test-results-$(buildStamp)'
publishLocation: 'pipeline'
- task: PublishTestResults@2
displayName: 'Publish test results'
condition: always()
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '**/*.trx'
searchFolder: '$(Agent.TempDirectory)/TestResults'
- task: PowerShell@2
displayName: 'Add repositories (modules)'
inputs:
targetType: 'inline'
pwsh: true
script: >
./PipelineScripts/update-repositories.ps1
-BuildArtifactStagingDirectory
"$(Build.ArtifactStagingDirectory)"
-SourceBranch
"$(Build.SourceBranch)"
-IslnRelativePath
"$(intent-module-solution)"
- task: PowerShell@2
displayName: 'Add repositories (tests)'
inputs:
targetType: 'inline'
pwsh: true
script: >
./PipelineScripts/update-repositories.ps1
-BuildArtifactStagingDirectory
"$(Build.ArtifactStagingDirectory)"
-SourceBranch
"$(Build.SourceBranch)"
-IslnRelativePath
"$(intent-solution)"
- task: PowerShell@2
displayName: 'Install Intent SF CLI'
inputs:
targetType: 'inline'
pwsh: true
script: |
$toolPath = "$(System.DefaultWorkingDirectory)/intent-cli-tool"
$nightly = '$(Build.SourceBranch)' -like 'refs/heads/development-*' ? '.nightly' : ''
$nightly = '.nightly'
if (Test-Path $toolPath)
{
Remove-Item -Recurse -Force $toolPath
}
# While 4.7 nightly is being installed, changing this to use latest non-nightly CLI.
# dotnet tool install Intent.SoftwareFactory.CLI$nightly --prerelease --tool-path $toolPath
dotnet tool install Intent.SoftwareFactory.CLI --prerelease --tool-path $toolPath
- task: PowerShell@2
displayName: 'Run SF CLI on modules solution'
env:
INTENT_USER: $(intent-architect-user)
INTENT_PASS: $(intent-architect-password)
INTENT_MODULE_SOLUTION_PATH: $(intent-module-solution)
inputs:
targetType: 'inline'
pwsh: true
script: |
$toolPath = "$(System.DefaultWorkingDirectory)/intent-cli-tool"
& "$toolPath/intent-cli" ensure-no-outstanding-changes -- "$Env:INTENT_USER" "$Env:INTENT_PASS" "$Env:INTENT_MODULE_SOLUTION_PATH"
- task: PowerShell@2
displayName: 'Run SF CLI on tests solution'
env:
INTENT_USER: $(intent-architect-user)
INTENT_PASS: $(intent-architect-password)
INTENT_SOLUTION_PATH: $(intent-solution)
inputs:
targetType: 'inline'
pwsh: true
script: |
$toolPath = "$(System.DefaultWorkingDirectory)/intent-cli-tool"
& "$toolPath/intent-cli" ensure-no-outstanding-changes --check-deviations -- "$Env:INTENT_USER" "$Env:INTENT_PASS" "$Env:INTENT_SOLUTION_PATH"
- task: PowerShell@2
displayName: 'Filter artifacts to publish'
condition: and(succeeded(), in('True', variables.isMaster, variables.isHotfix, variables.isDevelopment))
inputs:
targetType: inline
pwsh: true
script: |
$isPreReleaseRegex = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
$isMaster = '$(Build.SourceBranch)' -eq 'refs/heads/master'
$artifactsFolder = '$(Build.ArtifactStagingDirectory)'
Write-Host
Write-Host "Is Master: $isMaster"
Write-Host
Write-Host "All files:"
Get-ChildItem "$artifactsFolder" | ForEach-Object { Write-Host $_.Name }
$filesToRemove = Get-ChildItem "$artifactsFolder/*.*" | Where-Object { (-Not $isMaster -And ($_.Name -NotMatch $isPreReleaseRegex)) }
Write-Host
Write-Host "Deleting the following files to prevent them being published:"
$filesToRemove | ForEach-Object { Write-Host $_.Name }
$filesToRemove | Remove-Item
Write-Host
Write-Host "Remaining files:"
Get-ChildItem "$artifactsFolder" | ForEach-Object { Write-Host $_.Name }
- task: PowerShell@2
displayName: 'Install Module Server Client CLI'
condition: and(succeeded(), in('True', variables.isMaster, variables.isHotfix, variables.isDevelopment))
inputs:
targetType: 'inline'
pwsh: true
script: |
dotnet tool install Intent.ModuleServer.Client.CLI --global --prerelease
- task: PowerShell@2
displayName: 'Publish modules'
condition: and(succeeded(), in('True', variables.isMaster, variables.isHotfix, variables.isDevelopment))
env:
DOTNET_NOLOGO: '1'
# Avoid issues when attempting to run on environment without older .NET runtime version available:
# https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior
DOTNET_ROLL_FORWARD: 'LatestMajor'
inputs:
targetType: inline
pwsh: true
script: |
$artifactsFolder = '$(Build.ArtifactStagingDirectory)'
$sourceBranch = '$(Build.SourceBranch)'
$isDevWithVersion = $sourceBranch -like 'refs/heads/development-*'
$serverUrl = $isDevWithVersion ? 'https://dev-modules.intentarchitect.com/' : 'https://app-module-server-prod-zanorth-001.azurewebsites.net/'
$apiKey = '$(intent-architect-module-server-api-key)'
$files = (Get-ChildItem "$artifactsFolder/*.*");
$number = 0
foreach ($file in $files) {
$number++
Write-Host ""
Write-Host "Processing $($file.Name) ($number of $($files.Length))..."
if (-not $isDevWithVersion -and $file.Name -like "*-alpha.*.imod") {
$expression = "module-server-client-cli `"upload-module`" `"$serverUrl`" `"$apiKey`" `"$($file.FullName)`" --unlisted"
Write-Host "Invoking $($expression.Replace($apiKey, "****"))..."
Invoke-Expression $expression
continue
}
if ($file.Name -like "*.imod") {
$expression = "module-server-client-cli `"upload-module`" `"$serverUrl`" `"$apiKey`" `"$($file.FullName)`""
Write-Host "Invoking $($expression.Replace($apiKey, "****"))..."
Invoke-Expression $expression
continue
}
if ($file.Name -like "*.iat") {
$expression = "module-server-client-cli `"upload-application-template`" `"$serverUrl`" `"$apiKey`" `"$($file.FullName)`""
Write-Host "Invoking $($expression.Replace($apiKey, "****"))..."
Invoke-Expression $expression
continue
}
Write-Host "Not applicable, skipped."
}
- task: DotNetCoreCLI@2
displayName: 'Push *.nupkg to nuget.org (Final Release)'
condition: and(succeeded(), in('True', variables.isMaster, variables.isHotfix))
inputs:
command: 'custom'
custom: 'nuget'
arguments: >
push $(Build.ArtifactStagingDirectory)/*.nupkg
-s https://api.nuget.org/v3/index.json
-k $(nuget-api-key-intentarchitect)
--skip-duplicate