• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fedora-llvm-team / llvm-snapshots / 27679348919

17 Jun 2026 09:29AM UTC coverage: 55.569% (-0.02%) from 55.591%
27679348919

Pull #2126

github

web-flow
Merge 97021d5b9 into d9a548ad3
Pull Request #2126: Build and upload man pages alongside other snapshot version information

1 of 4 new or added lines in 2 files covered. (25.0%)

1 existing line in 1 file now uncovered.

1377 of 2478 relevant lines covered (55.57%)

0.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.67
/scripts/get-good-commit.py
1
#!/bin/env python3
2

3
import argparse
1✔
4
import logging
1✔
5

6
from github import Github
1✔
7

8

9
def get_good_commit(
1✔
10
    token: str,
11
    project: str,
12
    start_ref: str,
13
    max_tries: int,
14
    required_checks: list[str],
15
) -> str:
16
    """
17
    Takes a github project and walks up the chain of commits beginning with
18
    `start_ref`. All the checks in `required_checks` must have run for the commit to
19
    be considered the best of the `max_tries` commits.
20

21
    :param str token: to be used for github token authentication
22
    :param str project: the github project to work with
23
    :param str start_ref: the git ref to check first (can be a SHA, a branch name, or a tag name)
24
    :param int max_tries: the number of parents that the algorithm tries before giving up and returning an empty string
25
    :param list[str] required_checks: the list of checks that must exist for a commit to be classified as "good"
26
    """
27
    g = Github(login_or_token=token)
×
28
    repo = g.get_repo(project)
×
29
    next_sha = start_ref
×
30
    logging.basicConfig(level=logging.INFO)
×
NEW
31
    logging.info(f"""
×
32
Scanning for best of commit
33
Project:         {project}
34
Start ref:       {start_ref}
35
Max tries:       {max_tries}
36
Required checks: {required_checks}
37
""")
38

39
    required_checks_set = {(check, "success") for check in required_checks}
×
40
    for i in range(0, max_tries):
×
41
        commit = repo.get_commit(sha=next_sha)
×
42
        commit_url = f"https://github.com/{project}/commit/{commit.sha}"
×
43
        next_sha = commit.parents[0].sha
×
44

45
        logging.info(
×
46
            f"{i}. Checking commit {commit_url} (Date: {commit.commit.committer.date}, Combined status: {commit.get_combined_status().state})"
47
        )
48
        # Makes sure the required checks are among the ones that have been run
49
        # on the commit.
50
        actual_checks = {
×
51
            (status.context, status.state) for status in commit.get_statuses()
52
        }
53
        if not required_checks_set.issubset(actual_checks):
×
54
            logging.warning(
×
55
                f"- Ignoring commit because of missing or failed check(s): {required_checks_set - actual_checks}"
56
            )
57
            continue
×
58

59
        logging.info(f"Found good commit: {commit_url}")
×
60
        return str(commit.sha)
×
61

62
    sha = repo.get_commit(sha=start_ref).sha
×
63
    logging.info(f"No good commit found, using the initial one: {start_ref}, aka {sha}")
×
64
    return str(sha)
×
65

66

67
def main() -> None:
1✔
68
    parser = argparse.ArgumentParser(
×
69
        description="Find the latest commit that passed tests or return the start-ref commit sha"
70
    )
71
    parser.add_argument(
×
72
        "--token",
73
        dest="token",
74
        type=str,
75
        default="YOUR-TOKEN-HERE",
76
        help="your github token",
77
    )
78
    parser.add_argument(
×
79
        "--project",
80
        dest="project",
81
        type=str,
82
        default="llvm/llvm-project",
83
        help="github project to use (default: llvm/llvm-project)",
84
    )
85
    parser.add_argument(
×
86
        "--start-ref",
87
        dest="start_ref",
88
        type=str,
89
        default="main",
90
        help="git reference (e.g. branch name or sha1) to check first (default: main)",
91
    )
92
    parser.add_argument(
×
93
        "--max-tries",
94
        dest="max_tries",
95
        type=int,
96
        default="20",
97
        help="how many commit to try before giving up (default: 20)",
98
    )
99
    parser.add_argument(
×
100
        "--required-checks",
101
        dest="required_checks",
102
        metavar="CHECK",
103
        nargs="+",
104
        default=["clang-x86_64-debian-fast"],
105
        type=str,
106
        help="list check names that must have run (default: clang-x86_64-debian-fast)",
107
    )
108
    args = parser.parse_args()
×
109

110
    sha = get_good_commit(
×
111
        token=args.token,
112
        project=args.project,
113
        start_ref=args.start_ref,
114
        required_checks=args.required_checks,
115
        max_tries=args.max_tries,
116
    )
117

118
    print(sha)
×
119

120

121
if __name__ == "__main__":
1✔
122
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc