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

Improve prefilled issue template #681

Merged
merged 5 commits into from
Sep 9, 2022
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
2 changes: 1 addition & 1 deletion include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ namespace vcpkg
(msg::path),
"Fourth optional part of build troubleshooting message, printed after the version"
"information about vcpkg itself.",
"You can also use the prefilled template from {path}.");
"Please use the prefilled template from {path} when reporting your issue.");
DECLARE_MESSAGE(ChecksFailedCheck, (), "", "vcpkg has crashed; no additional details are available.");
DECLARE_MESSAGE(ChecksUnreachableCode, (), "", "unreachable code was reached");
DECLARE_MESSAGE(ChecksUpdateVcpkg, (), "", "updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.");
Expand Down
15 changes: 12 additions & 3 deletions include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,18 @@ namespace vcpkg

StringLiteral to_string_locale_invariant(const BuildResult build_result);
LocalizedString to_string(const BuildResult build_result);
LocalizedString create_user_troubleshooting_message(const InstallPlanAction& action,
const VcpkgPaths& paths,
Optional<Path>&& issue_body = nullopt);
LocalizedString create_user_troubleshooting_message(const InstallPlanAction& action, const VcpkgPaths& paths);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's now an error to call this IMO it would be better to just inline it (and put the definition of print_user_troubleshooting_message into build.cpp?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not possible:

vcpkg-tool\src\vcpkg\install.cpp(525,17): error C3861: "print_user_troubleshooting_message": identifier not found

inline void print_user_troubleshooting_message(const InstallPlanAction& action,
const VcpkgPaths& paths,
Optional<Path>&& issue_body)
{
msg::println_error(create_user_troubleshooting_message(action, paths));
if (issue_body)
{
msg::println(
Color::warning, msgBuildTroubleshootingMessage4, msg::path = issue_body.value_or_exit(VCPKG_LINE_INFO));
}
}

/// <summary>
/// Settings from the triplet file which impact the build environment and post-build checks
Expand Down
2 changes: 1 addition & 1 deletion locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"BuildTroubleshootingMessage1": "Please ensure you're using the latest port files with `git pull` and `vcpkg update`.\nThen check for known issues at:",
"BuildTroubleshootingMessage2": "You can submit a new issue at:",
"BuildTroubleshootingMessage3": "Include '[{package_name}] Build error' in your bug report title, the following version information in your bug description, and attach any relevant failure logs from above.",
"BuildTroubleshootingMessage4": "You can also use the prefilled template from {path}.",
"BuildTroubleshootingMessage4": "Please use the prefilled template from {path} when reporting your issue.",
"BuildingFromHead": "Building {spec} from HEAD...",
"BuildingPackage": "Building {spec}...",
"BuildingPackageFailed": "building {spec} failed with: {build_result}",
Expand Down
2 changes: 1 addition & 1 deletion locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"_BuildTroubleshootingMessage2.comment": "Second part of build troubleshooting message, printed after the URI to look for existing bugs but before the URI to file one.",
"BuildTroubleshootingMessage3": "Include '[{package_name}] Build error' in your bug report title, the following version information in your bug description, and attach any relevant failure logs from above.",
"_BuildTroubleshootingMessage3.comment": "Third part of build troubleshooting message, printed after the URI to file a bug but before version information about vcpkg itself. An example of {package_name} is zlib.",
"BuildTroubleshootingMessage4": "You can also use the prefilled template from {path}.",
"BuildTroubleshootingMessage4": "Please use the prefilled template from {path} when reporting your issue.",
"_BuildTroubleshootingMessage4.comment": "Fourth optional part of build troubleshooting message, printed after the versioninformation about vcpkg itself. An example of {path} is /foo/bar.",
"BuildingFromHead": "Building {spec} from HEAD...",
"_BuildingFromHead.comment": "'HEAD' means the most recent version of source code An example of {spec} is zlib:x64-windows.",
Expand Down
30 changes: 12 additions & 18 deletions src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,11 +1430,11 @@ namespace vcpkg
{
const auto& fs = paths.get_filesystem();
const auto create_log_details = [&fs](vcpkg::Path&& path) {
constexpr auto MAX_LOG_LENGTH = 20'000;
constexpr auto START_BLOCK_LENGTH = 3'000;
constexpr auto START_BLOCK_MAX_LENGTH = 5'000;
constexpr auto END_BLOCK_LENGTH = 13'000;
constexpr auto END_BLOCK_MAX_LENGTH = 15'000;
static constexpr auto MAX_LOG_LENGTH = 20'000;
static constexpr auto START_BLOCK_LENGTH = 3'000;
static constexpr auto START_BLOCK_MAX_LENGTH = 5'000;
static constexpr auto END_BLOCK_LENGTH = 13'000;
static constexpr auto END_BLOCK_MAX_LENGTH = 15'000;
auto log = fs.read_contents(path, VCPKG_LINE_INFO);
if (log.size() > MAX_LOG_LENGTH)
{
Expand Down Expand Up @@ -1470,8 +1470,8 @@ namespace vcpkg
action.displayname(),
" -> ",
action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).to_version(),
"\n**Host Environment**",
"\n- Host: ",
"\n\n**Host Environment**",
"\n\n- Host: ",
to_zstring_view(get_host_processor()),
'-',
get_host_os_name(),
Expand All @@ -1481,20 +1481,18 @@ namespace vcpkg
compiler_info.version,
"\n-",
paths.get_toolver_diagnostics(),
"\n\n**To Reproduce**\n",
"\n**To Reproduce**\n\n",
Strings::concat("`vcpkg ", args.command, " ", Strings::join(" ", args.command_arguments), "`\n"),
"\n\n**Failure logs**\n```\n",
"\n**Failure logs**\n\n```\n",
paths.get_filesystem().read_contents(build_result.stdoutlog.value_or_exit(VCPKG_LINE_INFO),
VCPKG_LINE_INFO),
"\n```\n",
Strings::join("\n", Util::fmap(build_result.error_logs, create_log_details)),
"\n\n**Additional context**\n",
"\n**Additional context**\n\n",
manifest);
}

