Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Allow the postbuild pipelines to download the needed artifacts for the tests. #20588

Merged
merged 11 commits into from
May 15, 2024
94 changes: 65 additions & 29 deletions tools/devops/automation/templates/tests/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,45 +145,81 @@ steps:
AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_P12: ${{ parameters.xqaCertPass }}
AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_2_P12: ${{ parameters.xqaCertPass }}

# this could be a template, which would make everything a lot simpler BUT alas we found a bug in Azure Devops (bugs++).
# if we use a template here azure devops will throw an exception due to a foreign key constraint error in their PK_Task_tbl_PlanContext.
# The simplest way to workaround their bad code is to remove the template and that way there wont be a task issue. I suspect that
# the problem resides in the fact that this is a template within a template within a matrix.
- bash: |
sudo rm -Rf $(Build.SourcesDirectory)/artifacts
displayName: "Remove artifacts"
condition: always()

- task: DownloadPipelineArtifact@2
displayName: Download PkgsVersions.json
inputs:
allowFailedBuilds: true
patterns: '**/PkgsVersions.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download WorkloadRollback.json
inputs:
allowFailedBuilds: true
patterns: '**/WorkloadRollback.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download packages
inputs:
allowFailedBuilds: true
artifactName: not-signed-package
path: $(Build.SourcesDirectory)/artifacts/not-signed-package

- task: DownloadPipelineArtifact@2
displayName: Download test libraries
inputs:
allowFailedBuilds: true
artifactName: package-test-libraries
path: $(Build.SourcesDirectory)/artifacts/package-test-libraries

# use a diff step depending if we have been trigger by a pipeline of by a PR/Commit
- ${{ if or(contains(variables['Build.Reason'], 'ResourceTrigger'), contains(variables['Build.Reason'], 'BuildCompletion')) }}:
- download: macios
displayName: Download PkgsVersions.json
artifact: PkgsVersions

- download: macios
displayName: Download WorkloadRollback.json
artifact: WorkloadRollback

- download: macios
displayName: Download packages
artifact: not-signed-package

- download: macios
displayName: Download test libraries
artifact: package-test-libraries

- pwsh: |
Get-ChildItem -Path "$(Pipeline.Workspace)/macios" -Recurse -Force
displayName: 'Display downloads'
timeoutInMinutes: 5

# the default location when downloading is $(Pipeline.Workspace)/<pipeline resource identifier>/<artifact name>
- bash: |
source="$PIPELINE_WORKSPACE/macios"
destination="$BUILD_SOURCESDIRECTORY/artifacts"
# move all the files from the source to the destination
mv -fv "$source" "$destination"
displayName: Move artifacts to the expected location

- ${{ else }}:
- task: DownloadPipelineArtifact@2
displayName: Download PkgsVersions.json
inputs:
allowFailedBuilds: true
patterns: '**/PkgsVersions.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download WorkloadRollback.json
inputs:
allowFailedBuilds: true
patterns: '**/WorkloadRollback.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download packages
inputs:
allowFailedBuilds: true
artifactName: not-signed-package
path: $(Build.SourcesDirectory)/artifacts/not-signed-package

- task: DownloadPipelineArtifact@2
displayName: Download test libraries
inputs:
allowFailedBuilds: true
artifactName: package-test-libraries
path: $(Build.SourcesDirectory)/artifacts/package-test-libraries

# print the downloads to make our life easier on debug
- pwsh: |
Get-ChildItem -Path $(Build.SourcesDirectory)/artifacts -Recurse -Force
displayName: 'Display downloads'
timeoutInMinutes: 5


- pwsh: |
$dir = "$(Build.SourcesDirectory)/artifacts"
$versionsPath = "$dir/${{ parameters.uploadPrefix }}PkgsVersions/PkgsVersions.json"
Expand Down