validation-pipeline.yaml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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: none
  6. jobs:
  7. # Agent phase. Process pull request changes and validate manifests.
  8. - job: 'FileValidation'
  9. displayName: 'Pull Request Validation'
  10. pool:
  11. vmImage: 'windows-latest'
  12. variables:
  13. skipComponentGovernanceDetection: ${{ true }}
  14. runCodesignValidationInjection: ${{ false }}
  15. steps:
  16. # Downloads all the setup files and its dependencies.
  17. - task: AzureCLI@1
  18. displayName: 'Azure Setup'
  19. inputs:
  20. azureSubscription: '$(WinGet.Subscription)'
  21. scriptLocation: inlineScript
  22. inlineScript: 'az storage blob download-batch -d . --pattern * -s servicewrapper --output none'
  23. env:
  24. AZURE_STORAGE_CONNECTION_STRING: $(ValidationStorageAccountConnectionString)
  25. # WinGet setup
  26. - script: 'winget_validation_setup.cmd'
  27. name: 'wingetsetup'
  28. displayName: 'WinGet Setup'
  29. workingDirectory: scripts
  30. env:
  31. HOST_KEY: $(AzureFunctionHostKey)
  32. SMART_SCREEN_ENDPOINT: $(AzFuncSmartScreenEndpoint)
  33. SCAN_ENDPOINT: $(AzFuncScanEndpoint)
  34. LABEL_ENDPOINT: $(AzFuncSetLabelOnPullRequestEndpoint)
  35. CLEANUP_ENDPOINT: $(AzFuncCleanupEndpoint)
  36. LABEL_KEY: $(AzureFunctionLabelKey)
  37. # Validates integrity of pull request.
  38. - task: CmdLine@2
  39. displayName: 'Validate Pull Request'
  40. inputs:
  41. script: 'WinGetSvcWrapper.exe process-pr --operationId %BUILD_BUILDNUMBER%'
  42. failOnStderr: true
  43. condition: succeeded()
  44. env:
  45. ValidationConnectionString: $(ValidationStorageAccountConnectionString)
  46. DIApplicationInsightKey: $(DIApplicationInsightKey)
  47. WinGet:AppConfig:Primary: $(AppConfigPrimary)
  48. WinGet:AppConfig:Secondary: $(AppConfigSecondary)
  49. # Validates manifest integrity.
  50. - task: CmdLine@2
  51. displayName: 'Validate Manifest'
  52. inputs:
  53. script: 'WinGetSvcWrapper.exe validate-manifests --operationId %BUILD_BUILDNUMBER%'
  54. failOnStderr: true
  55. condition: succeeded()
  56. env:
  57. ValidationConnectionString: $(ValidationStorageAccountConnectionString)
  58. DIApplicationInsightKey: $(DIApplicationInsightKey)
  59. WinGet:AppConfig:Primary: $(AppConfigPrimary)
  60. WinGet:AppConfig:Secondary: $(AppConfigSecondary)
  61. # Agentless phase. Depends on previous job.
  62. - job: 'ContentValidation'
  63. pool: server
  64. displayName: 'Manifest Content Validation'
  65. timeoutInMinutes: 1500
  66. dependsOn:
  67. - 'FileValidation'
  68. variables:
  69. HostKeySecret: $[ dependencies.FileValidation.outputs['wingetsetup.hostkey']]
  70. SmartScreenEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.smartScreenEndpoint']]
  71. ScanEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.scanEndpoint']]
  72. steps:
  73. # Scans all the urls from manifest contents.
  74. - task: AzureFunction@1
  75. displayName: 'Validation URLs in manifest files'
  76. inputs:
  77. function: '$(SmartScreenEndpointSecret)'
  78. key: '$(HostKeySecret)'
  79. body: |
  80. {
  81. "operationId": "$(Build.BuildNumber)",
  82. "BuildId": "$(Build.BuildId)",
  83. "PlanUrl": "$(system.CollectionUri)",
  84. "HubName": "$(system.HostType)",
  85. "ProjectId": "$(system.TeamProjectId)",
  86. "PlanId": "$(system.PlanId)",
  87. "JobId": "$(system.JobId)",
  88. "TimelineId": "$(system.TimelineId)",
  89. "TaskInstanceId": "$(system.TaskInstanceId)",
  90. "AuthToken": "$(system.AccessToken)"
  91. }
  92. waitForCompletion: "true"
  93. # Scan installers in manifests.
  94. - task: AzureFunction@1
  95. displayName: 'Installers Scan'
  96. inputs:
  97. function: '$(ScanEndpointSecret)'
  98. key: '$(HostKeySecret)'
  99. body: |
  100. {
  101. "operationId": "$(Build.BuildNumber)",
  102. "BuildId": "$(Build.BuildId)",
  103. "PlanUrl": "$(system.CollectionUri)",
  104. "HubName": "$(system.HostType)",
  105. "ProjectId": "$(system.TeamProjectId)",
  106. "PlanId": "$(system.PlanId)",
  107. "JobId": "$(system.JobId)",
  108. "TimelineId": "$(system.TimelineId)",
  109. "TaskInstanceId": "$(system.TaskInstanceId)",
  110. "AuthToken": "$(system.AccessToken)"
  111. }
  112. waitForCompletion: "true"
  113. # Agentless phase. Runs even if previous jobs failed.
  114. - job: 'postvalidation'
  115. pool: server
  116. displayName: 'Post Validation'
  117. dependsOn:
  118. - 'FileValidation'
  119. - 'ContentValidation'
  120. condition: succeededOrFailed()
  121. variables:
  122. HostKeySecret: $[ dependencies.FileValidation.outputs['wingetsetup.hostkey']]
  123. LabelKeySecret : $[ dependencies.FileValidation.outputs['wingetsetup.labelkey']]
  124. LabelEndpointSecret: $[ dependencies.FileValidation.outputs['wingetsetup.labelEndpoint']]
  125. RepositoryId: $[ dependencies.FileValidation.outputs['wingetsetup.repoId']]
  126. CleanupEndpointSecret: $[ dependencies.filevalidation.outputs['wingetsetup.cleanupEndpoint']]
  127. steps:
  128. # Set label in GitHub PullRequest.
  129. - task: AzureFunction@1
  130. displayName: 'Set Label'
  131. condition: eq(variables['WinGet.RepositoryType'], 'GitHub')
  132. inputs:
  133. function: '$(LabelEndpointSecret)'
  134. key: '$(LabelKeySecret)'
  135. body: |
  136. {
  137. "operationId": "$(Build.BuildNumber)",
  138. "PlanUrl": "$(system.CollectionUri)",
  139. "BuildId": "$(Build.BuildId)",
  140. "HubName": "$(system.HostType)",
  141. "ProjectId": "$(system.TeamProjectId)",
  142. "PlanId": "$(system.PlanId)",
  143. "JobId": "$(system.JobId)",
  144. "TimelineId": "$(system.TimelineId)",
  145. "TaskInstanceId": "$(system.TaskInstanceId)",
  146. "AuthToken": "$(system.AccessToken)",
  147. "BuildRepositoryId": "$(RepositoryId)",
  148. "PullRequestNumber": "$(System.PullRequest.PullRequestNumber)",
  149. }
  150. waitForCompletion: "true"
  151. # Cleanup resources.
  152. - task: AzureFunction@1
  153. displayName: 'Validation cleanup'
  154. inputs:
  155. function: '$(CleanupEndpointSecret)'
  156. key: '$(HostKeySecret)'
  157. body: |
  158. {
  159. "operationId": "$(Build.BuildNumber)",
  160. "PlanUrl": "$(system.CollectionUri)",
  161. "BuildId": "$(Build.BuildId)",
  162. "HubName": "$(system.HostType)",
  163. "ProjectId": "$(system.TeamProjectId)",
  164. "PlanId": "$(system.PlanId)",
  165. "JobId": "$(system.JobId)",
  166. "TimelineId": "$(system.TimelineId)",
  167. "TaskInstanceId": "$(system.TaskInstanceId)",
  168. "AuthToken": "$(system.AccessToken)"
  169. }
  170. waitForCompletion: "true"