LocalizedString create_user_troubleshooting_message(const InstallPlanAction& action,
const VcpkgPaths& paths,
Optional<Path>&& issue_body)
LocalizedString create_user_troubleshooting_message(const InstallPlanAction& action, const VcpkgPaths& paths)
{
std::string package = action.displayname();
if (auto scfl = action.source_control_file_and_location.get())
Expand All @@ -1515,11 +1513,7 @@ namespace vcpkg
.append_raw('\n');
result.append(msgBuildTroubleshootingMessage3, msg::package_name = spec_name).append_raw('\n');
result.append_raw(paths.get_toolver_diagnostics()).append_raw('\n');
if (issue_body)
{
result.append(msgBuildTroubleshootingMessage4, msg::path = issue_body.value_or_exit(VCPKG_LINE_INFO))
.append_raw('\n');
}

return result;
}

Expand Down
16 changes: 7 additions & 9 deletions src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,13 @@ namespace vcpkg
perform_install_plan_action(args, paths, action, status_db, binary_cache, build_logs_recorder);
if (result.code != BuildResult::SUCCEEDED && keep_going == KeepGoing::NO)
{
Checks::msg_exit_with_message(
VCPKG_LINE_INFO,
create_user_troubleshooting_message(
action, paths, result.stdoutlog.then([&](auto&) -> Optional<Path> {
const auto issue_body_path = paths.installed().root() / "vcpkg" / "issue_body.md";
paths.get_filesystem().write_contents(
issue_body_path, create_github_issue(args, result, paths, action), VCPKG_LINE_INFO);
return issue_body_path;
})));
print_user_troubleshooting_message(action, paths, result.stdoutlog.then([&](auto&) -> Optional<Path> {
auto issue_body_path = paths.installed().root() / "vcpkg" / "issue_body.md";
paths.get_filesystem().write_contents(
issue_body_path, create_github_issue(args, result, paths, action), VCPKG_LINE_INFO);
return issue_body_path;
}));
Checks::exit_fail(VCPKG_LINE_INFO);
}

this_install.current_summary->build_result.emplace(std::move(result));
Expand Down