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

Add option to remove unaffected ports from ci action #210

Merged
merged 6 commits into from
Oct 20, 2021
Merged
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
38 changes: 32 additions & 6 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,17 @@ namespace vcpkg::Commands::CI
static constexpr StringLiteral OPTION_XUNIT = "x-xunit";
static constexpr StringLiteral OPTION_RANDOMIZE = "x-randomize";
static constexpr StringLiteral OPTION_OUTPUT_HASHES = "output-hashes";
static constexpr StringLiteral OPTION_PARENT_HASHES = "parent-hashes";
static constexpr StringLiteral OPTION_SKIPPED_CASCADE_COUNT = "x-skipped-cascade-count";

static constexpr std::array<CommandSetting, 6> CI_SETTINGS = {
static constexpr std::array<CommandSetting, 7> CI_SETTINGS = {
{{OPTION_EXCLUDE, "Comma separated list of ports to skip"},
{OPTION_HOST_EXCLUDE, "Comma separated list of ports to skip for the host triplet"},
{OPTION_XUNIT, "File to output results in XUnit format (internal)"},
{OPTION_FAILURE_LOGS, "Directory to which failure logs will be copied"},
{OPTION_OUTPUT_HASHES, "File to output all determined package hashes"},
{OPTION_PARENT_HASHES,
"File to read package hashes for a parent CI state, to reduce the set of changed packages"},
{OPTION_SKIPPED_CASCADE_COUNT,
"Asserts that the number of --exclude and supports skips exactly equal this number"}}};

Expand Down Expand Up @@ -404,13 +407,16 @@ namespace vcpkg::Commands::CI

// This algorithm reduces an action plan to only unknown actions and their dependencies
static void reduce_action_plan(Dependencies::ActionPlan& action_plan,
const std::map<PackageSpec, Build::BuildResult>& known)
const std::map<PackageSpec, Build::BuildResult>& known,
View<std::string> parent_hashes)
{
std::set<PackageSpec> to_keep;
for (auto it = action_plan.install_actions.rbegin(); it != action_plan.install_actions.rend(); ++it)
{
auto it_known = known.find(it->spec);
if (it_known == known.end())
const auto& abi = it->abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi;
auto it_parent = std::find(parent_hashes.begin(), parent_hashes.end(), abi);
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
if (it_known == known.end() && it_parent == parent_hashes.end())
{
to_keep.insert(it->spec);
}
Expand All @@ -421,8 +427,11 @@ namespace vcpkg::Commands::CI
{
it->plan_type = InstallPlanType::EXCLUDED;
}
it->build_options = vcpkg::Build::backcompat_prohibiting_package_options;
to_keep.insert(it->package_dependencies.begin(), it->package_dependencies.end());
else
{
it->build_options = vcpkg::Build::backcompat_prohibiting_package_options;
to_keep.insert(it->package_dependencies.begin(), it->package_dependencies.end());
}
}
}

Expand Down Expand Up @@ -580,7 +589,24 @@ namespace vcpkg::Commands::CI
}
}

reduce_action_plan(action_plan, split_specs->known);
std::vector<std::string> parent_hashes;

auto it_parent_hashes = settings.find(OPTION_PARENT_HASHES);
if (it_parent_hashes != settings.end())
{
const Path parent_hashes_path = paths.original_cwd / it_parent_hashes->second;
auto parsed_json = Json::parse_file(VCPKG_LINE_INFO, filesystem, parent_hashes_path);
parent_hashes = Util::fmap(parsed_json.first.array(), [](const auto& json_object) {
auto abi = json_object.object().get("abi");
Checks::check_exit(VCPKG_LINE_INFO, abi);
#ifdef _MSC_VER
_Analysis_assume_(abi);
#endif
return abi->string().to_string();
dg0yt marked this conversation as resolved.
Show resolved Hide resolved
});
}

reduce_action_plan(action_plan, split_specs->known, parent_hashes);

vcpkg::printf("Time to determine pass/fail: %s\n", timer.elapsed());

Expand Down