-
Notifications
You must be signed in to change notification settings - Fork 9
/
azure-pipelines.yml
307 lines (264 loc) · 9.44 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
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: '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.Tests.isln'
- name: 'intent-module-solution'
value: 'Modules/Intent.Modules.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'
pool:
name: $(BuildPool.AzureManaged)
demands:
- 'ImageOverride -equals ubuntu-latest'
steps:
- task: CmdLine@2
inputs:
script: |
git config --global core.longpaths true
- checkout: 'self'
persistCredentials: 'true'
fetchDepth: '1'
submodules: 'recursive'
- 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: PowerShell@2
displayName: 'Imodspec validation'
inputs:
pwsh: true
filePath: 'PipelineScripts/pre-build-validation.ps1'
arguments: 'true'
- task: PowerShell@2
displayName: 'Check TypeScript version'
inputs:
targetType: inline
script: |
Write-Host "Install TypeScript:"
npm install -g typescript
Write-Host "Check TypeScript version:"
tsc --version
- task: PowerShell@2
displayName: 'Compile Designer Macro TypeScript files'
inputs:
targetType: inline
script: |
cd DesignerMacros/src
./compile-all.ps1
# 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: NuGetCommand@2
displayName: 'Push Intent Nuget Packages to DevOps Artifacts'
condition: and(succeeded(), in('True', variables.isMaster, variables.isDevelopment))
inputs:
command: 'push'
feedsToUse: 'select'
includeNuGetOrg: false
publishVstsFeed: $(vstsFeed)
allowPackageConflicts: true
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'internal'
- 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)
# Run this check as early as possible as devs will forget to do this and early feedback is useful.
- task: PowerShell@2
displayName: 'Template Testing Validation'
inputs:
targetType: 'inline'
pwsh: true
script: ./PipelineScripts/pre-template-test-validation.ps1 "$(Build.ArtifactStagingDirectory)" "$(intent-module-solution)" "$(intent-solution)"
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
env:
DOTNET_NOLOGO: 1
inputs:
command: 'test'
projects: $(targetsToBuild)
arguments: >
--no-build
--filter Requirement!=CosmosDB
- task: PowerShell@2
displayName: 'Install Intent SF CLI'
inputs:
targetType: 'inline'
pwsh: true
script: dotnet tool install Intent.SoftwareFactory.CLI --global --prerelease
- task: PowerShell@2
displayName: 'Run SF CLI on module 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: 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: intent-cli ensure-no-outstanding-changes "$Env:INTENT_USER" "$Env:INTENT_PASS" "$Env:INTENT_SOLUTION_PATH" --check-deviations
- task: PowerShell@2
displayName: 'Filter artifacts to publish'
condition: and(succeeded(), in('True', variables.isMaster, 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.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.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)'
$serverUrl = '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 ($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))
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