Skip to content

Commit

Permalink
[vcpkg ci] Add --purge-tombstones flag
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkaratarakis committed Oct 24, 2018
1 parent c6552cb commit 4202405
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions toolsrc/src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ namespace vcpkg::Commands::CI

static constexpr StringLiteral OPTION_DRY_RUN = "--dry-run";
static constexpr StringLiteral OPTION_EXCLUDE = "--exclude";
static constexpr StringLiteral OPTION_PURGE_TOMBSTONES = "--purge-tombstones";
static constexpr StringLiteral OPTION_XUNIT = "--x-xunit";

static constexpr std::array<CommandSetting, 2> CI_SETTINGS = {{
{OPTION_EXCLUDE, "Comma separated list of ports to skip"},
{OPTION_XUNIT, "File to output results in XUnit format (internal)"},
}};

static constexpr std::array<CommandSwitch, 1> CI_SWITCHES = {
{{OPTION_DRY_RUN, "Print out plan without execution"}}};
static constexpr std::array<CommandSwitch, 2> CI_SWITCHES = {{
{OPTION_DRY_RUN, "Print out plan without execution"},
{OPTION_PURGE_TOMBSTONES, "Purge failure tombstones and retry building the ports"},
}};

const CommandStructure COMMAND_STRUCTURE = {
Help::create_example_string("ci x64-windows"),
Expand All @@ -56,7 +59,8 @@ namespace vcpkg::Commands::CI
static UnknownCIPortsResults find_unknown_ports_for_ci(const VcpkgPaths& paths,
const std::set<std::string>& exclusions,
const Dependencies::PortFileProvider& provider,
const std::vector<FeatureSpec>& fspecs)
const std::vector<FeatureSpec>& fspecs,
const bool purge_tombstones)
{
UnknownCIPortsResults ret;

Expand All @@ -77,7 +81,7 @@ namespace vcpkg::Commands::CI

vcpkg::Cache<Triplet, Build::PreBuildInfo> pre_build_info_cache;

auto action_plan = Dependencies::create_feature_install_plan(provider, fspecs, StatusParagraphs{});
auto action_plan = Dependencies::create_feature_install_plan(provider, fspecs, StatusParagraphs {});

for (auto&& action : action_plan)
{
Expand All @@ -89,7 +93,7 @@ namespace vcpkg::Commands::CI
{
auto triplet = p->spec.triplet();

const Build::BuildPackageConfig build_config{
const Build::BuildPackageConfig build_config {
*scf, triplet, paths.port_dir(p->spec), install_plan_options, p->feature_list};

auto dependency_abis =
Expand Down Expand Up @@ -126,9 +130,16 @@ namespace vcpkg::Commands::CI
auto archive_path = archives_root_dir / archive_subpath;
auto archive_tombstone_path = archives_root_dir / "fail" / archive_subpath;

if (purge_tombstones)
{
std::error_code ec;
fs.remove(archive_tombstone_path, ec); // Ignore error
}

bool b_will_build = false;

ret.features.emplace(p->spec, std::vector<std::string>{p->feature_list.begin(), p->feature_list.end()});
ret.features.emplace(p->spec,
std::vector<std::string> {p->feature_list.begin(), p->feature_list.end()});

if (Util::Sets::contains(exclusions, p->spec.name()))
{
Expand Down Expand Up @@ -183,7 +194,8 @@ namespace vcpkg::Commands::CI
exclusions_set.insert(exclusions.begin(), exclusions.end());
}

auto is_dry_run = Util::Sets::contains(options.switches, OPTION_DRY_RUN);
const auto is_dry_run = Util::Sets::contains(options.switches, OPTION_DRY_RUN);
const auto purge_tombstones = Util::Sets::contains(options.switches, OPTION_PURGE_TOMBSTONES);

std::vector<Triplet> triplets;
for (const std::string& triplet : args.command_arguments)
Expand Down Expand Up @@ -222,7 +234,8 @@ namespace vcpkg::Commands::CI
std::vector<PackageSpec> specs = PackageSpec::to_package_specs(all_ports, triplet);
// Install the default features for every package
auto all_fspecs = Util::fmap(specs, [](auto& spec) { return FeatureSpec(spec, ""); });
auto split_specs = find_unknown_ports_for_ci(paths, exclusions_set, paths_port_file, all_fspecs);
auto split_specs =
find_unknown_ports_for_ci(paths, exclusions_set, paths_port_file, all_fspecs, purge_tombstones);
auto fspecs = FullPackageSpec::to_feature_specs(split_specs.unknown);

for (auto&& fspec : fspecs)
Expand Down Expand Up @@ -292,7 +305,7 @@ namespace vcpkg::Commands::CI
for (auto&& result : known_result)
{
xunit_doc +=
Install::InstallSummary::xunit_result(result.first, Chrono::ElapsedTime{}, result.second);
Install::InstallSummary::xunit_result(result.first, Chrono::ElapsedTime {}, result.second);
}
}

Expand Down

0 comments on commit 4202405

Please sign in to comment.