From d9b4acf02d8c784927f89d23edb677408ec428af Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Wed, 27 May 2020 18:40:23 -0700 Subject: [PATCH] [vcpkg] Move CI cleaning back out of the 'ci' command into a separate command to restore cross-compilation preinstalls. (#11545) --- .../azure-pipelines/linux/azure-pipelines.yml | 1 + .../azure-pipelines/osx/azure-pipelines.yml | 1 + .../windows/azure-pipelines.yml | 7 ++++ scripts/ci.baseline.txt | 8 ----- toolsrc/include/vcpkg/commands.h | 5 +++ toolsrc/src/vcpkg/commands.ci.cpp | 10 ++---- toolsrc/src/vcpkg/commands.ciclean.cpp | 32 +++++++++++++++++++ toolsrc/src/vcpkg/commands.cpp | 1 + toolsrc/vcpkglib/vcpkglib.vcxproj | 1 + toolsrc/vcpkglib/vcpkglib.vcxproj.filters | 3 ++ 10 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 toolsrc/src/vcpkg/commands.ciclean.cpp diff --git a/scripts/azure-pipelines/linux/azure-pipelines.yml b/scripts/azure-pipelines/linux/azure-pipelines.yml index c51515148e..022fc70e4e 100644 --- a/scripts/azure-pipelines/linux/azure-pipelines.yml +++ b/scripts/azure-pipelines/linux/azure-pipelines.yml @@ -35,6 +35,7 @@ jobs: - bash: toolsrc/build.rel/vcpkg-test displayName: 'Run vcpkg tests' - powershell: | + ./vcpkg x-ci-clean $skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-linux" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt" mkdir $(System.ArtifactsDirectory)/xml-results $env:HOME = '/home/agent' diff --git a/scripts/azure-pipelines/osx/azure-pipelines.yml b/scripts/azure-pipelines/osx/azure-pipelines.yml index b06bffb6f9..e51698c452 100644 --- a/scripts/azure-pipelines/osx/azure-pipelines.yml +++ b/scripts/azure-pipelines/osx/azure-pipelines.yml @@ -36,6 +36,7 @@ jobs: - bash: toolsrc/build.rel/vcpkg-test displayName: 'Run vcpkg tests' - powershell: | + ./vcpkg x-ci-clean $skip_list = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-osx" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt" mkdir $(System.ArtifactsDirectory)/xml-results ./vcpkg ci x64-osx --x-xunit="$(System.ArtifactsDirectory)/xml-results/x64-osx.xml" --exclude=$skip_list --binarycaching diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index 327f9511a6..48f3908d26 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -20,8 +20,15 @@ jobs: inputs: filename: 'bootstrap-vcpkg.bat' - powershell: | + .\vcpkg.exe x-ci-clean $skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "${{ parameters.triplet }}" -BaselineFile "$(System.DefaultWorkingDirectory)\scripts\ci.baseline.txt" mkdir $(System.ArtifactsDirectory)\xml-results + # WORKAROUND: the x86-windows flavors of these are needed for all cross-compilation, but they are not auto-installed. + # Install them so the CI succeeds: + if ( "${{ parameters.triplet }}" -notmatch "x86-windows" -and "${{ parameters.triplet }}" -notmatch "x64-windows" ) { + .\vcpkg.exe install protobuf:x86-windows boost-build:x86-windows sqlite3:x86-windows + } + $command = ".\vcpkg.exe ci ${{ parameters.triplet }} --x-xunit=`"$(System.ArtifactsDirectory)\xml-results\${{ parameters.triplet }}.xml`" --exclude=$skipList --binarycaching" Set-Content -Path 'run_ci.cmd' -Value $command -Encoding ASCII displayName: 'Write Test Modified Ports Batch File' diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 08203a2d82..3858c85876 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -166,14 +166,6 @@ boost-test:arm-uwp=fail boost-test:x64-uwp=fail boost-wave:arm-uwp=fail boost-wave:x64-uwp=fail -# Building boost-* with arm-uwp requires the x86-windows boost-* which breaks CI testing, Ignore them -boost-atomic:arm-uwp=ignore -boost-signals:arm-uwp=ignore -boost-exception:arm-uwp=ignore -boost-regex:arm-uwp=ignore -boost-nowide:arm-uwp=ignore -boost-system:arm-uwp=ignore -boost-container:arm-uwp=ignore botan:arm64-windows=fail botan:arm-uwp=fail botan:x64-uwp=fail diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index 3ce182410f..55d6bd7aaf 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/include/vcpkg/commands.h @@ -27,6 +27,11 @@ namespace vcpkg::Commands void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet); } + namespace CIClean + { + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); + } + namespace Env { extern const CommandStructure COMMAND_STRUCTURE; diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 1e06be37d8..336d30cf2b 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -397,12 +397,6 @@ namespace vcpkg::Commands::CI const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE); - auto& filesystem = paths.get_filesystem(); - if (filesystem.is_directory(paths.installed)) - { - filesystem.remove_all_inside(paths.installed, VCPKG_LINE_INFO); - } - std::set exclusions_set; auto it_exclusions = options.settings.find(OPTION_EXCLUDE); if (it_exclusions != options.settings.end()) @@ -558,11 +552,11 @@ namespace vcpkg::Commands::CI System::print2("Total elapsed time: ", result.summary.total_elapsed_time, "\n"); result.summary.print(); } - auto& fs = paths.get_filesystem(); + auto it_xunit = options.settings.find(OPTION_XUNIT); if (it_xunit != options.settings.end()) { - fs.write_contents(fs::u8path(it_xunit->second), xunitTestResults.build_xml(), VCPKG_LINE_INFO); + paths.get_filesystem().write_contents(fs::u8path(it_xunit->second), xunitTestResults.build_xml(), VCPKG_LINE_INFO); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/toolsrc/src/vcpkg/commands.ciclean.cpp b/toolsrc/src/vcpkg/commands.ciclean.cpp new file mode 100644 index 0000000000..9c69d1931c --- /dev/null +++ b/toolsrc/src/vcpkg/commands.ciclean.cpp @@ -0,0 +1,32 @@ +#include "pch.h" + +#include +#include +#include +#include + +using namespace vcpkg; + +namespace vcpkg::Commands::CIClean +{ + void perform_and_exit(const VcpkgCmdArguments&, const VcpkgPaths& paths) + { + auto& fs = paths.get_filesystem(); + if (fs.is_directory(paths.buildtrees)) + { + fs.remove_all_inside(paths.buildtrees, VCPKG_LINE_INFO); + } + + if (fs.is_directory(paths.installed)) + { + fs.remove_all_inside(paths.installed, VCPKG_LINE_INFO); + } + + if (fs.is_directory(paths.packages)) + { + fs.remove_all_inside(paths.packages, VCPKG_LINE_INFO); + } + + Checks::exit_success(VCPKG_LINE_INFO); + } +} diff --git a/toolsrc/src/vcpkg/commands.cpp b/toolsrc/src/vcpkg/commands.cpp index 0db6ddb8f9..246f7dcdf0 100644 --- a/toolsrc/src/vcpkg/commands.cpp +++ b/toolsrc/src/vcpkg/commands.cpp @@ -48,6 +48,7 @@ namespace vcpkg::Commands {"autocomplete", &Autocomplete::perform_and_exit}, {"hash", &Hash::perform_and_exit}, {"fetch", &Fetch::perform_and_exit}, + {"x-ci-clean", &CIClean::perform_and_exit}, {"x-history", &PortHistory::perform_and_exit}, {"x-vsinstances", &X_VSInstances::perform_and_exit}, }; diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj index 803ecb0908..005b1c0dc6 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj @@ -244,6 +244,7 @@ + diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters index f0b8eb2e48..3b09b7ab1b 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters @@ -48,6 +48,9 @@ Source Files\vcpkg + + Source Files\vcpkg + Source Files\vcpkg