(
pull_request: str,
github: ghstack.github.GitHubEndpoint,
circleci: ghstack.circleci.CircleCIEndpoint,
)
| 24 | |
| 25 | |
| 26 | async def main( |
| 27 | pull_request: str, |
| 28 | github: ghstack.github.GitHubEndpoint, |
| 29 | circleci: ghstack.circleci.CircleCIEndpoint, |
| 30 | ) -> None: |
| 31 | |
| 32 | # Game plan: |
| 33 | # 1. Query GitHub to find out what the current statuses are |
| 34 | # (TODO: if we got rate limited we'll miss stuff) |
| 35 | # 2. For each status in parallel: |
| 36 | # a. Query CircleCI for job status |
| 37 | # b. (Future work) Query output_url to get log information |
| 38 | # (it's gzip'ed) |
| 39 | # |
| 40 | # For now: |
| 41 | # - Print if the job actually ran, or was skipped |
| 42 | # - Easy way to determine: check if "Should run job after |
| 43 | # checkout" is last step |
| 44 | # - I inspected circleci.get('project/github/pytorch/pytorch/1773555') |
| 45 | # to see if there were other options, there did not appear |
| 46 | # to be any indication that a halt was called. So we'll |
| 47 | # have to rely on the (OS X jobs, take note!) |
| 48 | |
| 49 | params = ghstack.github_utils.parse_pull_request(pull_request) |
| 50 | |
| 51 | # TODO: stop hard-coding number of commits |
| 52 | r = github.graphql( |
| 53 | """ |
| 54 | query ($name: String!, $owner: String!, $number: Int!) { |
| 55 | repository(name: $name, owner: $owner) { |
| 56 | pullRequest(number: $number) { |
| 57 | commits(last: 100) { |
| 58 | nodes { |
| 59 | commit { |
| 60 | oid |
| 61 | messageHeadline |
| 62 | status { |
| 63 | contexts { |
| 64 | context |
| 65 | state |
| 66 | targetUrl |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | """, |
| 76 | **params, |
| 77 | ) |
| 78 | nodes = r["data"]["repository"]["pullRequest"]["commits"]["nodes"] |
| 79 | |
| 80 | async def process_node(n: Dict[str, Any]) -> str: |
| 81 | commit = n["commit"] |
| 82 | status = commit["status"] |
| 83 | icon = "❔" |
nothing calls this directly
no test coverage detected