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

[VMR] Use CopyFiles@2 task instead of manual copying #45479

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 24 additions & 64 deletions eng/pipelines/templates/jobs/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,70 +496,30 @@ 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
- task: CopyFiles@2
displayName: Prepare BuildLogs staging directory
inputs:
SourceFolder: '$(sourcesPath)'
Contents: |
artifacts/log/**
artifacts/scenario-tests/**/*.binlog
artifacts/TestResults/**/*.binlog
artifacts/TestResults/**/*.diff
artifacts/TestResults/**/Updated*.txt
artifacts/TestResults/**/*.trx
artifacts/TestResults/**/*.xml
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()

Expand Down
6 changes: 6 additions & 0 deletions src/SourceBuild/content/repo-projects/scenario-tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@
</ItemGroup>
</Target>

<Target Name="SetAzureDevOpsVariableForScenarioTests"
Condition="'$(ContinuousIntegrationBuild)' == 'true'"
BeforeTargets="Test">
<Message Importance="High" Text="##vso[task.setvariable variable=hasScenarioTestResults]true" />
</Target>

</Project>
Loading