From 286930a8d93028430f844d41aa99dabbec7d5aba Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 8 May 2024 19:18:51 -0400 Subject: [PATCH 1/8] [CI] Allow the postbuild pipelines to download the needed artifacts for the tests. --- .../automation/templates/tests/build.yml | 38 +-------- .../templates/tests/download-artifacts.yml | 80 +++++++++++++++---- 2 files changed, 65 insertions(+), 53 deletions(-) diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index c8f8ea80772a..0dc4d390faf4 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -145,43 +145,7 @@ steps: AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_P12: ${{ parameters.xqaCertPass }} AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_2_P12: ${{ parameters.xqaCertPass }} -- 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 - -- pwsh: | - Get-ChildItem -Path $(Build.SourcesDirectory)/artifacts -Recurse -Force - displayName: 'Display downloads' - timeoutInMinutes: 5 +- template: ./download-artifacts.yml - pwsh: | diff --git a/tools/devops/automation/templates/tests/download-artifacts.yml b/tools/devops/automation/templates/tests/download-artifacts.yml index df4db968ab67..18e2d986015f 100644 --- a/tools/devops/automation/templates/tests/download-artifacts.yml +++ b/tools/devops/automation/templates/tests/download-artifacts.yml @@ -1,21 +1,69 @@ steps: -- pwsh: | - if (Test-Path "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/Reports" -PathType Container) { - Remove-Item -Path "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/Reports" -Force -Recurse - } +- bash: | + sudo rm -Rf $(Build.SourcesDirectory)/artifacts displayName: "Remove artifacts" condition: always() -# Download the test report to write the comment. -- task: DownloadPipelineArtifact@2 - displayName: Download Test Summary - continueOnError: true # there are tests that do not have the test results, so far only the install_sources has it - inputs: - patterns: "**/TestSummary.md" - allowFailedBuilds: true - path: $(System.DefaultWorkingDirectory)\Reports - -- pwsh: - Get-ChildItem $(System.DefaultWorkingDirectory)/Reports -Recurse - displayName: "Debug downloaded artifacts." +# 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 + patterns: '**/PkgsVersions.json' + + - download: macios + displayName: Download WorkloadRollback.json + patterns: '**/WorkloadRollback.json' + + - download: macios + displayName: Download packages + artifactName: not-signed-package + + - download: macios + displayName: Download test libraries + artifactName: package-test-libraries + + # the default location when downloading is $(Pipeline.Workspace)// + - pwsh: | + $source = "$(Pipeline.Workspace)/macios" + $destination = "$(Build.SourcesDirectory)/artifacts + New-Item -ItemType Directory -Force -Path $destination + Write-Host "Moving content from $source to $destination" + # move all the files from the source to the destination + Get-ChildItem -Path $source -Recurse -File | Move-Item -Destination $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 From 72b246def3038a266b9d7eef598db1000269abae Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 9 May 2024 16:51:28 -0400 Subject: [PATCH 2/8] The lack of consistency in the AZP tasks is fascinating. --- .../devops/automation/templates/tests/download-artifacts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/devops/automation/templates/tests/download-artifacts.yml b/tools/devops/automation/templates/tests/download-artifacts.yml index 18e2d986015f..d300d33c0fb9 100644 --- a/tools/devops/automation/templates/tests/download-artifacts.yml +++ b/tools/devops/automation/templates/tests/download-artifacts.yml @@ -17,11 +17,11 @@ steps: - download: macios displayName: Download packages - artifactName: not-signed-package + artifact: not-signed-package - download: macios displayName: Download test libraries - artifactName: package-test-libraries + artifact: package-test-libraries # the default location when downloading is $(Pipeline.Workspace)// - pwsh: | From 99b7e822472222b6d7058122e38cb38d1e72e838 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Mon, 13 May 2024 17:09:33 -0400 Subject: [PATCH 3/8] Workaround peoples bad code. --- .../automation/templates/tests/build.yml | 73 ++++++++++++++++++- .../templates/tests/download-artifacts.yml | 69 ------------------ 2 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 tools/devops/automation/templates/tests/download-artifacts.yml diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index 0dc4d390faf4..afeba6c0175d 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -145,8 +145,77 @@ steps: AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_P12: ${{ parameters.xqaCertPass }} AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_2_P12: ${{ parameters.xqaCertPass }} -- template: ./download-artifacts.yml - +# 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() + +# 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 + patterns: '**/PkgsVersions.json' + + - download: macios + displayName: Download WorkloadRollback.json + patterns: '**/WorkloadRollback.json' + + - download: macios + displayName: Download packages + artifact: not-signed-package + + - download: macios + displayName: Download test libraries + artifact: package-test-libraries + + # the default location when downloading is $(Pipeline.Workspace)// + - pwsh: | + $source = "$(Pipeline.Workspace)/macios" + $destination = "$(Build.SourcesDirectory)/artifacts + New-Item -ItemType Directory -Force -Path $destination + Write-Host "Moving content from $source to $destination" + # move all the files from the source to the destination + Get-ChildItem -Path $source -Recurse -File | Move-Item -Destination $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" diff --git a/tools/devops/automation/templates/tests/download-artifacts.yml b/tools/devops/automation/templates/tests/download-artifacts.yml deleted file mode 100644 index d300d33c0fb9..000000000000 --- a/tools/devops/automation/templates/tests/download-artifacts.yml +++ /dev/null @@ -1,69 +0,0 @@ -steps: - -- bash: | - sudo rm -Rf $(Build.SourcesDirectory)/artifacts - displayName: "Remove artifacts" - condition: always() - -# 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 - patterns: '**/PkgsVersions.json' - - - download: macios - displayName: Download WorkloadRollback.json - patterns: '**/WorkloadRollback.json' - - - download: macios - displayName: Download packages - artifact: not-signed-package - - - download: macios - displayName: Download test libraries - artifact: package-test-libraries - - # the default location when downloading is $(Pipeline.Workspace)// - - pwsh: | - $source = "$(Pipeline.Workspace)/macios" - $destination = "$(Build.SourcesDirectory)/artifacts - New-Item -ItemType Directory -Force -Path $destination - Write-Host "Moving content from $source to $destination" - # move all the files from the source to the destination - Get-ChildItem -Path $source -Recurse -File | Move-Item -Destination $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 From 2a7d83cd79a58f23d27b53acfdcc0def2cc1a682 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Mon, 13 May 2024 18:04:57 -0400 Subject: [PATCH 4/8] Fix artifact names. --- .../automation/templates/tests/build.yml | 4 ++-- .../templates/tests/download-artifacts.yml | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tools/devops/automation/templates/tests/download-artifacts.yml diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index afeba6c0175d..5447aa6bdef7 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -158,11 +158,11 @@ steps: - ${{ if or(contains(variables['Build.Reason'], 'ResourceTrigger'), contains(variables['Build.Reason'], 'BuildCompletion')) }}: - download: macios displayName: Download PkgsVersions.json - patterns: '**/PkgsVersions.json' + artifact: PkgsVersions - download: macios displayName: Download WorkloadRollback.json - patterns: '**/WorkloadRollback.json' + artifact: WorkloadRollback - download: macios displayName: Download packages diff --git a/tools/devops/automation/templates/tests/download-artifacts.yml b/tools/devops/automation/templates/tests/download-artifacts.yml new file mode 100644 index 000000000000..df4db968ab67 --- /dev/null +++ b/tools/devops/automation/templates/tests/download-artifacts.yml @@ -0,0 +1,21 @@ +steps: + +- pwsh: | + if (Test-Path "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/Reports" -PathType Container) { + Remove-Item -Path "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY/Reports" -Force -Recurse + } + displayName: "Remove artifacts" + condition: always() + +# Download the test report to write the comment. +- task: DownloadPipelineArtifact@2 + displayName: Download Test Summary + continueOnError: true # there are tests that do not have the test results, so far only the install_sources has it + inputs: + patterns: "**/TestSummary.md" + allowFailedBuilds: true + path: $(System.DefaultWorkingDirectory)\Reports + +- pwsh: + Get-ChildItem $(System.DefaultWorkingDirectory)/Reports -Recurse + displayName: "Debug downloaded artifacts." From 22dbcbcdfee77411d278312efa915b37fe7795ad Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 14 May 2024 11:40:16 -0400 Subject: [PATCH 5/8] Missing closing quote. --- tools/devops/automation/templates/tests/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index 5447aa6bdef7..e279e276395f 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -175,7 +175,7 @@ steps: # the default location when downloading is $(Pipeline.Workspace)// - pwsh: | $source = "$(Pipeline.Workspace)/macios" - $destination = "$(Build.SourcesDirectory)/artifacts + $destination = "$(Build.SourcesDirectory)/artifacts" New-Item -ItemType Directory -Force -Path $destination Write-Host "Moving content from $source to $destination" # move all the files from the source to the destination From a1838f121cd913808e687506be870b6f66f964bc Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 14 May 2024 13:58:40 -0400 Subject: [PATCH 6/8] More debugging. --- tools/devops/automation/templates/tests/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index e279e276395f..5ad620af7fad 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -172,6 +172,11 @@ steps: 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)// - pwsh: | $source = "$(Pipeline.Workspace)/macios" From 5c13500610d0426c5cb6d8807a00e0aad8334455 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 15 May 2024 06:33:53 -0400 Subject: [PATCH 7/8] Use move to keep dir structure. --- tools/devops/automation/templates/tests/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index 5ad620af7fad..9b13b02c0f58 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -184,7 +184,7 @@ steps: New-Item -ItemType Directory -Force -Path $destination Write-Host "Moving content from $source to $destination" # move all the files from the source to the destination - Get-ChildItem -Path $source -Recurse -File | Move-Item -Destination $destination + Move-Item -Path $source -Destination $destination -Force displayName: Move artifacts to the expected location - ${{ else }}: From 8f39418535c1a71345de0dc458be561d5f5f9edc Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 15 May 2024 11:43:49 -0400 Subject: [PATCH 8/8] Resort to bash which we can trust. --- tools/devops/automation/templates/tests/build.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/devops/automation/templates/tests/build.yml b/tools/devops/automation/templates/tests/build.yml index 9b13b02c0f58..87480545725f 100644 --- a/tools/devops/automation/templates/tests/build.yml +++ b/tools/devops/automation/templates/tests/build.yml @@ -178,13 +178,11 @@ steps: timeoutInMinutes: 5 # the default location when downloading is $(Pipeline.Workspace)// - - pwsh: | - $source = "$(Pipeline.Workspace)/macios" - $destination = "$(Build.SourcesDirectory)/artifacts" - New-Item -ItemType Directory -Force -Path $destination - Write-Host "Moving content from $source to $destination" + - bash: | + source="$PIPELINE_WORKSPACE/macios" + destination="$BUILD_SOURCESDIRECTORY/artifacts" # move all the files from the source to the destination - Move-Item -Path $source -Destination $destination -Force + mv -fv "$source" "$destination" displayName: Move artifacts to the expected location - ${{ else }}: