Lines Matching +full:ghstack +full:- +full:mergeability +full:- +full:check
3 # NB: the following functions are used in Meta-internal workflows
377 # This query needs read-org permission
442 RE_GHSTACK_HEAD_REF = re.compile(r"^(gh/[^/]+/[0-9]+/)head$")
446 r"https://github.com/(?P<owner>[^/]+)/(?P<repo>[^/]+)/pull/(?P<number>[0-9]+)",
450 RE_DIFF_REV = re.compile(r"^Differential Revision:.+?(D[0-9]+)", re.MULTILINE)
458 INTERNAL_CHANGES_CHECKRUN_NAME = "Meta Internal-Only Changes Check"
462 # This could be set to -1 to ignore all flaky and broken trunk failures. On the
467 def gh_get_pr_info(org: str, proj: str, pr_no: int) -> Any:
473 def gh_get_team_members(org: str, name: str) -> List[str]:
487 warn(f"Requested non-existing team {org}/{name}")
494 def get_check_run_name_prefix(workflow_run: Any) -> str:
501 def is_passing_status(status: Optional[str]) -> bool:
509 ) -> JobNameToStateDict:
513 # workflow -> job -> job info
519 def add_conclusions(edges: Any) -> None:
608 def parse_args() -> Any:
612 parser.add_argument("--dry-run", action="store_true")
613 parser.add_argument("--revert", action="store_true")
614 parser.add_argument("--force", action="store_true")
615 parser.add_argument("--ignore-current", action="store_true")
616 parser.add_argument("--check-mergeability", action="store_true")
617 parser.add_argument("--comment-id", type=int)
618 parser.add_argument("--reason", type=str)
623 def can_skip_internal_checks(pr: "GitHubPR", comment_id: Optional[int] = None) -> bool:
629 return comment.author_login == "facebook-github-bot"
637 ) -> List[Tuple["GitHubPR", str]]:
644 f"Could not find PR-resolved string in {msg} of ghstacked PR {pr.pr_num}"
660 ) -> List[Tuple["GitHubPR", str]]:
665 # For ghstack, cherry-pick commits based from origin
669 def skip_func(idx: int, candidate: "GitHubPR") -> bool:
692 + "This usually happens because there is a non ghstack change in the PR. "
693 … + f"Please sync them and try again (ex. make the changes on {orig_ref} and run ghstack)."
699 def __init__(self, org: str, project: str, pr_num: int) -> None:
714 def is_closed(self) -> bool:
717 def is_cross_repo(self) -> bool:
720 def base_ref(self) -> str:
723 def default_branch(self) -> str:
726 def head_ref(self) -> str:
729 def is_ghstack_pr(self) -> bool:
732 def get_ghstack_orig_ref(self) -> str:
736 def is_base_repo_private(self) -> bool:
739 def get_changed_files_count(self) -> int:
742 def last_commit(self) -> Any:
743 return self.info["commits"]["nodes"][-1]["commit"]
745 def get_merge_base(self) -> str:
751 # work for ghstack where the base is the custom branch, i.e. gh/USER/ID/base,
767 def get_changed_files(self) -> List[str]:
790 def get_submodules(self) -> List[str]:
797 def get_changed_submodules(self) -> List[str]:
801 def has_invalid_submodule_updates(self) -> bool:
813 def _get_reviews(self) -> List[Tuple[str, str]]:
838 def get_approved_by(self) -> List[str]:
841 def get_commit_count(self) -> int:
844 def get_pr_creator_login(self) -> str:
847 def _fetch_authors(self) -> List[Tuple[str, str]]:
852 def add_authors(info: Dict[str, Any]) -> None:
879 def get_committer_login(self, num: int = 0) -> str:
882 def get_committer_author(self, num: int = 0) -> str:
885 def get_labels(self) -> List[str]:
896 def get_checkrun_conclusions(self) -> JobNameToStateDict:
897 """Returns dict of checkrun -> [conclusion, url]"""
904 ) -> Any:
910 cs_cursor=edges[edge_idx - 1]["cursor"] if edge_idx > 0 else None,
914 -1
916 checkruns = last_commit["checkSuites"]["nodes"][-1]["checkRuns"]
919 def get_pr_next_checksuites(checksuites: Any) -> Any:
925 cursor=checksuites["edges"][-1]["cursor"],
928 last_commit = info["commits"]["nodes"][-1]["commit"]
955 def get_authors(self) -> Dict[str, str]:
962 def get_author(self) -> str:
973 def get_title(self) -> str:
976 def get_body(self) -> str:
979 def get_merge_commit(self) -> Optional[str]:
983 def get_pr_url(self) -> str:
987 def _comment_from_node(node: Any) -> GitHubComment:
999 def get_comments(self) -> List[GitHubComment]:
1021 def get_last_comment(self) -> GitHubComment:
1022 return self._comment_from_node(self.info["comments"]["nodes"][-1])
1024 def get_comment_by_id(self, database_id: int) -> GitHubComment:
1026 # Fastpath - try searching in partial prefetched comments
1038 # Check those review comments to see if one of those was the comment in question.
1047 def get_diff_revision(self) -> Optional[str]:
1051 def has_internal_changes(self) -> bool:
1060 def has_no_connected_diff(self) -> bool:
1073 ) -> List["GitHubPR"]:
1104 ) -> str:
1107 filters out ghstack info"""
1122 msg += f"ghstack dependencies: {', '.join([f'#{pr.pr_num}' for pr in ghstack_deps])}\n"
1124 # Mention PR co-authors, which should be at the end of the message
1131 msg += f"\nCo-authored-by: {author_name}"
1135 def add_numbered_label(self, label_base: str, dry_run: bool) -> None:
1153 ) -> None:
1213 ) -> List["GitHubPR"]:
1215 … :param skip_all_rule_checks: If true, skips all rule checks, useful for dry-running merge locally
1222 pr_branch_name = f"__pull-request-{self.pr_num}__init__"
1224 repo._run_git("merge", "--squash", pr_branch_name)
1225 repo._run_git("commit", f'--author="{self.get_author()}"', "-m", msg)
1237 def __init__(self, message: str, rule: Optional["MergeRule"] = None) -> None:
1260 org: str, project: str, labels: List[str], template: str = "bug-report.yml"
1261 ) -> str:
1272 ) -> List[MergeRule]:
1275 NB: this function is used in Meta-internal workflows, see the comment
1303 ) -> Tuple[
1313 NB: this function is used in Meta-internal workflows, see the comment at the top of
1350 # Score 0 to 10K - how many files rule matched
1351 # Score 10K - matched all files, but no overlapping approvers
1352 # Score 20K - matched all files and approvers, but mandatory checks are pending
1353 # Score 30k - Matched all files and approvers, but mandatory checks failed
1365 num_matching_files = len(changed_files) - len(non_matching_files)
1371 … f"{num_matching_files} files matched, but there are still non-matching files:",
1403 … f"- {name} ({', '.join(approved_by[:5])}{', ...' if len(approved_by) > 5 else ''})"
1419 or ("Facebook CLA Check" in x)
1445 f"{len(failed_checks)} mandatory check(s) failed. The first few are:",
1457 … f"{len(pending_checks)} mandatory check(s) are pending/not yet run. The first few are:",
1494 def checks_to_str(checks: List[Tuple[str, Optional[str]]]) -> str:
1500 ) -> List[str]:
1502 f"- [{c[0]}]({c[1]})" if c[1] is not None else f"- {c[0]}" for c in checks[:5]
1526 ) -> None:
1554 "_id": f"{project}-{pr_num}-{comment_id}-{os.environ.get('GITHUB_RUN_ID')}",
1564 def get_rockset_results(head_sha: str, merge_base: str) -> List[Dict[str, Any]]:
1594 def get_drci_classifications(pr_num: int, project: str = "pytorch") -> Any:
1614 REMOVE_JOB_NAME_SUFFIX_REGEX = re.compile(r", [0-9]+, [0-9]+, .+\)$")
1617 def remove_job_name_suffix(name: str, replacement: str = ")") -> str:
1622 check: JobCheckState,
1624 ) -> bool:
1625 if not check or not drci_classifications:
1628 name = check.name
1629 job_id = check.job_id
1639 check: JobCheckState,
1641 ) -> bool:
1642 if not check or not drci_classifications:
1645 name = check.name
1646 job_id = check.job_id
1661 check: JobCheckState,
1663 ) -> bool:
1664 if not check or not drci_classifications:
1667 name = check.name
1668 job_id = check.job_id
1681 ) -> bool:
1683 After https://github.com/pytorch/test-infra/pull/4579, invalid cancelled
1707 ) -> Dict[str, JobCheckState]:
1713 def get_readable_drci_results(drci_classifications: Any) -> str:
1727 # SandCastle, we fallback to any results we can find on Dr.CI check run summary
1743 for name, check in checks.items():
1744 if check.status == "SUCCESS" or check.status == "NEUTRAL":
1747 if is_unstable(check, drci_classifications):
1749 check.name,
1750 check.url,
1751 check.status,
1753 check.job_id,
1754 check.title,
1755 check.summary,
1759 # NB: It's important to note that when it comes to ghstack and broken trunk classification,
1761 if is_broken_trunk(check, drci_classifications):
1763 check.name,
1764 check.url,
1765 check.status,
1767 check.job_id,
1768 check.title,
1769 check.summary,
1773 elif is_flaky(check, drci_classifications):
1775 check.name,
1776 check.url,
1777 check.status,
1779 check.job_id,
1780 check.title,
1781 check.summary,
1785 elif is_invalid_cancel(name, check.status, drci_classifications):
1790 check.name,
1791 check.url,
1792 check.status,
1794 check.job_id,
1795 check.title,
1796 check.summary,
1802 check.name,
1803 check.url,
1804 check.status,
1806 check.job_id,
1807 check.title,
1808 check.summary,
1816 ) -> List[JobCheckState]:
1817 return [check for check in checks.values() if status_filter(check.status)]
1820 def get_pr_commit_sha(repo: GitRepo, pr: GitHubPR) -> str:
1832 ) -> Tuple[str, str]:
1862 ) -> List[Tuple[str, GitHubPR]]:
1874 skip_len = len(rev_list) - 1
1880 # Validate that candidate always ends rev-list
1881 if rev_list[-len(candidate) :] != candidate:
1887 rev_list = rev_list[:-skip_len]
1907 ) -> None:
1932 revert_message += "\ncc: @pytorch/pytorch-dev-infra"
1950 ) -> None:
1984 def prefix_with_github_url(suffix_str: str) -> str:
1988 def check_for_sev(org: str, project: str, skip_mandatory_checks: bool) -> None:
2009 def has_label(labels: List[str], pattern: Pattern[str] = CIFLOW_LABEL) -> bool:
2017 ) -> Tuple[
2102 ) -> None:
2120 # ignored and is toggled by the --ignore-current flag
2143 # Check for approvals
2175 elapsed_time = current_time - start_time
2220 … f"{len(startup_failures)} STARTUP failures reported, please check workflows syntax! "
2255 gh_add_labels(pr.org, pr.project, pr.pr_num, ["land-failed"], dry_run)
2259 def main() -> None:
2265 def handle_exception(e: Exception, title: str = "Merge failed") -> None:
2329 "Cross-repo ghstack merges are not supported",