• Home
  • Raw
  • Download

Lines Matching +full:ghstack +full:- +full:mergeability +full:- +full:check

5 # This source code is licensed under the BSD-style license found in the
8 # NB: the following functions are used in Meta-internal workflows
379 # This query needs read-org permission
444 RE_GHSTACK_HEAD_REF = re.compile(r"^(gh/[^/]+/[0-9]+/)head$")
448 r"https://github.com/(?P<owner>[^/]+)/(?P<repo>[^/]+)/pull/(?P<number>[0-9]+)",
452 RE_DIFF_REV = re.compile(r"^Differential Revision:.+?(D[0-9]+)", re.MULTILINE)
460 INTERNAL_CHANGES_CHECKRUN_NAME = "Meta Internal-Only Changes Check"
464 # This could be set to -1 to ignore all flaky and broken trunk failures. On the
469 def gh_get_pr_info(org: str, proj: str, pr_no: int) -> Any:
475 def gh_get_team_members(org: str, name: str) -> List[str]:
489 warn(f"Requested non-existing team {org}/{name}")
496 def get_check_run_name_prefix(workflow_run: Any) -> str:
503 def is_passing_status(status: Optional[str]) -> bool:
511 ) -> JobNameToStateDict:
515 # workflow -> job -> job info
521 def add_conclusions(edges: Any) -> None:
598 def parse_args() -> Any:
602 parser.add_argument("--dry-run", action="store_true")
603 parser.add_argument("--revert", action="store_true")
604 parser.add_argument("--force", action="store_true")
605 parser.add_argument("--ignore-current", action="store_true")
606 parser.add_argument("--check-mergeability", action="store_true")
607 parser.add_argument("--comment-id", type=int)
608 parser.add_argument("--reason", type=str)
613 def can_skip_internal_checks(pr: "GitHubPR", comment_id: Optional[int] = None) -> bool:
619 return comment.author_login == "facebook-github-bot"
627 ) -> List[Tuple["GitHubPR", str]]:
634 f"Could not find PR-resolved string in {msg} of ghstacked PR {pr.pr_num}"
650 ) -> List[Tuple["GitHubPR", str]]:
655 # For ghstack, cherry-pick commits based from origin
659 def skip_func(idx: int, candidate: "GitHubPR") -> bool:
682 + "This usually happens because there is a non ghstack change in the PR. "
683 … + f"Please sync them and try again (ex. make the changes on {orig_ref} and run ghstack)."
689 def __init__(self, org: str, project: str, pr_num: int) -> None:
704 def is_closed(self) -> bool:
707 def is_cross_repo(self) -> bool:
710 def base_ref(self) -> str:
713 def default_branch(self) -> str:
716 def head_ref(self) -> str:
719 def is_ghstack_pr(self) -> bool:
722 def get_ghstack_orig_ref(self) -> str:
726 def is_base_repo_private(self) -> bool:
729 def get_changed_files_count(self) -> int:
732 def last_commit(self) -> Any:
733 return self.info["commits"]["nodes"][-1]["commit"]
735 def get_merge_base(self) -> str:
741 # work for ghstack where the base is the custom branch, i.e. gh/USER/ID/base,
757 def get_changed_files(self) -> List[str]:
780 def get_submodules(self) -> List[str]:
787 def get_changed_submodules(self) -> List[str]:
791 def has_invalid_submodule_updates(self) -> bool:
803 def _get_reviews(self) -> List[Tuple[str, str]]:
828 def get_approved_by(self) -> List[str]:
831 def get_commit_count(self) -> int:
834 def get_pr_creator_login(self) -> str:
837 def _fetch_authors(self) -> List[Tuple[str, str]]:
842 def add_authors(info: Dict[str, Any]) -> None:
869 def get_committer_login(self, num: int = 0) -> str:
872 def get_committer_author(self, num: int = 0) -> str:
875 def get_labels(self) -> List[str]:
886 def get_checkrun_conclusions(self) -> JobNameToStateDict:
887 """Returns dict of checkrun -> [conclusion, url]"""
894 ) -> Any:
900 cs_cursor=edges[edge_idx - 1]["cursor"] if edge_idx > 0 else None,
904 -1
906 checkruns = last_commit["checkSuites"]["nodes"][-1]["checkRuns"]
909 def get_pr_next_checksuites(checksuites: Any) -> Any:
915 cursor=checksuites["edges"][-1]["cursor"],
918 last_commit = info["commits"]["nodes"][-1]["commit"]
945 def get_authors(self) -> Dict[str, str]:
952 def get_author(self) -> str:
963 def get_title(self) -> str:
966 def get_body(self) -> str:
969 def get_merge_commit(self) -> Optional[str]:
973 def get_pr_url(self) -> str:
977 def _comment_from_node(node: Any) -> GitHubComment:
989 def get_comments(self) -> List[GitHubComment]:
1011 def get_last_comment(self) -> GitHubComment:
1012 return self._comment_from_node(self.info["comments"]["nodes"][-1])
1014 def get_comment_by_id(self, database_id: int) -> GitHubComment:
1016 # Fastpath - try searching in partial prefetched comments
1028 # Check those review comments to see if one of those was the comment in question.
1037 def get_diff_revision(self) -> Optional[str]:
1041 def has_internal_changes(self) -> bool:
1050 def has_no_connected_diff(self) -> bool:
1063 ) -> List["GitHubPR"]:
1094 ) -> str:
1097 filters out ghstack info"""
1109 # Mention PR co-authors
1112 msg += f"\nCo-authored-by: {author_name}"
1117 msg += f"ghstack dependencies: {', '.join([f'#{pr.pr_num}' for pr in ghstack_deps])}\n"
1120 def add_numbered_label(self, label_base: str, dry_run: bool) -> None:
1138 ) -> None:
1201 ) -> List["GitHubPR"]:
1203 … :param skip_all_rule_checks: If true, skips all rule checks, useful for dry-running merge locally
1210 pr_branch_name = f"__pull-request-{self.pr_num}__init__"
1212 repo._run_git("merge", "--squash", pr_branch_name)
1213 repo._run_git("commit", f'--author="{self.get_author()}"', "-m", msg)
1225 def __init__(self, message: str, rule: Optional["MergeRule"] = None) -> None:
1248 org: str, project: str, labels: List[str], template: str = "bug-report.yml"
1249 ) -> str:
1260 ) -> List[MergeRule]:
1263 NB: this function is used in Meta-internal workflows, see the comment
1291 ) -> Tuple[
1301 NB: this function is used in Meta-internal workflows, see the comment at the top of
1338 # Score 0 to 10K - how many files rule matched
1339 # Score 10K - matched all files, but no overlapping approvers
1340 # Score 20K - matched all files and approvers, but mandatory checks are pending
1341 # Score 30k - Matched all files and approvers, but mandatory checks failed
1353 num_matching_files = len(changed_files) - len(non_matching_files)
1359 … f"{num_matching_files} files matched, but there are still non-matching files:",
1391 … f"- {name} ({', '.join(approved_by[:5])}{', ...' if len(approved_by) > 5 else ''})"
1407 or ("Facebook CLA Check" in x)
1433 f"{len(failed_checks)} mandatory check(s) failed. The first few are:",
1445 … f"{len(pending_checks)} mandatory check(s) are pending/not yet run. The first few are:",
1482 def checks_to_str(checks: List[Tuple[str, Optional[str]]]) -> str:
1488 ) -> List[str]:
1490 f"- [{c[0]}]({c[1]})" if c[1] is not None else f"- {c[0]}" for c in checks[:5]
1517 ) -> None:
1522 # Decide not to save the record to Rockset if dry-run is set to not pollute
1568 def get_rockset_results(head_sha: str, merge_base: str) -> List[Dict[str, Any]]:
1598 def get_drci_classifications(pr_num: int, project: str = "pytorch") -> Any:
1618 REMOVE_JOB_NAME_SUFFIX_REGEX = re.compile(r", [0-9]+, [0-9]+, .+\)$")
1621 def remove_job_name_suffix(name: str, replacement: str = ")") -> str:
1628 ) -> bool:
1642 ) -> bool:
1654 ) -> bool:
1656 After https://github.com/pytorch/test-infra/pull/4579, invalid cancelled
1680 ) -> Dict[str, JobCheckState]:
1686 def get_readable_drci_results(drci_classifications: Any) -> str:
1700 # SandCastle, we fallback to any results we can find on Dr.CI check run summary
1716 for name, check in checks.items():
1717 if check.status == "SUCCESS" or check.status == "NEUTRAL":
1722 check.name,
1723 check.url,
1724 check.status,
1726 check.job_id,
1727 check.title,
1728 check.summary,
1732 # NB: It's important to note that when it comes to ghstack and broken trunk classification,
1736 check.name,
1737 check.url,
1738 check.status,
1740 check.job_id,
1741 check.title,
1742 check.summary,
1748 check.name,
1749 check.url,
1750 check.status,
1752 check.job_id,
1753 check.title,
1754 check.summary,
1758 elif is_invalid_cancel(name, check.status, drci_classifications):
1763 check.name,
1764 check.url,
1765 check.status,
1767 check.job_id,
1768 check.title,
1769 check.summary,
1775 check.name,
1776 check.url,
1777 check.status,
1779 check.job_id,
1780 check.title,
1781 check.summary,
1789 ) -> List[JobCheckState]:
1790 return [check for check in checks.values() if status_filter(check.status)]
1793 def get_pr_commit_sha(repo: GitRepo, pr: GitHubPR) -> str:
1805 ) -> Tuple[str, str]:
1835 ) -> List[Tuple[str, GitHubPR]]:
1847 skip_len = len(rev_list) - 1
1853 # Validate that candidate always ends rev-list
1854 if rev_list[-len(candidate) :] != candidate:
1860 rev_list = rev_list[:-skip_len]
1880 ) -> None:
1905 revert_message += "\ncc: @pytorch/pytorch-dev-infra"
1923 ) -> None:
1957 def prefix_with_github_url(suffix_str: str) -> str:
1961 def check_for_sev(org: str, project: str, skip_mandatory_checks: bool) -> None:
1982 def has_label(labels: List[str], pattern: Pattern[str] = CIFLOW_LABEL) -> bool:
1990 ) -> Tuple[
2075 ) -> None:
2093 # ignored and is toggled by the --ignore-current flag
2116 # Check for approvals
2148 elapsed_time = current_time - start_time
2193 … f"{len(startup_failures)} STARTUP failures reported, please check workflows syntax! "
2228 gh_add_labels(pr.org, pr.project, pr.pr_num, ["land-failed"], dry_run)
2232 def main() -> None:
2238 def handle_exception(e: Exception, title: str = "Merge failed") -> None:
2302 "Cross-repo ghstack merges are not supported",