From 99e26480b577489a94fca300dd9070a5832716ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 16 Dec 2024 16:21:21 +0100 Subject: [PATCH 1/4] [VMR] Use CopyFiles@2 task instead of manual copying --- eng/pipelines/templates/jobs/vmr-build.yml | 82 +++++----------------- 1 file changed, 16 insertions(+), 66 deletions(-) diff --git a/eng/pipelines/templates/jobs/vmr-build.yml b/eng/pipelines/templates/jobs/vmr-build.yml index 8aaed9b0ba55..6c4a8c4cdd26 100644 --- a/eng/pipelines/templates/jobs/vmr-build.yml +++ b/eng/pipelines/templates/jobs/vmr-build.yml @@ -496,72 +496,22 @@ jobs: displayName: Run Tests timeoutInMinutes: ${{ variables.runTestsTimeout }} - - ${{ if eq(parameters.targetOS, 'windows') }}: - - # Don't use CopyFiles@2 as it encounters permissions issues because it indexes all files in the source directory graph. - - powershell: | - function CopyWithRelativeFolders($sourcePath, $targetFolder, $filter) { - Get-ChildItem -Path $sourcePath -Filter $filter -Recurse | ForEach-Object { - $targetPath = Join-Path $targetFolder (Resolve-Path -Relative $_.FullName) - New-Item -ItemType Directory -Path (Split-Path -Parent $targetPath) -Force | Out-Null - Copy-Item $_.FullName -Destination $targetPath -Force - Write-Host "Copied $_ to $targetPath" - } - } - - $targetFolder = "$(Build.ArtifactStagingDirectory)/BuildLogs/" - New-Item -ItemType Directory -Path $targetFolder -Force | Out-Null - - cd "$(sourcesPath)" - - CopyWithRelativeFolders "artifacts/log/" $targetFolder "*" - - if (Test-Path "artifacts/scenario-tests/") { - CopyWithRelativeFolders "artifacts/scenario-tests/" $targetFolder "*.binlog" - echo "##vso[task.setvariable variable=hasScenarioTestResults]true" - } - - if (Test-Path "artifacts/TestResults/*") { - CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.binlog" - CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.diff" - CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "Updated*.txt" - CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.trx" - } - displayName: Prepare BuildLogs staging directory and check assets - continueOnError: true - condition: succeededOrFailed() - - - ${{ else }}: - - # Don't use CopyFiles@2 as it encounters permissions issues because it indexes all files in the source directory graph. - - script: | - set -ex - - targetFolder=$(Build.ArtifactStagingDirectory)/BuildLogs/ - mkdir -p ${targetFolder} - - cd "$(sourcesPath)" - - find artifacts/log/ -exec cp --parents {} ${targetFolder} \; - - if [ -d "artifacts/scenario-tests/" ]; then - find artifacts/scenario-tests/ -type f -name "*.binlog" -exec cp --parents {} ${targetFolder} \; - echo "##vso[task.setvariable variable=hasScenarioTestResults]true" - fi - - if [ -d "artifacts/TestResults/" ]; then - find artifacts/TestResults/ -type f -name "*.binlog" -exec cp --parents {} ${targetFolder} \; - find artifacts/TestResults/ -type f -name "*.diff" -exec cp --parents {} ${targetFolder} \; - find artifacts/TestResults/ -type f -name "Updated*.txt" -exec cp --parents {} ${targetFolder} \; - find artifacts/TestResults/ -type f -name "*.trx" -exec cp --parents {} ${targetFolder} \; - fi - - if [[ "${{ parameters.buildSourceOnly }}" == "True" ]]; then - find artifacts/prebuilt-report/ -exec cp --parents {} ${targetFolder} \; - fi - displayName: Prepare BuildLogs staging directory and check assets - continueOnError: true - condition: succeededOrFailed() + - task: CopyFiles@2 + displayName: Prepare BuildLogs staging directory and check assets + inputs: + SourceFolder: '$(sourcesPath)' + Contents: | + artifacts/log/** + artifacts/scenario-tests/**/*.binlog + artifacts/TestResults/**/*.binlog + artifacts/TestResults/**/*.diff + artifacts/TestResults/**/Updated*.txt + artifacts/TestResults/**/*.trx + artifacts/prebuilt-report/** + TargetFolder: '$(Build.ArtifactStagingDirectory)/BuildLogs' + CleanTargetFolder: true + continueOnError: true + condition: succeededOrFailed() - ${{ if or(ne(variables['System.TeamProject'], 'internal'), eq(variables['Build.Reason'], 'PullRequest')) }}: - publish: $(Build.ArtifactStagingDirectory)/BuildLogs From 065107a08ce9ce61b39128247a1148a2b9398723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 16 Dec 2024 17:41:29 +0100 Subject: [PATCH 2/4] Set hasScenarioTestResults via msbuild --- src/SourceBuild/content/repo-projects/scenario-tests.proj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SourceBuild/content/repo-projects/scenario-tests.proj b/src/SourceBuild/content/repo-projects/scenario-tests.proj index a6b02a5a3e38..1a843d0a8253 100644 --- a/src/SourceBuild/content/repo-projects/scenario-tests.proj +++ b/src/SourceBuild/content/repo-projects/scenario-tests.proj @@ -57,4 +57,10 @@ + + + + From b8965a3a779a50a5c7d6b0a9f0f372b02cb04d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 16 Dec 2024 17:43:20 +0100 Subject: [PATCH 3/4] Upload xml test results too --- eng/pipelines/templates/jobs/vmr-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/templates/jobs/vmr-build.yml b/eng/pipelines/templates/jobs/vmr-build.yml index 6c4a8c4cdd26..45b4c0c3cf28 100644 --- a/eng/pipelines/templates/jobs/vmr-build.yml +++ b/eng/pipelines/templates/jobs/vmr-build.yml @@ -507,6 +507,7 @@ jobs: artifacts/TestResults/**/*.diff artifacts/TestResults/**/Updated*.txt artifacts/TestResults/**/*.trx + artifacts/TestResults/**/*.xml artifacts/prebuilt-report/** TargetFolder: '$(Build.ArtifactStagingDirectory)/BuildLogs' CleanTargetFolder: true From d055cd729f1fad3578e9358369e6b4e45aa4af41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 16 Dec 2024 19:44:31 +0100 Subject: [PATCH 4/4] Only copy prebuilt-report when building source-only --- eng/pipelines/templates/jobs/vmr-build.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/jobs/vmr-build.yml b/eng/pipelines/templates/jobs/vmr-build.yml index 45b4c0c3cf28..a59dc39e5c57 100644 --- a/eng/pipelines/templates/jobs/vmr-build.yml +++ b/eng/pipelines/templates/jobs/vmr-build.yml @@ -497,7 +497,7 @@ jobs: timeoutInMinutes: ${{ variables.runTestsTimeout }} - task: CopyFiles@2 - displayName: Prepare BuildLogs staging directory and check assets + displayName: Prepare BuildLogs staging directory inputs: SourceFolder: '$(sourcesPath)' Contents: | @@ -508,12 +508,21 @@ jobs: artifacts/TestResults/**/Updated*.txt artifacts/TestResults/**/*.trx artifacts/TestResults/**/*.xml - artifacts/prebuilt-report/** TargetFolder: '$(Build.ArtifactStagingDirectory)/BuildLogs' CleanTargetFolder: true continueOnError: true condition: succeededOrFailed() + - ${{ if eq(parameters.buildSourceOnly, 'True') }}: + - task: CopyFiles@2 + displayName: Copy prebuilt-report to BuildLogs + inputs: + SourceFolder: '$(sourcesPath)' + Contents: artifacts/prebuilt-report/** + TargetFolder: '$(Build.ArtifactStagingDirectory)/BuildLogs' + continueOnError: true + condition: succeededOrFailed() + - ${{ if or(ne(variables['System.TeamProject'], 'internal'), eq(variables['Build.Reason'], 'PullRequest')) }}: - publish: $(Build.ArtifactStagingDirectory)/BuildLogs artifact: $(Agent.JobName)_BuildLogs_Attempt$(System.JobAttempt)