fiftyone.geolocation 4.2.1 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/.gitmodules +3 -0
  2. package/README.md +2 -2
  3. package/ci/README.md +2 -0
  4. package/ci/build-and-test.yml +34 -0
  5. package/ci/common-ci/.github/labels.yml +59 -0
  6. package/ci/common-ci/.github/workflows/sync-labels.yml +49 -0
  7. package/ci/common-ci/CiTips.md +34 -0
  8. package/ci/common-ci/GitVersion.yml +18 -0
  9. package/ci/common-ci/LICENSE +286 -0
  10. package/ci/common-ci/README.md +365 -0
  11. package/ci/common-ci/build-and-test.yml +65 -0
  12. package/ci/common-ci/check-merge-commit-format.yml +50 -0
  13. package/ci/common-ci/cloud-release-config.json +51 -0
  14. package/ci/common-ci/create-tag.yml +41 -0
  15. package/ci/common-ci/deploy.yml +25 -0
  16. package/ci/common-ci/dotnet/shared-code-signing-steps.yml +20 -0
  17. package/ci/common-ci/dotnet/shared-extract-and-publish-packages.yml +29 -0
  18. package/ci/common-ci/go/shared-go-list-stage.yml +64 -0
  19. package/ci/common-ci/java/readme.md +22 -0
  20. package/ci/common-ci/java/shared-code-signing-steps.yml +17 -0
  21. package/ci/common-ci/node/shared-extract-and-publish-packages.yml +26 -0
  22. package/ci/common-ci/php/readme.md +15 -0
  23. package/ci/common-ci/release-config-schema.json +52 -0
  24. package/ci/common-ci/release-config-template.json +310 -0
  25. package/ci/common-ci/release-config.json +128 -0
  26. package/ci/common-ci/release-process.drawio +165 -0
  27. package/ci/common-ci/release-process.png +0 -0
  28. package/ci/common-ci/scripts/azure/checkSlot.ps1 +28 -0
  29. package/ci/common-ci/scripts/modules/51DAuthorizationModule/51DAuthorizationModule.Tests.ps1 +1 -0
  30. package/ci/common-ci/scripts/modules/51DAuthorizationModule/51DAuthorizationModule.psm1 +16 -0
  31. package/ci/common-ci/scripts/modules/51DBuildModule/51DBuildModule.Tests.ps1 +3 -0
  32. package/ci/common-ci/scripts/modules/51DBuildModule/51DBuildModule.psm1 +200 -0
  33. package/ci/common-ci/scripts/modules/51DDeployModule/51DDeployModule.psm1 +66 -0
  34. package/ci/common-ci/scripts/modules/51DDownloadDataFileModule/51DDownloadDataFileModule.psm1 +58 -0
  35. package/ci/common-ci/scripts/modules/51DEnvironmentModule/51DEnvironmentModule.Tests.ps1 +25 -0
  36. package/ci/common-ci/scripts/modules/51DEnvironmentModule/51DEnvironmentModule.psm1 +22 -0
  37. package/ci/common-ci/scripts/modules/51DErrorHandleModule/51DErrorHandleModule.Tests.ps1 +1 -0
  38. package/ci/common-ci/scripts/modules/51DErrorHandleModule/51DErrorHandleModule.psm1 +41 -0
  39. package/ci/common-ci/scripts/modules/51DGitModule/51DGitModule.Tests.ps1 +5 -0
  40. package/ci/common-ci/scripts/modules/51DGitModule/51DGitModule.psm1 +698 -0
  41. package/ci/common-ci/scripts/modules/51DPackageModule/51DPackageModule.Tests.ps1 +842 -0
  42. package/ci/common-ci/scripts/modules/51DPackageModule/51DPackageModule.psm1 +926 -0
  43. package/ci/common-ci/scripts/modules/51DPipelineModule/51DPipelineModule.Tests.ps1 +1 -0
  44. package/ci/common-ci/scripts/modules/51DPipelineModule/51DPipelineModule.psm1 +87 -0
  45. package/ci/common-ci/scripts/modules/51DPullRequestModule/51DPullRequestModule.Tests.ps1 +194 -0
  46. package/ci/common-ci/scripts/modules/51DPullRequestModule/51DPullRequestModule.psm1 +653 -0
  47. package/ci/common-ci/scripts/modules/51DReleaseModule/51DReleaseModule.Tests.ps1 +277 -0
  48. package/ci/common-ci/scripts/modules/51DReleaseModule/51DReleaseModule.psm1 +554 -0
  49. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/51DReleaseTestEnvModule.Tests.ps1 +1141 -0
  50. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/51DReleaseTestEnvModule.psd1 +0 -0
  51. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/51DReleaseTestEnvModule.psm1 +1465 -0
  52. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/ConfigurationVerifier.Tests.ps1 +318 -0
  53. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/ConfigurationVerifier.psm1 +344 -0
  54. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/ReleaseVerifier.Tests.ps1 +1186 -0
  55. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/ReleaseVerifier.psm1 +900 -0
  56. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/SharedVariables.psm1 +139 -0
  57. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/c-test-env-config.json +268 -0
  58. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/dotnet-deploy-test-env-config.json +700 -0
  59. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/dotnet-test-env-config.json +533 -0
  60. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/go-deploy-test-env-config.json +290 -0
  61. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/go-test-env-config.json +260 -0
  62. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/java-deploy-test-env-config.json +511 -0
  63. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/java-test-env-config.json +388 -0
  64. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/node-deploy-test-env-config.json +419 -0
  65. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/node-test-env-config.json +329 -0
  66. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/php-test-env-config.json +540 -0
  67. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/python-deploy-test-env-config.json +411 -0
  68. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/python-test-env-config.json +321 -0
  69. package/ci/common-ci/scripts/modules/51DReleaseTestEnvModule/config/test-env-config.json +457 -0
  70. package/ci/common-ci/scripts/modules/51DRestModule/51DRestModule.psm1 +38 -0
  71. package/ci/common-ci/scripts/modules/AzurePortalModules/51DApplicationInsightsModule/51DApplicationInsightsModule.psm1 +104 -0
  72. package/ci/common-ci/scripts/modules/AzurePortalModules/51DChecksModule/51DChecksModule.psm1 +68 -0
  73. package/ci/common-ci/scripts/modules/AzurePortalModules/51DCloudModule/51DCloudModule.psm1 +155 -0
  74. package/ci/common-ci/scripts/modules/AzurePortalModules/51DConnectAzureModule/51DConnectAzureModule.psm1 +45 -0
  75. package/ci/common-ci/scripts/modules/AzurePortalModules/51DSSLBindingsModule/51DSSLBIndingsModule.psm1 +100 -0
  76. package/ci/common-ci/scripts/modules/AzurePortalModules/51DStagingSlotModule/51DStagingSlotModule.psm1 +50 -0
  77. package/ci/common-ci/scripts/modules/AzurePortalModules/51DStorageAccountModule/51DStorageAccountModule.psm1 +248 -0
  78. package/ci/common-ci/scripts/modules/AzurePortalModules/51DTrafficManagerModule/51DTrafficManagerModule.psm1 +58 -0
  79. package/ci/common-ci/shared-auto-complete-pr-stage.yml +61 -0
  80. package/ci/common-ci/shared-create-tag-job.yml +23 -0
  81. package/ci/common-ci/shared-docker-build-steps.yml +34 -0
  82. package/ci/common-ci/shared-docker-push-steps.yml +32 -0
  83. package/ci/common-ci/shared-docker-test-http-steps.yml +69 -0
  84. package/ci/common-ci/shared-git-tag-job.yml +38 -0
  85. package/ci/common-ci/shared-git-version-job.yml +71 -0
  86. package/ci/common-ci/shared-publish-github-stage.yml +107 -0
  87. package/ci/common-ci/shared-submodule-trigger-stage.yml +110 -0
  88. package/ci/common-ci/shared-variables.yml +3 -0
  89. package/ci/common-ci/trigger-release-apis.yml +39 -0
  90. package/ci/create-packages.yml +109 -0
  91. package/ci/deploy-external.yml +55 -0
  92. package/ci/deploy-internal.yml +50 -0
  93. package/ci/shared-build-and-test-platforms.yml +26 -0
  94. package/ci/shared-build-and-test-stage.yml +128 -0
  95. package/ci/shared-variables.yml +7 -0
  96. package/ci/submodule-trigger.yml +12 -0
  97. package/docs/Doxyfile +3 -3
  98. package/docs/DoxygenLayout.xml +1 -1
  99. package/examples/examples.test.js +3 -3
  100. package/geoLocationPipelineBuilder.js +16 -13
  101. package/package.json +14 -6
  102. package/setup.js +1 -0
  103. package/tests/geoLocationCloud.test.js +192 -0
  104. package/tsconfig.json +21 -0
  105. package/types/geoLocationCloud.d.ts +7 -0
  106. package/types/geoLocationPipelineBuilder.d.ts +17 -0
  107. package/types/index.d.ts +2 -0
  108. package/build-and-test.yml +0 -112
  109. package/publish-packages.yml +0 -87
