diff --git a/build_pr_changes.py b/build_pr_changes.py index fd55d18..0345212 100755 --- a/build_pr_changes.py +++ b/build_pr_changes.py @@ -1148,13 +1148,13 @@ def failure_summary(fails: List[Tuple[str, str]]) -> str: def generate_build_results(installed, passed, fails, about_build_host) -> str: """Generate a report in markdown format for cut-and-paste into the PR comment.""" - build_results = f"Auto-submitted build results{about_build_host}: (see disclaimer below)\n" + build_results = f"Build results{about_build_host}:\n" build_results += "The following specs were checked (extracted from `gh pr diff`):\n" build_results += "- `" + "`\n- `".join(installed + passed) + "`\n\n" if installed or passed: - build_results += "The following specs were installed or passed building in this run:" - build_results += " (variants are shortened, e.g. no disabled variants)\n" + build_results += "These specs were installed:" + build_results += " (`~disabled` variants are hidden using `sed`)\n" build_results += "```py\n" cmd = ["bin/spack", "find", "--variants", *(installed + passed)] build_results += " ".join(cmd) @@ -1177,19 +1177,10 @@ def generate_build_results(installed, passed, fails, about_build_host) -> str: build_results += failure_summary(fails) if fails: build_results += ( - "\nThis report was generated by a script and may contain errors.\n" - "The idea would be that I/we can improve this script to get fast checks for PRs!\n" - "I think this is already much better than just checking checksums manually," - "and it should get better as more build error cases get covered properly.\n\n" - "If the build report contains real errors, please fix them and push the changes.\n\n" - "The script tries to add a label to indicate the build status,\n" - "and set the 'draft' status of the PR.\n\n" - "After the correct fix is pushed, to the PR branch and change the" - " PR status to 'Ready for review'.\n\n" - "Generated and submitted by " + "\nThis report was generated by a script that is a work-in-progress.\n" + "If this found a real issue, please fix it and push the changes.\n\n" ) - else: - build_results += "Generated and submitted by " + build_results += "Generated by " git_dir = os.path.dirname(os.path.realpath(__file__)) err, stdout, stderr = run(["git", "-C", git_dir, "config", "--get", "remote.origin.url"]) if not err: @@ -1299,7 +1290,7 @@ def is_approved_or_changes_requested_by_me(pr: Dict[str, Any]) -> bool: approvers = get_reviews(pr, "APPROVED") if approvers: - print("Approved by" + ", ".join(approvers)) + print("Approved by " + ", ".join(approvers)) requesters = get_reviews(pr, "CHANGES_REQUESTED") if requesters: @@ -1330,13 +1321,22 @@ def pull_request_is_ready_for_review(args: argparse.Namespace) -> bool: def create_change_request(args: argparse.Namespace, build_results: str) -> ExitCode: """Create a change request for the failed specs.""" print(build_results) - if not (args.yes or input("Create a change request for the failed specs [y/n]: ") == "y"): - return 1 - print("Creating a change request for the failed specs.") if not pull_request_is_ready_for_review(args): + print("The PR is not ready for review, skipping creating a change request.") return Success + if not (args.yes or input("Create a change request for the failed specs [y/n]: ") == "y"): + return 1 + print("Creating a change request for the failed specs.") + + if args.yes: + build_results += ( + "The script automatically adds a label for tracking to indicate the build status,\n" + "and sets the 'draft' status of the PR.\n\n" + "If there is no (longer) an issue, please change the PR to 'Ready for review' again." + ) + # Remove ANSI color codes from the output: build_results = re.sub(r"\x1b\[[0-9;]*m", "", build_results)