From 3b0080e3b0d395de7551cc2ce1ec89189e539eab Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Tue, 19 May 2020 13:43:30 -0700 Subject: [vcpkg] Harden file removals and clean directory contents in "CI" inside vcpkg itself. (#11432) `files.h/files.cpp`: * Add end and else comments to all macros. * Add "remove_all_inside" function which empties a directory without actually deleting the directory. This is necessary to handle the case where the directory is actually a directory symlink. * Change remove_all to use std::remove when VCPKG_USE_STD_FILESYSTEM is set; this will engage POSIX delete support available on current Win10. `commands.ci.cpp`: empty "installed". `*/initialize_environment.*`: No longer clean the directories outside the tool. `ci-step.ps1`: Remove unused console output tee-ing. --- .../linux/initialize-environment.sh | 4 --- .../azure-pipelines/osx/initialize-environment.sh | 9 ------- .../azure-pipelines/windows/azure-pipelines.yml | 6 ----- scripts/azure-pipelines/windows/ci-step.ps1 | 6 +---- .../windows/initialize-environment.ps1 | 29 ++++++++++++---------- 5 files changed, 17 insertions(+), 37 deletions(-) (limited to 'scripts') diff --git a/scripts/azure-pipelines/linux/initialize-environment.sh b/scripts/azure-pipelines/linux/initialize-environment.sh index 5346345a5..1cbdd3326 100755 --- a/scripts/azure-pipelines/linux/initialize-environment.sh +++ b/scripts/azure-pipelines/linux/initialize-environment.sh @@ -6,7 +6,3 @@ if [ ! -d "archives" ]; then ln -s /archives archives fi - -rm -rf installed -rm -rf buildtrees -rm -rf packages/* diff --git a/scripts/azure-pipelines/osx/initialize-environment.sh b/scripts/azure-pipelines/osx/initialize-environment.sh index 5eeba4255..6f42a809a 100755 --- a/scripts/azure-pipelines/osx/initialize-environment.sh +++ b/scripts/azure-pipelines/osx/initialize-environment.sh @@ -4,29 +4,20 @@ # Sets up the environment for MacOS runs of vcpkg CI -rm -rf installed || true mkdir -p ~/Data/installed || true ln -s ~/Data/installed -rm -rf ~/Data/installed/* || true -rm -rf buildtrees || true mkdir -p ~/Data/buildtrees || true ln -s ~/Data/buildtrees -rm -rf ~/Data/buildtrees/* || true -rm -rf packages || true mkdir -p ~/Data/packages || true ln -s ~/Data/packages -rm -rf ~/Data/packages/* || true rm archives || rm -rf archives || true ln -s ~/Data/archives -rm -rf downloads || true mkdir -p ~/Data/downloads || true ln -s ~/Data/downloads -if [ -d downloads/ ]; then #delete downloaded files that have not been used in 7 days find downloads/ -maxdepth 1 -type f ! -atime 7 -exec rm -f {} \; -fi diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index 71ffc7828..9d4de6794 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -41,12 +41,6 @@ jobs: cp $xmlPath $(Build.ArtifactStagingDirectory) Move-Item $xmlPath -Destination $outputXmlPath - # already in DevOps, no need for extra copies - rm $(System.DefaultWorkingDirectory)\console-out.txt -ErrorAction Ignore - - Remove-Item "$(System.DefaultWorkingDirectory)\buildtrees\*" -Recurse -errorAction silentlycontinue - Remove-Item "$(System.DefaultWorkingDirectory)\packages\*" -Recurse -errorAction silentlycontinue - Remove-Item "$(System.DefaultWorkingDirectory)\installed\*" -Recurse -errorAction silentlycontinue displayName: 'Collect logs and cleanup build' - task: PowerShell@2 diff --git a/scripts/azure-pipelines/windows/ci-step.ps1 b/scripts/azure-pipelines/windows/ci-step.ps1 index 0e07895e0..f0aee4dfd 100644 --- a/scripts/azure-pipelines/windows/ci-step.ps1 +++ b/scripts/azure-pipelines/windows/ci-step.ps1 @@ -125,14 +125,13 @@ if (!$?) { throw "bootstrap failed" } Write-Host "Bootstrapping vcpkg ... done." $ciXmlPath = "$vcpkgRootDir\test-full-ci.xml" -$consoleOuputPath = "$vcpkgRootDir\console-out.txt" Remove-VcpkgItem $ciXmlPath $env:VCPKG_FEATURE_FLAGS = "binarycaching" if (![string]::IsNullOrEmpty($OnlyIncludePorts)) { ./vcpkg install --triplet $Triplet $OnlyIncludePorts $AdditionalVcpkgFlags ` - "--x-xunit=$ciXmlPath" | Tee-Object -FilePath "$consoleOuputPath" + "--x-xunit=$ciXmlPath" } else { $exclusions = "" @@ -155,9 +154,6 @@ else { | ForEach-Object { if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.ToString() } else { $_ } } - - # Phasing out the console output (it is already saved in DevOps) Create a dummy file for now. - Set-Content -LiteralPath "$consoleOuputPath" -Value '' } Write-Host "CI test is complete" diff --git a/scripts/azure-pipelines/windows/initialize-environment.ps1 b/scripts/azure-pipelines/windows/initialize-environment.ps1 index 4bbc15665..8b1d8e8e4 100644 --- a/scripts/azure-pipelines/windows/initialize-environment.ps1 +++ b/scripts/azure-pipelines/windows/initialize-environment.ps1 @@ -68,21 +68,24 @@ else } Write-Host "Linking archives => $archivesPath" -Remove-DirectorySymlink archives -cmd /c "mklink /D archives $archivesPath" +if (-Not (Test-Path archives)) { + cmd /c "mklink /D archives $archivesPath" +} Write-Host 'Linking installed => E:\installed' -Remove-DirectorySymlink installed -Remove-Item E:\installed -Recurse -Force -ErrorAction SilentlyContinue -mkdir E:\installed -cmd /c "mklink /D installed E:\installed" +if (-Not (Test-Path E:\installed)) { + mkdir E:\installed +} -Write-Host 'Linking downloads => D:\downloads' -Remove-DirectorySymlink downloads -cmd /c "mklink /D downloads D:\downloads" +if (-Not (Test-Path installed)) { + cmd /c "mklink /D installed E:\installed" +} -Write-Host 'Cleaning buildtrees' -Remove-Item buildtrees\* -Recurse -Force -errorAction silentlycontinue +Write-Host 'Linking downloads => D:\downloads' +if (-Not (Test-Path D:\downloads)) { + mkdir D:\downloads +} -Write-Host 'Cleaning packages' -Remove-Item packages\* -Recurse -Force -errorAction silentlycontinue +if (-Not (Test-Path downloads)) { + cmd /c "mklink /D downloads D:\downloads" +} -- cgit v1.2.3