@@ -0,0 +1,900 @@
1
+ <#
2
+ ===================== Release Verifier =====================
3
+ .Description
4
+ This module contains functions that verifies if the release
5
+ process has produced the expected results as described in
6
+ the input configuration. This input configuration is the release
7
+ configuration used by the release process.
8
+ #>
9
+
10
+ Using module 51DEnvironmentModule
11
+ Using module 51DGitModule
12
+ Using module 51DPackageModule
13
+
14
+
15
+ <#
16
+ .Description
17
+ Verify dependencies of all Maven packages in a repository.
18
+
19
+ .Parameter RepositoryName
20
+ Name of the current repository
21
+
22
+ .Parameter RepositoryConfig
23
+ A configuration object which contains expected release results
24
+ as described in the config file.
25
+
26
+ .Parameter Repositories
27
+ A repositories object which contains all release repositories
28
+ as described in the config file.
29
+
30
+ .Outputs
31
+ true or false
32
+ #>
33
+ function Test-MavenPackageDependencies {
34
+ param (
35
+ [Parameter(Mandatory)]
36
+ [string]$RepositoryName,
37
+ [Parameter(Mandatory)]
38
+ [object]$RepositoryConfig,
39
+ [Parameter(Mandatory)]
40
+ [object]$Repositories
41
+ )
42
+
43
+ Write-Host ""
44
+ Write-Host "Test Maven Package Dependencies"
45
+ Write-Host "================================="
46
+
47
+ $dependencies = $Repositories."$RepositoryName".dependencies
48
+ if ($dependencies -ne $null -and $dependencies.count -gt 0) {
49
+ # Check if pom.xml exists
50
+ if (Test-Path pom.xml) {
51
+ $pomContent = $(Get-Content pom.xml -Raw)
52
+ foreach ($dependency in $dependencies) {
53
+ Write-Host "# Checking dependency '$dependency'"
54
+ $versionVariableName = $Repositories."$dependency".versionVariableName
55
+ if ([string]::IsNullOrEmpty($versionVariableName)) { continue }
56
+ if ($pomContent -match "\<$versionVariableName\>(?<version>.*)\</$versionVariableName\>") {
57
+ Write-Host "# Version variable matches dependency '$versionVariableName'."
58
+ $dependencyVersion = $Repositories."$dependency".version
59
+ if ($Matches['version'] -ne $dependencyVersion) {
60
+ Write-Host "# FAIL: Version '$($Matches['version'])' of $dependency does not match $dependencyVersion"
61
+ return $false
62
+ }
63
+ }
64
+ }
65
+ } else {
66
+ Write-Host "# WARNING: No pom file is found at this directory. Nothing to verify."
67
+ }
68
+ } else {
69
+ Write-Host "# There is no dependencies defined in configuration file. Skipped."
70
+ }
71
+
72
+ Write-Host "# OK"
73
+ return $true
74
+ }
75
+
76
+ <#
77
+ .Description
78
+ Verify dependencies of all Dotnet packages in a repository.
79
+
80
+ .Parameter RepositoryName
81
+ Name of a repository
82
+
83
+ .Parameter RepositoryConfig
84
+ A configuration object which contains expected release results
85
+ as described in the config file.
86
+
87
+ .Parameter Repositories
88
+ A repositories object which contains all release repositories
89
+ as described in the config file.
90
+
91
+ .Outputs
92
+ true or false
93
+ #>
94
+ function Test-DotnetPackageDependencies {
95
+ param (
96
+ [Parameter(Mandatory)]
97
+ [string]$RepositoryName,
98
+ [Parameter(Mandatory)]
99
+ [object]$RepositoryConfig,
100
+ [Parameter(Mandatory)]
101
+ [object]$Repositories
102
+ )
103
+
104
+ Write-Host ""
105
+ Write-Host "Test Dotnet Package Dependencies"
106
+ Write-Host "================================="
107
+
108
+ $dependencies = $Repositories."$RepositoryName".dependencies
109
+ # Make sure only test if there are dependencies
110
+ if ($dependencies -ne $null -and $dependencies.count -gt 0) {
111
+ # Test each .csproj file.
112
+ foreach ($project in $(Get-ChildItem -Filter *.csproj -Recurse)) {
113
+ Write-Host "# Working on project $project"
114
+ $projFileContent = $(Get-Content $project.FullName -Raw)
115
+ # Test each .csproj file with dependency versions.
116
+ foreach ($dependency in $dependencies) {
117
+ $packageName = $Repositories."$dependency".packageName
118
+ if ([string]::IsNullOrEmpty($packageName)) { continue }
119
+
120
+ # This pattern has a match group name 'name'. That will be used to preserve the actual matched package name.
121
+ $matchPattern = "\<PackageReference \s*Include=\`"(?<name>$packageName.*)\`" \s*Version=\`"(?<version>\d+\.\d+\.\d+)\`"\s*/\>"
122
+ if ($projFileContent -match "$matchPattern") {
123
+ Write-Host "# Version variable matches dependency $packageName."
124
+ $dependencyVersion = $Repositories."$dependency".version
125
+ if ($Matches['version'] -ne $dependencyVersion) {
126
+ Write-Host "# FAIL: Version '$($Matches['version'])' of $dependency does not match $dependencyVersion"
127
+ return $false
128
+ }
129
+ }
130
+
131
+ # This pattern has a match group name 'name'. That will be used to preserve the actual matched package name.
132
+ $matchPattern = "(?<prefix>\<PackageReference \s*Include=\`"$packageName.*\`"\s*\>.*\r\n.*\<Version\>)(?<version>\d+\.\d+\.\d+)(?<suffix>\</Version\>.*\r\n.*\</PackageReference\>)"
133
+ if ($projFileContent -match "$matchPattern") {
134
+ Write-Host "# Version variable matches dependency $packageName."
135
+ $dependencyVersion = $Repositories."$dependency".version
136
+ if ($Matches['version'] -ne $dependencyVersion) {
137
+ Write-Host "# FAIL: Version '$($Matches['version'])' of $dependency does not match $dependencyVersion"
138
+ return $false
139
+ }
140
+ }
141
+
142
+ # This pattern has a match group name 'name'. That will be used to preserve the actual matched package name.
143
+ $matchPattern = "(?<prefix>\<HintPath\>\s*.*$packageName.*)(?<version>\d+\.\d+\.\d+)(?<suffix>\\lib.*\<\/HintPath\>)"
144
+ if ($projFileContent -match "$matchPattern") {
145
+ Write-Host "# Version variable matches dependency $packageName."
146
+ $dependencyVersion = $Repositories."$dependency".version
147
+ if ($Matches['version'] -ne $dependencyVersion) {
148
+ Write-Host "# FAIL: Version '$($Matches['version'])' of $dependency does not match $dependencyVersion"
149
+ return $false
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ # Test each packages.config file.
156
+ foreach ($project in $(Get-ChildItem -Filter packages.config -Recurse)) {
157
+ Write-Host "# Working on project $project"
158
+ $projFileContent = $(Get-Content $project.FullName -Raw)
159
+ # Test each packages.config file with dependency versions.
160
+ foreach ($dependency in $dependencies) {
161
+ $packageName = $Repositories."$dependency".packageName
162
+ if ([string]::IsNullOrEmpty($packageName)) { continue }
163
+ # This pattern has a match group name 'name'. That will be used to preserve the actual matched package name.
164
+ $matchPattern = "\<PackageReference \s*Include=\`"(?<name>$packageName.*)\`" \s*Version=\`"(?<version>\d+\.\d+\.\d+)\`"\s*/\>"
165
+ $matchPattern = "(?<prefix>\<package \s*id=\`"$packageName.*\`" \s*version=\`")(?<version>\d+\.\d+\.\d+)(?<suffix>\`"\s*targetFramework=\`".*\`"\s*/\>)"
166
+ if ($projFileContent -match "$matchPattern") {
167
+ Write-Host "# Version variable matches dependency $packageName."
168
+ $dependencyVersion = $Repositories."$dependency".version
169
+ if ($Matches['version'] -ne $dependencyVersion) {
170
+ Write-Host "# FAIL: Version '$($Matches['version'])' of $dependency does not match $dependencyVersion"
171
+ return $false
172
+ }
173
+ }
174
+ }
175
+ }
176
+ } else {
177
+ Write-Host "# There is no dependencies defined in configuration file. Skipped."
178
+ }
179
+
180
+
181
+ Write-Host "# OK"
182
+ return $true
183
+ }
184
+
185
+ <#
186
+ .Description
187
+ Take a package file content and verify the input repository version.
188
+
189
+ .Parameter RepositoryName
190
+ Name of the repository to verify
191
+
192
+ .Parameter Repositories
193
+ An object of all repositories as specified in the configuration file.
194
+
195
+ .Parameter PackageFileContent
196
+ Content of the package file to verify
197
+
198
+ .Parameter IsRemotePackage
199
+ Whether the current package file is remote_package.json.
200
+
201
+ .Outputs
202
+ true or false
203
+ #>
204
+ function Test-NodePackageDependency {
205
+ param (
206
+ [string]$RepositoryName,
207
+ [object]$Repositories,
208
+ [string]$PackageFileContent,
209
+ [boolean]$IsRemotePackage
210
+ )
211
+
212
+ $packageName = $Repositories."$RepositoryName".packageName
213
+ if ([string]::IsNullOrEmpty($packageName)) { return $PackageFileContent }
214
+
215
+ # This pattern has a match group name 'name'. That will be used to preserve the actual matched package name.
216
+ $matchPattern = "\`"(?<name>$packageName(\.[A-Za-z]+)*)\`"\s*:\s*\`"\^(?<version>\d+\.\d+\.\d+)\`""
217
+ if ($PackageFileContent -match "$matchPattern") {
218
+ Write-Host "# Version variable matches dependency $packageName."
219
+ $dependencyVersion = $Repositories."$RepositoryName".version
220
+ # Make sure that the version exists for the dependency. Else bail out.
221
+ if ($Matches['version'] -ne $dependencyVersion) {
222
+ Write-Host "# FAIL: Expected '$dependencyVersion' for $dependency but got $($Matches['version'])"
223
+ return $false
224
+ }
225
+ } else {
226
+ Write-Host "# Nothing to verify for dependency $packageName"
227
+ }
228
+ return $true
229
+ }
230
+
231
+ <#
232
+ .Description
233
+ Verify a package file with a input list of dependencies.
234
+
235
+ .Parameter RepositoryName
236
+ Name of the current repository
237
+
238
+ .Parameter Repositories
239
+ An object that contains all repositories configuration as specified
240
+ in the configuration file.
241
+
242
+ .Parameter PackageFileName
243
+ Name of the package file
244
+
245
+ .Outputs
246
+ true or false
247
+ #>
248
+ function Test-NodeDependenciesSub {
249
+ param (
250
+ [string]$RepositoryName,
251
+ [object]$Repositories,
252
+ [string]$PackageFileName
253
+ )
254
+
255
+ # Verify each file.
256
+ foreach ($package in $(Get-ChildItem -Filter $PackageFileName -Recurse)) {
257
+ Write-Host "# Working on package '$($package.FullName)'"
258
+ $pkgFileContent = $(Get-Content $package.FullName -Raw)
259
+ $changeMade = $false
260
+ $dependencies = $Repositories."$RepositoryName".dependencies
261
+ # Verify each package file with dependency versions.
262
+ foreach ($dependency in $dependencies) {
263
+ Write-Host "# Verifying dependency '$dependency'"
264
+ if (!$(Test-NodePackageDependency `
265
+ -RepositoryName $dependency `
266
+ -Repositories $Repositories `
267
+ -PackageFileContent $pkgFileContent `
268
+ -IsRemotePackage $false)) {
269
+ return $false
270
+ }
271
+ }
272
+
273
+ # If is remote_package.json, then also verify internal dependencies.
274
+ if ($PackageFileName -match "remote_package.json") {
275
+ Write-Host "# Is remote_package.json so varifying self."
276
+ if (!$(Test-NodePackageDependency `
277
+ -RepositoryName $RepositoryName `
278
+ -Repositories $Repositories `
279
+ -PackageFileContent $pkgFileContent `
280
+ -IsRemotePackage $true)) {
281
+ return $false
282
+ }
283
+ }
284
+ }
285
+ return $true
286
+ }
287
+
288
+ <#
289
+ .Description
290
+ Verify dependencies of all Node packages in a repository.
291
+
292
+ .Parameter RepositoryName
293
+ Name of a repository
294
+
295
+ .Parameter RepositoryConfig
296
+ A configuration object which contains expected release results
297
+ as described in the config file.
298
+
299
+ .Parameter Repositories
300
+ A repositories object which contains all release repositories
301
+ as described in the config file.
302
+
303
+ .Outputs
304
+ true or false
305
+ #>
306
+ function Test-NodePackageDependencies {
307
+ param (
308
+ [Parameter(Mandatory)]
309
+ [string]$RepositoryName,
310
+ [Parameter(Mandatory)]
311
+ [object]$RepositoryConfig,
312
+ [Parameter(Mandatory)]
313
+ [object]$Repositories
314
+ )
315
+
316
+ Write-Host ""
317
+ Write-Host "Verify Node Package Dependencies"
318
+ Write-Host "================================="
319
+
320
+ $dependencies = $RepositoryConfig.dependencies
321
+ # Make sure only verify if there are dependencies
322
+ if ($dependencies -ne $null -and $dependencies.count -gt 0) {
323
+ # Verify package.json files
324
+ Write-Host "# Verify package.json files"
325
+ if (!$(Test-NodeDependenciesSub `
326
+ -RepositoryName $RepositoryName `
327
+ -Dependencies $dependencies `
328
+ -Repositories $Repositories `
329
+ -PackageFileName "package.json")) {
330
+ Write-Host "# ERROR: 'package.json' is not up to date"
331
+ return $false
332
+ }
333
+
334
+ # Verify remote-package.json files
335
+ Write-Host "# Verify remote_package.json files"
336
+ if (!$(Test-NodeDependenciesSub `
337
+ -RepositoryName $RepositoryName `
338
+ -Dependencies $dependencies `
339
+ -Repositories $Repositories `
340
+ -PackageFileName "remote_package.json")) {
341
+ Write-Host "# ERROR: 'remote_package.json' is not up to date"
342
+ return $false
343
+ }
344
+ } else {
345
+ Write-Host "# There is no dependencies defined in configuration file. Skipped."
346
+ }
347
+
348
+ Write-Host "# OK"
349
+ return $true
350
+ }
351
+
352
+ <#
353
+ .Description
354
+ Verify dependencies of all Python packages in a repository.
355
+
356
+ .Parameter RepositoryName
357
+ Name of the current repository
358
+
359
+ .Parameter RepositoryConfig
360
+ A configuration object which contains expected release results
361
+ as described in the config file.
362
+
363
+ .Parameter Repositories
364
+ A repositories object which contains all release repositories
365
+ as described in the config file.
366
+
367
+ .Outputs
368
+ true or false
369
+ #>
370
+ function Test-PythonPackageDependencies {
371
+ param (
372
+ [Parameter(Mandatory)]
373
+ [string]$RepositoryName,
374
+ [Parameter(Mandatory)]
375
+ [object]$RepositoryConfig,
376
+ [Parameter(Mandatory)]
377
+ [object]$Repositories
378
+ )
379
+
380
+ Write-Host ""
381
+ Write-Host "Test Python Package Dependencies"
382
+ Write-Host "================================="
383
+
384
+ $dependencies = $RepositoryConfig.dependencies
385
+ if ($dependencies -ne $null -and $dependencies.count -gt 0) {
386
+ # Check if shared-variables.yml exists
387
+ if (Test-Path ci\shared-variables.yml) {
388
+ $sharedVariablesContent = $(Get-Content ci\shared-variables.yml -Raw)
389
+ $changeMade = $false
390
+ foreach ($dependency in $dependencies) {
391
+ Write-Host "# Verifying dependency '$dependency'"
392
+ $versionVariableName = $Repositories."$dependency".versionVariableName
393
+ if ([string]::IsNullOrEmpty($versionVariableName)) { continue }
394
+ if ($sharedVariablesContent -match "(?<prefix>name\s*:\s*$versionVariableName\s*\r\n\s*value\s*:\s*)'==(?<version>\d+\.\d+\.\d+)'") {
395
+ Write-Host "# Version variable matches dependency $versionVariableName. Verify."
396
+ Write-Host $Matches['prefix']
397
+ $dependencyVersion = $Repositories."$dependency".version
398
+
399
+ if ($Matches['version'] -ne $dependencyVersion) {
400
+ Write-Host "# FAIL: Expected '$dependencyVersion' for '$dependency' but get '$($Matches['version'])"
401
+ return $false
402
+ }
403
+ }
404
+ }
405
+ }
406
+ } else {
407
+ Write-Host "# There is no dependencies defined in configuration file. Skipped."
408
+ }
409
+
410
+ Write-Host "# OK"
411
+ return $true
412
+ }
413
+
414
+ <#
415
+ .Description
416
+ Work on the local git repository. Verify if current repository
417
+ matches all the expected package dependencies versions.
418
+
419
+ .Parameter RepositoryName
420
+ Name of the current repository
421
+
422
+ .Parameter RepositoryConfig
423
+ Expected configuration of a repository
424
+
425
+ .Parameter Repositories
426
+ A list of repositories configurations as specified
427
+ in the configuration file.
428
+
429
+ .Outputs
430
+ true or false
431
+ #>
432
+ function Test-PackageDependencies {
433
+ param(
434
+ [Parameter(Mandatory)]
435
+ [object]$RepositoryName,
436
+ [Parameter(Mandatory)]
437
+ [object]$RepositoryConfig,
438
+ [Parameter(Mandatory)]
439
+ [object]$Repositories
440
+ )
441
+
442
+ Write-Host ""
443
+ Write-Host "# Test package depedencies"
444
+ Write-Host "============================"
445
+
446
+ $pass = $true
447
+ # Determine the type of package based on languages
448
+ switch -Wildcard ("$RepositoryName") {
449
+ "*java" {
450
+ Write-Host "# $RepositoryName is a Maven package."
451
+ $pass = Test-MavenPackageDependencies `
452
+ -RepositoryName $RepositoryName `
453
+ -RepositoryConfig $RepositoryConfig `
454
+ -Repositories $Repositories
455
+ Break
456
+ }
457
+ "*dotnet" {
458
+ Write-Host "# $RepositoryName is a Dotnet package."
459
+ $pass = Test-DotnetPackageDependencies `
460
+ -RepositoryName $RepositoryName `
461
+ -RepositoryConfig $RepositoryConfig `
462
+ -Repositories $Repositories
463
+ Break
464
+ }
465
+ "*node" {
466
+ Write-Host "# $RepositoryName is a Node package."
467
+ $pass = Test-NodePackageDependencies `
468
+ -RepositoryName $RepositoryName `
469
+ -RepositoryConfig $RepositoryConfig `
470
+ -Repositories $Repositories
471
+ Break
472
+ }
473
+ "*python" {
474
+ Write-Host "# $RepositoryName is a Python package."
475
+ $pass = Test-PythonPackageDependencies `
476
+ -RepositoryName $RepositoryName `
477
+ -RepositoryConfig $RepositoryConfig `
478
+ -Repositories $Repositories
479
+ Break
480
+ }
481
+ Default {
482
+ Write-Host "# $RepositoryName is of type that do not require package dependencies."
483
+ Break
484
+ }
485
+ }
486
+
487
+ Write-Host "# OK"
488
+ return $pass
489
+ }
490
+
491
+ <#
492
+ .Description
493
+ Work on the local git repository. Verify if current repository
494
+ matches all the expected submodule references.
495
+
496
+ .Parameter RepositoryConfig
497
+ Expected configuration of a repository
498
+
499
+ .Parameter Repositories
500
+ A list of repositories configurations as specified
501
+ in the configuration file.
502
+
503
+ .Outputs
504
+ true or false
505
+ #>
506
+ function Test-SubmoduleReferences {
507
+ param(
508
+ [Parameter(Mandatory)]
509
+ [object]$RepositoryConfig,
510
+ [Parameter(Mandatory)]
511
+ [object]$Repositories
512
+ )
513
+
514
+ foreach ($submodule in $(git config --file .gitmodules --name-only --get-regexp path)) {
515
+ Write-Host ""
516
+ Write-Host "# Process submodule path $submodule."
517
+ $submodulePath = Find-SubmodulePath -GitSubmodulePath $submodule
518
+ if ($submodulePath -ne $null) {
519
+ Write-Host "# Path $submodulePath extracted."
520
+ Push-Location $submodulePath
521
+
522
+ # Get repo name
523
+ $subRepoName = Get-RepositoryName
524
+ Write-Host "# Processing module $subRepoName."
525
+
526
+ # Check and verify the submodule to the correct tag.
527
+ $targetTag = $Repositories."$subRepoName".version
528
+ Write-Host "# Checking tag $targetTag"
529
+
530
+ # Get all tag
531
+ Write-Host "# Fetch all tags"
532
+ if (![GitHandler]::FetchAllTags()) {
533
+ Write-Host "# ERROR: Failed to fetch tags. Cannot reliably check submodule deployment."
534
+ Pop-Location
535
+ return $false
536
+ }
537
+
538
+ $tagFound = $false
539
+ if ($targetTag -ne $null) {
540
+ $curTag = git describe --tags
541
+ if ($curTag -match "\d+\.\d+\.\d+(\+\d+)?" `
542
+ -and $curTag -like "$targetTag*") {
543
+ $tagFound = $true
544
+ } else {
545
+ Write-Host "# FAIL: Current tag '$curTag' does not match expected tag '$targetTag'"
546
+ }
547
+ } else {
548
+ # If no version is found from the configuration file.
549
+ # Treat it as nothing to be changed for this submodule.
550
+ Write-Host "# No target version has been specified for $subRepoName. No verification required."
551
+ $tagFound = $true
552
+ }
553
+
554
+ Pop-Location
555
+
556
+ # Exit if not all tags have been found.
557
+ if (!$tagFound) {
558
+ Write-Host "# ERROR: Current HEAD for submodule $submodule not referencing the correct tag."
559
+ return $false
560
+ }
561
+ } else {
562
+ Write-Host "# ERROR: Failed to extract module path from $submodulePath"
563
+ return $false
564
+ }
565
+ }
566
+
567
+ Write-Host "# OK"
568
+ return $true
569
+ }
570
+
571
+ <#
572
+ .Description
573
+ Work on the local git repository. Verify if current repository
574
+ matches all the branching and GitVersion.yml format.
575
+
576
+ .Parameter RepositoryConfig
577
+ Expected configuration of a repository
578
+
579
+ .Outputs
580
+ true or false
581
+ #>
582
+ function Test-GitVersion {
583
+ param(
584
+ [Parameter(Mandatory)]
585
+ [object]$RepositoryConfig
586
+ )
587
+
588
+ # Check if GitVersion.yml exists and has the right format.
589
+ if (Test-Path "$($(Get-Location).Path)\GitVersion.yml") {
590
+ $gitVersionFileContent = Get-Content "$($(Get-Location).Path)\GitVersion.yml" -Raw
591
+ if ($gitVersionFileContent `
592
+ -match ".*next-version(\s)*:(\s)*(?<version>\d+\.\d+\.\d+).*") {
593
+ if ($Matches['version'] -ne $RepositoryConfig.version) {
594
+ Write-Host "# FAIL: GitVersion.yaml does not specify the correct version '$($RepositoryConfig.version)'"
595
+ Write-Host "# FAIL: The found version is $($Matches['version'])"
596
+ return $false
597
+ }
598
+ } else {
599
+ Write-Host "# FAIL: not next-version found in GitVersion.yml"
600
+ return $false
601
+ }
602
+ } else {
603
+ Write-Host "# FAIL: GitVersion.yml does not exist"
604
+ return $false
605
+ }
606
+ Write-Host "# OK"
607
+ return $true
608
+ }
609
+
610
+ <#
611
+ .Description
612
+ Checkout a repository and its main branch
613
+
614
+ .Parameter RepositoryName
615
+ Name of a repository
616
+
617
+ .Parameter TeamProjectName
618
+ Name ofthe repository team project
619
+
620
+ .Outputs
621
+ true or false
622
+ #>
623
+ function Use-Repository {
624
+ param(
625
+ [Parameter(Mandatory)]
626
+ [string]$RepositoryName,
627
+ [Parameter(Mandatory)]
628
+ [string]$TeamProjectName
629
+ )
630
+
631
+ Write-Host ""
632
+ Write-Host "# Clone repository $RepositoryName"
633
+
634
+ $mainBranch = Get-MainBranchRef `
635
+ -RepositoryName $RepositoryName `
636
+ -TeamProjectName $TeamProjectName
637
+ Write-Host "# Main branch ref is '$mainBranch'"
638
+ if ($mainBranch -match "refs/heads/(?<name>(master|main))") {
639
+ $mainBranchName = $Matches['name']
640
+ } else {
641
+ Write-Host "# ERROR: Main branch name is not standard."
642
+ return $false
643
+ }
644
+
645
+ $remoteUrl = Get-RepositoryRemoteUrl `
646
+ -RepositoryName $RepositoryName `
647
+ -TeamProjectName $TeamProjectName
648
+ if ($remoteUrl -ne $null) {
649
+ if ([GitHandler]::Clone($remoteUrl)) {
650
+ Push-Location $RepositoryName
651
+
652
+ # Configuration email address and user name before any commit for this repository.
653
+ if (![GitHandler]::Config("ciuser@51degrees.com", "CIUser")) {
654
+ Write-Host "# ERROR: Failed to configure email and user name"
655
+ return $false
656
+ }
657
+
658
+ # Checkout the main branch
659
+ if ($(git rev-parse --abbrev-ref HEAD) -notmatch "(master|main)") {
660
+ if ([GitHandler]::Checkout($mainBranchName)) {
661
+ Write-Host "# Successfully checkout main branch '$mainBranchName'."
662
+ } elseif ([GitHandler]::CheckoutTrack('origin/$mainBranchName')) {
663
+ Write-Host "# Successfully checkout and track main branch '$mainBranchName'."
664
+ } else {
665
+ Write-Host "# ERROR: Failed to checkout main branch."
666
+ Pop-Location
667
+ return $false
668
+ }
669
+ } else {
670
+ Write-Host "# Currently on $mainBranchName."
671
+ }
672
+
673
+ Pop-Location
674
+ } else {
675
+ Write-Host "# ERROR: Failed to clone the remote url $remoteUrl"
676
+ return $false
677
+ }
678
+ } else {
679
+ Write-Host "# ERROR: No remote url found for repository $RepositoryName."
680
+ return $false
681
+ }
682
+ return $true
683
+ }
684
+
685
+ <#
686
+ .Description
687
+ Verify if the current state of a repository match
688
+ the expectation specified in the configuration file.
689
+
690
+ .Parameter RepositoryName
691
+ Name of a repository
692
+
693
+ .Parameter RepositoryConfig
694
+ A repository configuration object
695
+
696
+ .Parameter Repositories
697
+ A list of repositories configurations as specified
698
+ in the configuration file.
699
+
700
+ .Parameter TeamProjectName
701
+ Name ofthe repository team project
702
+
703
+ .Outputs
704
+ true or false
705
+ #>
706
+ function Test-Repository {
707
+ param(
708
+ [Parameter(Mandatory)]
709
+ [string]$RepositoryName,
710
+ [Parameter(Mandatory)]
711
+ [object]$RepositoryConfig,
712
+ [Parameter(Mandatory)]
713
+ [object]$Repositories,
714
+ [Parameter(Mandatory)]
715
+ [string]$TeamProjectName
716
+ )
717
+
718
+ Write-Host ""
719
+ Write-Host "# Verifying repository $RepositoryName"
720
+ # Checkout the repository
721
+ if (!$(Use-Repository -RepositoryName $RepositoryName -TeamProjectName $TeamProjectName)) {
722
+ Write-Host "# ERROR: Failed to clone and checkout the 'main' branch of repository $RepositoryName"
723
+ Pop-Location
724
+ return $false
725
+ }
726
+
727
+ # CD to the repository
728
+ Push-Location $RepositoryName
729
+
730
+ # Verify if tag exist
731
+ Write-Host ""
732
+ Write-Host "# Verify if tag $($RepositoryConfig.version) exists"
733
+ if (!$(Test-TagExist `
734
+ -RepositoryName $RepositoryName `
735
+ -Version $RepositoryConfig.version `
736
+ -TeamProjectName $TeamProjectName)) {
737
+ Write-Host "# FAIL: Not all tags exist"
738
+ Pop-Location
739
+ return $false
740
+ }
741
+
742
+ # Verify if release/hotfix branch and GitVersion.yml exist
743
+ # Check if release/hotfix branch exists
744
+ Write-Host ""
745
+ Write-Host "# Check if GitVersion.yml exists. If not skip."
746
+ if ($(Get-ReleaseBranchRef `
747
+ -RepositoryName $RepositoryName `
748
+ -Version $RepositoryConfig.version `
749
+ -TeamProjectName $TeamProjectName) -eq $null) {
750
+ if (!$(Test-GitVersion -RepositoryConfig $RepositoryConfig)) {
751
+ Write-Host "# FAIL: GitVersion.yml is not updated as expected"
752
+ Pop-Location
753
+ return $false
754
+ }
755
+ }
756
+
757
+ # Verify if submodules reference are up to date
758
+ Write-Host ""
759
+ Write-Host "# Check if submodule references are up to date"
760
+ if (!$(Test-SubmoduleReferences `
761
+ -RepositoryConfig $RepositoryConfig `
762
+ -Repositories $Repositories)) {
763
+ Write-Host "# FAIL: Not all submodule references are updated"
764
+ Pop-Location
765
+ return $false
766
+ }
767
+
768
+ # Verify if packages version are up to date
769
+ Write-Host ""
770
+ Write-Host "# Check if package dependency versions are up to date."
771
+ if (!$(Test-PackageDependencies `
772
+ -RepositoryName $RepositoryName `
773
+ -RepositoryConfig $RepositoryConfig `
774
+ -Repositories $Repositories)) {
775
+ Write-Host "# FAIL: Not all package dependencies are updated"
776
+ Pop-Location
777
+ return $false
778
+ }
779
+
780
+ # CD output of the repository
781
+ Pop-Location
782
+
783
+ return $true
784
+ }
785
+
786
+ <#
787
+ .Description
788
+ Take a list of repositories configurations and
789
+ verify the expected output. This creates a folder
790
+ named 'workpace' at the current location to checkout
791
+ the repositories for testing.
792
+
793
+ .Parameter Repositories
794
+ A list of repositories configurations as specified
795
+ in the configuration file.
796
+
797
+ .Parameter Force
798
+ Force create a 'workplace' folder
799
+
800
+ .Parameter TeamProjectName
801
+ Name ofthe repository team project
802
+
803
+ .Outputs
804
+ true or false
805
+ #>
806
+ function Test-Repositories {
807
+ param(
808
+ [Parameter(Mandatory)]
809
+ [object]$Repositories,
810
+ [switch]$Force = $false,
811
+ [Parameter(Mandatory)]
812
+ [string]$TeamProjectName
813
+ )
814
+
815
+ Write-Host ""
816
+ Write-Host "Verify repositories"
817
+ Write-Host "==================="
818
+
819
+ Write-Host "# A folder named 'workplace' will be created to checkout the target repositories for testing."
820
+ Write-Host "# Please confirm that you want to proceed."
821
+ Write-Host "# Y[Yes] N[No]"
822
+ if (!$Force) {
823
+ $answer = Read-Host -Prompt "# Answer"
824
+ if (!$($answer -match "Y|Yes")) {
825
+ Write-Host "# Stopped"
826
+ return $true
827
+ }
828
+ }
829
+
830
+ Write-Host "# Create a working folder"
831
+ $rc = New-Item -Type "directory" -Path workplace
832
+ if (!(Test-Path "$($(Get-Location).Path)/workplace")) {
833
+ Write-Host "# ERROR: Failed to create a working folder"
834
+ return $false
835
+ }
836
+ $rc = Push-Location workplace
837
+
838
+ foreach ($repository in $($Repositories | Get-Member -MemberType NoteProperty)) {
839
+ Write-Host "# Processing repository '$($repository.Name)'"
840
+ if (!$(Test-Repository `
841
+ -RepositoryName $repository.Name `
842
+ -RepositoryConfig $Repositories."$($repository.Name)" `
843
+ -Repositories $Repositories `
844
+ -TeamProjectName $TeamProjectName)) {
845
+ Write-Host "# FAIL: Output for repository '$($repository.Name)' does not match expection."
846
+ return $false
847
+ }
848
+ }
849
+ $rc = Pop-Location
850
+ return $true
851
+ }
852
+
853
+ <#
854
+ .Description
855
+ Read a config file and verify that the results
856
+ specified has been met.
857
+
858
+ .Parameter ConfigFile
859
+ Full path to the configuration file
860
+
861
+ .Outputs
862
+ true or false
863
+ #>
864
+ function Test-Release {
865
+ param(
866
+ [Parameter(Mandatory)]
867
+ [string]$ConfigurationFile
868
+ )
869
+
870
+ Write-Host ""
871
+ Write-Host "Read input configuration file"
872
+ Write-Host "============================="
873
+ # Check file existance
874
+ if (!(Test-Path $ConfigurationFile)) {
875
+ Write-Host "# ERROR: File $ConfigurationFile does not exist."
876
+ return $false
877
+ }
878
+
879
+ # Get content of configuration file
880
+ $config = Get-Content $ConfigurationFile | Out-String | ConvertFrom-Json
881
+ if (!$?) {
882
+ Write-Host "# ERROR: Failed to get content of the configuration file $ConfigurationFile."
883
+ return $false
884
+ }
885
+
886
+ $result = $(Test-Repositories `
887
+ -Repositories $config.repositories `
888
+ -TeamProjectName "$([EnvironmentHandler]::GetEnvironmentVariable($Env:SYSTEM_TEAMPROJECTID))")
889
+ Write-Host "Result $result"
890
+
891
+ # Verify all repositories
892
+ if (!$result) {
893
+ Write-Host "# FAIL: Actual results do not match what is specified."
894
+ return $false
895
+ }
896
+
897
+ # Actual results match what is specified.
898
+ Write-Host "# PASS"
899
+ return $true
900
+ }