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,165 @@
1
+ <mxfile host="65bd71144e">
2
+ <diagram id="kqvr45VDlgbzlYrqjXVV" name="Page-1">
3
+ <mxGraphModel dx="1092" dy="790" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
4
+ <root>
5
+ <mxCell id="0"/>
6
+ <mxCell id="1" parent="0"/>
7
+ <mxCell id="3" value="Release Trigger" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
8
+ <mxGeometry x="320" y="20" width="120" height="60" as="geometry"/>
9
+ </mxCell>
10
+ <mxCell id="4" value="Complete Leaf Modules Pull Requests" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
11
+ <mxGeometry x="320" y="120" width="120" height="60" as="geometry"/>
12
+ </mxCell>
13
+ <mxCell id="5" value="Tag-Repository/Create-Packages" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
14
+ <mxGeometry x="320" y="220" width="120" height="60" as="geometry"/>
15
+ </mxCell>
16
+ <mxCell id="6" value="Tag Creation Only" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
17
+ <mxGeometry x="340" y="320" width="80" height="80" as="geometry"/>
18
+ </mxCell>
19
+ <mxCell id="7" value="Deploy Internally" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
20
+ <mxGeometry x="320" y="440" width="120" height="60" as="geometry"/>
21
+ </mxCell>
22
+ <mxCell id="8" value="Deploy externally" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
23
+ <mxGeometry x="520" y="440" width="120" height="60" as="geometry"/>
24
+ </mxCell>
25
+ <mxCell id="9" value="Submodule trigger" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
26
+ <mxGeometry x="320" y="670" width="120" height="60" as="geometry"/>
27
+ </mxCell>
28
+ <mxCell id="10" value="Create Pull Request To Main" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
29
+ <mxGeometry x="320" y="870" width="120" height="60" as="geometry"/>
30
+ </mxCell>
31
+ <mxCell id="11" value="Pull Request Tests Run" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
32
+ <mxGeometry x="320" y="970" width="120" height="60" as="geometry"/>
33
+ </mxCell>
34
+ <mxCell id="12" value="Pull Request Auto Completion" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
35
+ <mxGeometry x="320" y="1190" width="120" height="60" as="geometry"/>
36
+ </mxCell>
37
+ <mxCell id="13" value="Tests Pass" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
38
+ <mxGeometry x="340" y="1070" width="80" height="80" as="geometry"/>
39
+ </mxCell>
40
+ <mxCell id="14" value="Update dependency references and versions" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
41
+ <mxGeometry x="320" y="770" width="120" height="60" as="geometry"/>
42
+ </mxCell>
43
+ <mxCell id="15" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="3" target="4">
44
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
45
+ <mxPoint x="530" y="260" as="sourcePoint"/>
46
+ <mxPoint x="580" y="210" as="targetPoint"/>
47
+ <Array as="points">
48
+ <mxPoint x="380" y="100"/>
49
+ </Array>
50
+ </mxGeometry>
51
+ </mxCell>
52
+ <mxCell id="16" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="5">
53
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
54
+ <mxPoint x="530" y="260" as="sourcePoint"/>
55
+ <mxPoint x="580" y="210" as="targetPoint"/>
56
+ </mxGeometry>
57
+ </mxCell>
58
+ <mxCell id="17" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="5" target="6">
59
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
60
+ <mxPoint x="390" y="190" as="sourcePoint"/>
61
+ <mxPoint x="390" y="230" as="targetPoint"/>
62
+ </mxGeometry>
63
+ </mxCell>
64
+ <mxCell id="18" value="Yes" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="7">
65
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
66
+ <mxPoint x="530" y="460" as="sourcePoint"/>
67
+ <mxPoint x="580" y="410" as="targetPoint"/>
68
+ </mxGeometry>
69
+ </mxCell>
70
+ <mxCell id="19" value="Yes" style="endArrow=classic;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="6">
71
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
72
+ <mxPoint x="530" y="460" as="sourcePoint"/>
73
+ <mxPoint x="590" y="440" as="targetPoint"/>
74
+ <Array as="points">
75
+ <mxPoint x="590" y="360"/>
76
+ </Array>
77
+ </mxGeometry>
78
+ </mxCell>
79
+ <mxCell id="20" value="No" style="endArrow=classic;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="9">
80
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
81
+ <mxPoint x="530" y="460" as="sourcePoint"/>
82
+ <mxPoint x="580" y="410" as="targetPoint"/>
83
+ <Array as="points">
84
+ <mxPoint x="200" y="360"/>
85
+ <mxPoint x="200" y="700"/>
86
+ </Array>
87
+ </mxGeometry>
88
+ </mxCell>
89
+ <mxCell id="21" value="" style="endArrow=classic;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" target="31">
90
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
91
+ <mxPoint x="380" y="505" as="sourcePoint"/>
92
+ <mxPoint x="374" y="550" as="targetPoint"/>
93
+ </mxGeometry>
94
+ </mxCell>
95
+ <mxCell id="22" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="9" target="14">
96
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
97
+ <mxPoint x="530" y="590" as="sourcePoint"/>
98
+ <mxPoint x="580" y="540" as="targetPoint"/>
99
+ </mxGeometry>
100
+ </mxCell>
101
+ <mxCell id="24" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="14" target="10">
102
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
103
+ <mxPoint x="530" y="690" as="sourcePoint"/>
104
+ <mxPoint x="580" y="640" as="targetPoint"/>
105
+ </mxGeometry>
106
+ </mxCell>
107
+ <mxCell id="25" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="10" target="11">
108
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
109
+ <mxPoint x="530" y="690" as="sourcePoint"/>
110
+ <mxPoint x="580" y="640" as="targetPoint"/>
111
+ </mxGeometry>
112
+ </mxCell>
113
+ <mxCell id="26" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="11" target="13">
114
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
115
+ <mxPoint x="530" y="890" as="sourcePoint"/>
116
+ <mxPoint x="380" y="1079" as="targetPoint"/>
117
+ </mxGeometry>
118
+ </mxCell>
119
+ <mxCell id="28" value="Yes" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="13" target="12">
120
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
121
+ <mxPoint x="530" y="1090" as="sourcePoint"/>
122
+ <mxPoint x="580" y="1040" as="targetPoint"/>
123
+ </mxGeometry>
124
+ </mxCell>
125
+ <mxCell id="29" value="" style="endArrow=classic;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="12" target="5">
126
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
127
+ <mxPoint x="330" y="1110" as="sourcePoint"/>
128
+ <mxPoint x="120" y="260" as="targetPoint"/>
129
+ <Array as="points">
130
+ <mxPoint x="120" y="1220"/>
131
+ <mxPoint x="120" y="250"/>
132
+ </Array>
133
+ </mxGeometry>
134
+ </mxCell>
135
+ <mxCell id="31" value="Parent Module Exists" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
136
+ <mxGeometry x="340" y="544.5" width="80" height="80" as="geometry"/>
137
+ </mxCell>
138
+ <mxCell id="32" value="Yes" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="31" target="9">
139
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
140
+ <mxPoint x="530" y="750" as="sourcePoint"/>
141
+ <mxPoint x="374" y="680" as="targetPoint"/>
142
+ </mxGeometry>
143
+ </mxCell>
144
+ <mxCell id="34" value="Terminated" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
145
+ <mxGeometry x="660" y="1070" width="80" height="80" as="geometry"/>
146
+ </mxCell>
147
+ <mxCell id="35" value="No" style="endArrow=classic;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="31" target="34">
148
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
149
+ <mxPoint x="530" y="750" as="sourcePoint"/>
150
+ <mxPoint x="580" y="700" as="targetPoint"/>
151
+ <Array as="points">
152
+ <mxPoint x="699" y="585"/>
153
+ </Array>
154
+ </mxGeometry>
155
+ </mxCell>
156
+ <mxCell id="36" value="" style="endArrow=classic;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="13" target="34">
157
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
158
+ <mxPoint x="530" y="950" as="sourcePoint"/>
159
+ <mxPoint x="580" y="900" as="targetPoint"/>
160
+ </mxGeometry>
161
+ </mxCell>
162
+ </root>
163
+ </mxGraphModel>
164
+ </diagram>
165
+ </mxfile>
Binary file
@@ -0,0 +1,28 @@
1
+ # This is a wrapper script which runs the Get-SlotStatus function in the
2
+ # 51DDeployModule, helpful if running from azure pipelines and need to pass in
3
+ # arguments.
4
+
5
+ param (
6
+ # The path to the module folder which contains the 51DeployModule. This
7
+ # module contains the Get-SlotStatus function.
8
+ [Parameter(Mandatory=$true)]
9
+ [string]$ModulePath,
10
+
11
+ # The URI of the service to test, e.g. https://51degrees.com
12
+ [Parameter(Mandatory=$true)]
13
+ [string]$Uri,
14
+
15
+ # The number of tries before aborting the test.
16
+ [int]$NumberOfTries=18,
17
+
18
+ # The delay between tries in seconds.
19
+ [int]$SecondsBetweenTries=10
20
+ )
21
+
22
+ # Install all modules
23
+ $Env:PSModulePath += "$([IO.Path]::PathSeparator)$($ModulePath)"
24
+ Write-Host "Module Path: $($Env:PSModulePath)"
25
+
26
+ # Execute Get-SlotStatus script. The function will exit with a status of 1 if
27
+ # the service fails to respond with a HTTP 200 status code.
28
+ Get-SlotStatus -Uri $Uri -NumberOfTries $NumberOfTries -SecondsBetweenTries $SecondsBetweenTries
@@ -0,0 +1,16 @@
1
+ # Get the path to the script parent folder.
2
+ $scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
3
+
4
+ # Class contains definition of authorization string.
5
+ class Authorization {
6
+ static [string]$AuthorizationString = "Bearer $Env:SYSTEM_ACCESSTOKEN"
7
+ # When using this script locally, create a authorization -setting.json with the following content:
8
+ # { "Base64PAT": "Basic [Your Base 64 PAT]" }
9
+ # Update it with your base 64 encoded PAT as described at
10
+ # https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page#use-a-pat
11
+ #
12
+ # Then uncomment the following line, load this module and run 'Using module 51DAuthorizationModule' in a fresh environment if
13
+ # accessing this directly from a terminal.
14
+ #
15
+ # static [string]$AuthorizationString = $(Get-Content $scriptPath/authorization-settings.json -Raw | Out-String | ConvertFrom-Json).Base64PAT
16
+ }
@@ -0,0 +1,3 @@
1
+ Describe 'Stop-PreviousBuilds' {
2
+ # Place holders for future tests
3
+ }
@@ -0,0 +1,200 @@
1
+ <#
2
+ ===================== Build =====================
3
+ .Description
4
+ This module contains functions that perform actions
5
+ on a or more Azure Devops build.
6
+ For more information, please read description of
7
+ each function.
8
+ #>
9
+
10
+ Using module 51DAuthorizationModule
11
+ Using module 51DEnvironmentModule
12
+
13
+ <#
14
+ .Description
15
+ Requeue a test build of a pull request.
16
+
17
+ .Parameter RepositoryName
18
+ Name of a repository
19
+
20
+ .Parameter PullRequestId
21
+ Id number of a pull request
22
+
23
+ .Parameter TeamProjectName
24
+ Name ofthe repository team project
25
+
26
+ .Outputs true or false
27
+ #>
28
+ function Restart-TestBuild {
29
+ param (
30
+ [Parameter(Mandatory)]
31
+ [string]$RepositoryName,
32
+ [Parameter(Mandatory)]
33
+ [int32]$PullRequestId,
34
+ [Parameter(Mandatory)]
35
+ [string]$TeamProjectName
36
+ )
37
+
38
+ # Get the merge branch of the pull request
39
+ $ref = Get-MergeBranchName -PullRequestId $PullRequestId
40
+
41
+ # Obtain test pipeline id of a repository.
42
+ $pipelineId = Get-PipelineId -Name "$RepositoryName-test" -TeamProjectName $TeamProjectName
43
+ if ($pipelineId -eq $null) {
44
+ Write-Host "# ERROR: Failed to get pipeline id"
45
+ return $false
46
+ }
47
+
48
+ # Get all runs for the pipeline.
49
+ $url = "$([EnvironmentHandler]::GetEnvironmentVariable($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI))$($TeamProjectName)/_apis/build/builds?api-version=6.0"
50
+ $jsonBody = @"
51
+ {
52
+ "definition" : {
53
+ "id" : $pipelineId
54
+ },
55
+ "sourceBranch" : "$ref"
56
+ }
57
+ "@
58
+
59
+ $response = Invoke-WebRequest `
60
+ -URI $url `
61
+ -Headers @{
62
+ Authorization = "$([Authorization]::AuthorizationString)"
63
+ } `
64
+ -Method POST `
65
+ -ContentType "application/json" `
66
+ -Body $jsonBody
67
+
68
+ return $(Test-RestResponse `
69
+ -Response $response `
70
+ -ErrorMessage "Failed to rerun the test pipeline for pull request $PullRequestId.")
71
+ }
72
+
73
+ <#
74
+ .Description
75
+ Requeue a test build of a pull request.
76
+
77
+ .Parameter BuildId
78
+ Id number of a build.
79
+
80
+ .Parameter TeamProjectName
81
+ Name ofthe repository team project
82
+
83
+ .Outputs Build object.
84
+ #>
85
+ function Get-Build {
86
+ param (
87
+ [Parameter(Mandatory)]
88
+ [int32]$BuildId,
89
+ [Parameter(Mandatory)]
90
+ [string]$TeamProjectName
91
+ )
92
+
93
+ $url = "$([EnvironmentHandler]::GetEnvironmentVariable($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI))$($TeamProjectName)/_apis/build/builds/$($BuildId)?api-version=6.0"
94
+ $response = Invoke-WebRequest `
95
+ -URI $url `
96
+ -Headers @{
97
+ Authorization = "$([Authorization]::AuthorizationString)"
98
+ } `
99
+ -Method GET
100
+
101
+ if ($(Test-RestResponse `
102
+ -Response $response `
103
+ -ErrorMessage "Failed to get build object for build $BuildId.")) {
104
+ $content = $response.content | Out-String | ConvertFrom-Json
105
+ return $content
106
+ } else {
107
+ return $null
108
+ }
109
+ }
110
+
111
+ <#
112
+ .Description
113
+ Cancel all other builds of a pipeline on a certain branch, except the specified build id.
114
+
115
+ .Parameter PipelineName
116
+ Name of a pipeline to check for the builds.
117
+
118
+ .Parameter Branch
119
+ Full reference name of a branch to check if the builds run on.
120
+
121
+ .Parameter CurrentBuildId
122
+ Build id.
123
+
124
+ .Parameter TeamProjectName
125
+ Name ofthe repository team project
126
+
127
+ .Outputs true or false
128
+ #>
129
+ function Stop-PreviousBuilds {
130
+ param (
131
+ [Parameter(Mandatory)]
132
+ [string]$PipelineName,
133
+ [Parameter(Mandatory)]
134
+ [string]$Branch,
135
+ [Parameter(Mandatory)]
136
+ [string]$CurrentBuildId,
137
+ [Parameter(Mandatory)]
138
+ [string]$TeamProjectName
139
+ )
140
+
141
+ Write-Host ""
142
+ Write-Host "# Getting current builds."
143
+ $pipelineId = Get-PipelineId -Name $PipelineName -TeamProjectName $TeamProjectName
144
+ $url = "$([EnvironmentHandler]::GetEnvironmentVariable($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI))$($TeamProjectName)/_apis/build/builds?definitions=$pipelineId&branchName=$Branch&api-version=6.0"
145
+ $response = Invoke-WebRequest `
146
+ -URI $url `
147
+ -Headers @{
148
+ Authorization = "$([Authorization]::AuthorizationString)"
149
+ } `
150
+ -Method GET
151
+
152
+ if ($(Test-RestResponse -Response $response -ErrorMessage "Failed to get all current builds.")) {
153
+ $content = $response.content | Out-String | ConvertFrom-Json
154
+ $buildsToCancel = $content.value.Where({ ($_.status -eq 'inProgress') -and ($_.id -ne $CurrentBuildId) })
155
+ $allCancelled = $true
156
+
157
+ $currentBuild = Get-Build -BuildId $CurrentBuildId -TeamProjectName $TeamProjectName
158
+ if ($currentBuild -eq $null) {
159
+ Write-Host "# ERROR: Failed to obtain current build object."
160
+ return $false
161
+ }
162
+
163
+ $currentBuildTime = Get-Date -Format yyyy-MM-ddTHH-mm-ss-ff $currentBuild.startTime
164
+ foreach ($build in $buildsToCancel) {
165
+ $buildTime = Get-Date -Format yyyy-MM-ddTHH-mm-ss-ff $build.startTime
166
+ if ($buildTime -lt $currentBuildTime) {
167
+ Write-Host ""
168
+ Write-Host "# Cancelling build $($build.id)."
169
+ $body = @"
170
+ {
171
+ "id" : $($build.id),
172
+ "status" : "cancelling"
173
+ }
174
+ "@
175
+
176
+ $url = "$([EnvironmentHandler]::GetEnvironmentVariable($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI))$($TeamProjectName)/_apis/build/builds/$($build.id)?api-version=6.0"
177
+ $cancellingResponse = Invoke-WebRequest `
178
+ -URI $url `
179
+ -Headers @{
180
+ Authorization = "$([Authorization]::AuthorizationString)"
181
+ } `
182
+ -Method PATCH `
183
+ -ContentType "application/json" `
184
+ -Body $body
185
+
186
+ if ($(Test-RestResponse -Response $cancellingResponse -ErrorMessage "Failed to cancle build $($build.id)")) {
187
+ Write-Host "# SUCCESS"
188
+ } else {
189
+ Write-Host "# FAIL"
190
+ $allCancelled = $false
191
+ }
192
+ }
193
+ }
194
+ return $allCancelled
195
+ }
196
+ return $false
197
+ }
198
+
199
+ Export-ModuleMember -Function Restart-TestBuild
200
+ Export-ModuleMember -Function Stop-PreviousBuilds
@@ -0,0 +1,66 @@
1
+ <#
2
+ ==================== Deploy =====================
3
+ .Description
4
+ This module contains functions to aid with deployment to Azure Services.
5
+ #>
6
+
7
+ # Get HTTP status where querying a Uri, return even if the client throws an
8
+ # exception.
9
+ function Get-StatusCode {
10
+
11
+ param(
12
+ [string]$Uri
13
+ )
14
+
15
+ try{
16
+ (Invoke-WebRequest -Uri $Uri -UseBasicParsing -DisableKeepAlive).StatusCode
17
+ }
18
+ catch [Net.WebException]
19
+ {
20
+ [int]$_.Exception.Response.StatusCode
21
+ }
22
+ catch [Exception]
23
+ {
24
+ return 0
25
+ }
26
+ }
27
+
28
+ # Check if a service has started by polling an endoint, if the number of retrys
29
+ # has been exhausted and the service is not running (no 200 status code returned)
30
+ # then exit with status code 1.
31
+ function Get-SlotStatus {
32
+ param (
33
+ # The URI of the service to test, e.g. https://51degrees.com
34
+ [Parameter(Mandatory=$true)]
35
+ [string]$Uri,
36
+
37
+ # The number of tries before aborting the test.
38
+ [Parameter(Mandatory=$true)]
39
+ [int]$NumberOfTries,
40
+
41
+ # The delay between tries in seconds.
42
+ [Parameter(Mandatory=$true)]
43
+ [int]$SecondsBetweenTries
44
+ )
45
+
46
+ # Wait for the service to start
47
+ Write-Host -NoNewline "Waiting for response from $Uri "
48
+
49
+ $Tries = 0
50
+ $HTTP_Status = Get-StatusCode -Uri $Uri -Path $Path
51
+ While ($HTTP_Status -ne 200 -And $Tries -le $NumberOfTries) {
52
+ Start-Sleep -Seconds $SecondsBetweenTries
53
+ $Tries = $Tries +1
54
+ $HTTP_Status = Get-StatusCode -Uri $Uri -Path $Path
55
+ Write-Host -NoNewLine "."
56
+ }
57
+ Write-Host ""
58
+ # Exit if service is not accepting requests
59
+ if($HTTP_Status -ne 200) {
60
+ Write-Host "Service is not accepting requests."
61
+ exit 1
62
+ }
63
+ Write-Host "Service has started"
64
+ }
65
+
66
+ Export-ModuleMember -Function Get-SlotStatus
@@ -0,0 +1,58 @@
1
+ <#
2
+ ==================== Download =====================
3
+ .Description
4
+ This module contains a function to download a data file
5
+ from the 51Degrees Distributor.
6
+ #>
7
+
8
+ # Download a data file.
9
+ function Get-DataFile {
10
+
11
+ param (
12
+ [Parameter(Mandatory=$true)]
13
+ [string]$licenseKey,
14
+
15
+ [Parameter(Mandatory=$true)]
16
+ [string]$dataType,
17
+
18
+ [Parameter(Mandatory=$true)]
19
+ [string]$product,
20
+
21
+ [Parameter(Mandatory=$true)]
22
+ [string]$fullFilePath
23
+ )
24
+
25
+ $timeoutWebclientCode = @"
26
+ using System.Net;
27
+
28
+ public class TimeoutWebClient : WebClient
29
+ {
30
+ public int TimeoutSeconds;
31
+
32
+ protected override WebRequest GetWebRequest(System.Uri address)
33
+ {
34
+ WebRequest request = base.GetWebRequest(address);
35
+ if (request != null)
36
+ {
37
+ request.Timeout = TimeoutSeconds * 1000;
38
+ }
39
+ return request;
40
+ }
41
+
42
+ public TimeoutWebClient()
43
+ {
44
+ TimeoutSeconds = 100; // Timeout value by default
45
+ }
46
+ }
47
+ "@;
48
+
49
+ Add-Type -TypeDefinition $timeoutWebclientCode -Language CSharp
50
+ $webClient = New-Object TimeoutWebClient;
51
+ $webClient.TimeoutSeconds = 240;
52
+ $url ="https://distributor.51degrees.com/api/v2/download?LicenseKeys=$($licenseKey)&Type=$($dataType)&Download=True&Product=$($product)"
53
+ $start_time = Get-Date
54
+ $webClient.DownloadFile($url, $fullFilePath)
55
+ Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
56
+ }
57
+
58
+ Export-ModuleMember -Function Get-DataFile
@@ -0,0 +1,25 @@
1
+ Using module 51DEnvironmentModule
2
+
3
+ Describe 'GetEnvironmentVariable' {
4
+ It 'Successfully get default in test environment' {
5
+ $curEnv = $Env:51D_ENVIRONMENT
6
+ # Set test environment
7
+ $Env:51D_ENVIRONMENT = "Test"
8
+ $result = [EnvironmentHandler]::GetEnvironmentVariable("test")
9
+
10
+ # Restore the current environment
11
+ $Env:51D_ENVIRONMENT = $curEnv
12
+ $result | Should -Be "default"
13
+ }
14
+
15
+ It 'Successfully get value in production environment' {
16
+ $curEnv = $Env:51D_ENVIRONMENT
17
+ # Set test environment
18
+ $Env:51D_ENVIRONMENT = "Production"
19
+ $result = [EnvironmentHandler]::GetEnvironmentVariable("test")
20
+
21
+ # Restore the current environment
22
+ $Env:51D_ENVIRONMENT = $curEnv
23
+ $result | Should -Be "test"
24
+ }
25
+ }
@@ -0,0 +1,22 @@
1
+ class EnvironmentHandler {
2
+ <#
3
+ .Description
4
+ This function check what value caller should see in current environment.
5
+ This is normally used to make sure that in a test environment, a fake
6
+ value is always used so that we don't accidentally change the production
7
+ environment.
8
+
9
+ .Parameter envVarValue
10
+ Actual environment value
11
+
12
+ .Outputs
13
+ The input value or default if in test environment
14
+ #>
15
+ static [object]GetEnvironmentVariable([object]$envVarValue) {
16
+ if ($Env:51D_ENVIRONMENT -eq 'Test') {
17
+ return "default"
18
+ } else {
19
+ return $envVarValue
20
+ }
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ # Placeholder for future tests
@@ -0,0 +1,41 @@
1
+ <#
2
+ ===================== Error Handling =====================
3
+ .Description
4
+ This module contains functions that perform error handling
5
+ actions.
6
+ For more information, please read description of
7
+ each function.
8
+ #>
9
+
10
+ <#
11
+ .Description
12
+ Check a Rest Response and return
13
+ whether it is successful or not.
14
+
15
+ .Parameter Response
16
+
17
+ .Outputs true or false
18
+ #>
19
+ function Test-RestResponse {
20
+ param (
21
+ $Response,
22
+ [string]$ErrorMessage
23
+ )
24
+
25
+ # Check that reponse is not null. This is for cases whereexception occurs
26
+ # when call Invoke-WebRequest and no response is returned.
27
+ if ($Response -eq $null) {
28
+ Write-Host "# ERROR: Response object is null."
29
+ Write-Host "# ERROR: $ErrorMessage"
30
+ return $false
31
+ }
32
+
33
+ # Check for actual status code
34
+ if ($Response.StatusCode -le 599 -and $Response.StatusCode -ge 400) {
35
+
36
+ Write-Host "# ERROR: Status Code returned $($Response.StatusCode)"
37
+ Write-Host "# ERROR: $ErrorMessage"
38
+ throw "# ERROR: Rest api call failed."
39
+ }
40
+ return $true
41
+ }
@@ -0,0 +1,5 @@
1
+ # Place holder. Since most of the Git module requires
2
+ # invokdation of 'git' command. It cannot mock the
3
+ # git behaviour without a great deal of cearting the
4
+ # wrapper for each. Thus, this file is a place holder
5
+ # for future tests.