validation-pipeline.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. # Validation pipeline for manifest on pull requests.
  2. # Name of the run
  3. name: '$(Build.DefinitionName)-$(Build.DefinitionVersion)-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)-$(Rev:r)'
  4. trigger: none
  5. pr:
  6. branches:
  7. include:
  8. - master
  9. paths:
  10. include:
  11. - manifests
  12. jobs:
  13. # Agent phase. Process pull request changes and validate manifests.
  14. - job: 'FileValidation'
  15. displayName: 'Pull Request Validation'
  16. pool:
  17. vmImage: 'windows-latest'
  18. variables:
  19. skipComponentGovernanceDetection: ${{ true }}
  20. runCodesignValidationInjection: ${{ false }}
  21. steps:
  22. # Downloads all the setup files and its dependencies.
  23. - task: AzureCLI@1
  24. displayName: 'Azure Setup'
  25. inputs:
  26. azureSubscription: '$(WinGet.Subscription)'
  27. scriptLocation: inlineScript
  28. inlineScript: 'az storage blob download-batch -d . --pattern * -s servicewrapper --output none'
  29. env:
  30. AZURE_STORAGE_CONNECTION_STRING: $(ValidationStorageAccountConnectionString)
  31. # WinGet setup
  32. - script: 'winget_validation_setup.cmd'
  33. name: 'wingetsetup'
  34. displayName: 'WinGet Setup'
  35. workingDirectory: scripts
  36. env:
  37. HOST_KEY: $(AzureFunctionHostKey)
  38. SMART_SCREEN_ENDPOINT: $(AzFuncSmartScreenEndpoint)
  39. DOMAIN_URLS_VALIDATION_ENDPOINT: $(AzFuncDomainUrlValEndpoint)
  40. MANIFEST_POLICY_ENDPOINT: $(AzFuncManifestPolicyEndpoint)
  41. SCAN_ENDPOINT: $(AzFuncScanEndpoint)
  42. INSTALLATION_ENDPOINT: $(AzFuncInstallationVerificationEndpoint)
  43. LABEL_ENDPOINT: $(AzFuncSetLabelOnPullRequestEndpoint)
  44. CLEANUP_ENDPOINT: $(AzFuncCleanupEndpoint)
  45. LABEL_KEY: $(AzureFunctionLabelKey)
  46. CATALOG_CONTENT_VERIFICATION_ENDPOINT: $(AzFuncCatalogContentVerificationEndpoint)
  47. # Validates integrity of pull request.
  48. - task: CmdLine@2
  49. displayName: 'Validate Pull Request'
  50. inputs:
  51. script: 'WinGetSvcWrapper.exe process-pr --operationId %BUILD_BUILDNUMBER%'
  52. failOnStderr: true
  53. condition: succeeded()
  54. env:
  55. ValidationConnectionString: $(ValidationStorageAccountConnectionString)
  56. GithubRepository: $(GithubRepository)
  57. GithubServiceAccountToken: $(GithubServiceAccountToken)
  58. ExecutionEnvironment: $(ExecutionEnvironment)
  59. DIApplicationInsightKey: $(DIApplicationInsightKey)
  60. WinGet:AppConfig:Primary: $(AppConfigPrimary)
  61. WinGet:AppConfig:Secondary: $(AppConfigSecondary)
  62. # Validates manifest integrity.
  63. - task: CmdLine@2
  64. displayName: 'Validate Manifest'
  65. inputs:
  66. script: 'WinGetSvcWrapper.exe validate-manifests --operationId %BUILD_BUILDNUMBER%'
  67. failOnStderr: true
  68. condition: succeeded()
  69. env:
  70. ValidationConnectionString: $(ValidationStorageAccountConnectionString)
  71. DIApplicationInsightKey: $(DIApplicationInsightKey)
  72. WinGet:AppConfig:Primary: $(AppConfigPrimary)
  73. WinGet:AppConfig:Secondary: $(AppConfigSecondary)
  74. # Validates manifest dependencies.
  75. - task: CmdLine@2
  76. displayName: 'Validate Manifest Dependencies'
  77. inputs:
  78. script: 'WinGetSvcWrapper.exe validate-dependencies --operationId %BUILD_BUILDNUMBER%'
  79. failOnStderr: true
  80. condition: succeeded()
  81. env:
  82. ValidationConnectionString: $(ValidationStorageAccountConnectionString)
  83. CacheConnectionString: $(CacheStorageAccountConnectionString)
  84. DIApplicationInsightKey: $(DIApplicationInsightKey)
  85. WinGet:AppConfig:Primary: $(AppConfigPrimary)
  86. WinGet:AppConfig:Secondary: $(AppConfigSecondary)
  87. # Agentless phase. Depends on previous job.
  88. - job: 'ContentValidation'
  89. pool: server
  90. displayName: 'Manifest Content Validation'
  91. timeoutInMinutes: 1500
  92. dependsOn:
  93. - 'FileValidation'
  94. variables:
  95. HostKeySecret: $[ dependencies.FileValidation.outputs['wingetsetup.hostkey']]
  96. SmartScreenEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.smartScreenEndpoint']]
  97. DomainUrlValidationEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.domainUrlValidationEndpoint']]
  98. ManiestPolicyEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.manifestPolicyEndpoint']]
  99. steps:
  100. # Scans all the urls from manifest contents.
  101. - task: AzureFunction@1
  102. displayName: 'URLs Validation'
  103. inputs:
  104. function: '$(SmartScreenEndpointSecret)'
  105. key: '$(HostKeySecret)'
  106. body: |
  107. {
  108. "operationId": "$(Build.BuildNumber)",
  109. "BuildId": "$(Build.BuildId)",
  110. "PlanUrl": "$(system.CollectionUri)",
  111. "HubName": "$(system.HostType)",
  112. "ProjectId": "$(system.TeamProjectId)",
  113. "PlanId": "$(system.PlanId)",
  114. "JobId": "$(system.JobId)",
  115. "TimelineId": "$(system.TimelineId)",
  116. "TaskInstanceId": "$(system.TaskInstanceId)",
  117. "AuthToken": "$(system.AccessToken)"
  118. }
  119. waitForCompletion: "true"
  120. # Domain url validations.
  121. - task: AzureFunction@1
  122. displayName: 'URL Domain validation'
  123. inputs:
  124. function: '$(DomainUrlValidationEndpointSecret)'
  125. key: '$(HostKeySecret)'
  126. body: |
  127. {
  128. "operationId": "$(Build.BuildNumber)",
  129. "BuildId": "$(Build.BuildId)",
  130. "PlanUrl": "$(system.CollectionUri)",
  131. "HubName": "$(system.HostType)",
  132. "ProjectId": "$(system.TeamProjectId)",
  133. "PlanId": "$(system.PlanId)",
  134. "JobId": "$(system.JobId)",
  135. "TimelineId": "$(system.TimelineId)",
  136. "TaskInstanceId": "$(system.TaskInstanceId)",
  137. "AuthToken": "$(system.AccessToken)"
  138. }
  139. waitForCompletion: "true"
  140. # Manifest policy checks.
  141. - task: AzureFunction@1
  142. displayName: 'Manifest Policy Validation'
  143. inputs:
  144. function: '$(ManiestPolicyEndpointSecret)'
  145. key: '$(HostKeySecret)'
  146. body: |
  147. {
  148. "operationId": "$(Build.BuildNumber)",
  149. "BuildId": "$(Build.BuildId)",
  150. "PlanUrl": "$(system.CollectionUri)",
  151. "HubName": "$(system.HostType)",
  152. "ProjectId": "$(system.TeamProjectId)",
  153. "PlanId": "$(system.PlanId)",
  154. "JobId": "$(system.JobId)",
  155. "TimelineId": "$(system.TimelineId)",
  156. "TaskInstanceId": "$(system.TaskInstanceId)",
  157. "AuthToken": "$(system.AccessToken)"
  158. }
  159. waitForCompletion: "true"
  160. # Agentless phase. Depends on previous job.
  161. - job: 'InstallerValidation'
  162. pool: server
  163. displayName: 'Installer Validation'
  164. timeoutInMinutes: 1500
  165. dependsOn:
  166. - 'FileValidation'
  167. - 'ContentValidation'
  168. variables:
  169. HostKeySecret: $[ dependencies.FileValidation.outputs['wingetsetup.hostkey']]
  170. ScanEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.scanEndpoint']]
  171. InstallationEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.installationEndpoint']]
  172. steps:
  173. # Scan installers in manifests.
  174. - task: AzureFunction@1
  175. displayName: 'Installers Scan'
  176. inputs:
  177. function: '$(ScanEndpointSecret)'
  178. key: '$(HostKeySecret)'
  179. body: |
  180. {
  181. "operationId": "$(Build.BuildNumber)",
  182. "BuildId": "$(Build.BuildId)",
  183. "PlanUrl": "$(system.CollectionUri)",
  184. "HubName": "$(system.HostType)",
  185. "ProjectId": "$(system.TeamProjectId)",
  186. "PlanId": "$(system.PlanId)",
  187. "JobId": "$(system.JobId)",
  188. "TimelineId": "$(system.TimelineId)",
  189. "TaskInstanceId": "$(system.TaskInstanceId)",
  190. "AuthToken": "$(system.AccessToken)"
  191. }
  192. waitForCompletion: "true"
  193. # Validates installation.
  194. - task: AzureFunction@1
  195. displayName: 'Installation Validation'
  196. inputs:
  197. function: '$(InstallationEndpointSecret)'
  198. key: '$(HostKeySecret)'
  199. body: |
  200. {
  201. "operationId": "$(Build.BuildNumber)",
  202. "BuildId": "$(Build.BuildId)",
  203. "PlanUrl": "$(system.CollectionUri)",
  204. "HubName": "$(system.HostType)",
  205. "ProjectId": "$(system.TeamProjectId)",
  206. "PlanId": "$(system.PlanId)",
  207. "JobId": "$(system.JobId)",
  208. "TimelineId": "$(system.TimelineId)",
  209. "TaskInstanceId": "$(system.TaskInstanceId)",
  210. "AuthToken": "$(system.AccessToken)"
  211. }
  212. waitForCompletion: "true"
  213. # Agentless phase. Depends on previous job.
  214. - job: 'CatalogContentVerification'
  215. pool: server
  216. displayName: 'Catalog Content Verification'
  217. timeoutInMinutes: 1500
  218. dependsOn:
  219. - 'FileValidation'
  220. - 'ContentValidation'
  221. - 'InstallerValidation'
  222. variables:
  223. HostKeySecret: $[ dependencies.FileValidation.outputs['wingetsetup.hostkey']]
  224. CatalogContentVerificationEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.catalogContentVerificationEndpoint']]
  225. steps:
  226. # Catalog content verification
  227. - task: AzureFunction@1
  228. displayName: 'Catalog Content Verification'
  229. inputs:
  230. function: '$(CatalogContentVerificationEndpointSecret)'
  231. key: '$(HostKeySecret)'
  232. body: |
  233. {
  234. "operationId": "$(Build.BuildNumber)",
  235. "BuildId": "$(Build.BuildId)",
  236. "PlanUrl": "$(system.CollectionUri)",
  237. "HubName": "$(system.HostType)",
  238. "ProjectId": "$(system.TeamProjectId)",
  239. "PlanId": "$(system.PlanId)",
  240. "JobId": "$(system.JobId)",
  241. "TimelineId": "$(system.TimelineId)",
  242. "TaskInstanceId": "$(system.TaskInstanceId)",
  243. "AuthToken": "$(system.AccessToken)"
  244. }
  245. waitForCompletion: "true"
  246. # Agentless phase. Runs even if previous jobs failed.
  247. - job: 'postvalidation'
  248. pool: server
  249. displayName: 'Post Validation'
  250. dependsOn:
  251. - 'FileValidation'
  252. - 'ContentValidation'
  253. - 'InstallerValidation'
  254. - 'CatalogContentVerification'
  255. condition: succeededOrFailed()
  256. variables:
  257. HostKeySecret: $[ dependencies.FileValidation.outputs['wingetsetup.hostkey']]
  258. LabelKeySecret : $[ dependencies.FileValidation.outputs['wingetsetup.labelkey']]
  259. LabelEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.labelEndpoint']]
  260. RepositoryId: $[ dependencies.FileValidation.outputs['wingetsetup.repoId']]
  261. CleanupEndpointSecret: $[ dependencies.filevalidation.outputs['wingetsetup.cleanupEndpoint']]
  262. steps:
  263. # Set label in GitHub PullRequest.
  264. - task: AzureFunction@1
  265. displayName: 'Set Label'
  266. condition: eq(variables['WinGet.RepositoryType'], 'GitHub')
  267. inputs:
  268. function: '$(LabelEndpointSecret)'
  269. key: '$(LabelKeySecret)'
  270. body: |
  271. {
  272. "operationId": "$(Build.BuildNumber)",
  273. "PlanUrl": "$(system.CollectionUri)",
  274. "BuildId": "$(Build.BuildId)",
  275. "HubName": "$(system.HostType)",
  276. "ProjectId": "$(system.TeamProjectId)",
  277. "PlanId": "$(system.PlanId)",
  278. "JobId": "$(system.JobId)",
  279. "TimelineId": "$(system.TimelineId)",
  280. "TaskInstanceId": "$(system.TaskInstanceId)",
  281. "AuthToken": "$(system.AccessToken)",
  282. "BuildRepositoryId": "$(RepositoryId)",
  283. "PullRequestNumber": "$(System.PullRequest.PullRequestNumber)",
  284. }
  285. waitForCompletion: "true"
  286. # Cleanup resources.
  287. - task: AzureFunction@1
  288. displayName: 'Validation cleanup'
  289. inputs:
  290. function: '$(CleanupEndpointSecret)'
  291. key: '$(HostKeySecret)'
  292. body: |
  293. {
  294. "operationId": "$(Build.BuildNumber)",
  295. "PlanUrl": "$(system.CollectionUri)",
  296. "BuildId": "$(Build.BuildId)",
  297. "HubName": "$(system.HostType)",
  298. "ProjectId": "$(system.TeamProjectId)",
  299. "PlanId": "$(system.PlanId)",
  300. "JobId": "$(system.JobId)",
  301. "TimelineId": "$(system.TimelineId)",
  302. "TaskInstanceId": "$(system.TaskInstanceId)",
  303. "AuthToken": "$(system.AccessToken)"
  304. }
  305. waitForCompletion: "true"