(n: Dict[str, Any])
| 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 = "❔" |
| 84 | text = "" |
| 85 | buildid_text = "" |
| 86 | if status is not None: |
| 87 | contexts = status["contexts"] |
| 88 | else: |
| 89 | contexts = [] |
| 90 | for c in contexts: |
| 91 | # TODO: Stop hard-coding me |
| 92 | if c["context"] != "ci/circleci: pytorch_linux_xenial_py3_clang5_asan_test": |
| 93 | continue |
| 94 | m = RE_CIRCLECI_URL.match(c["targetUrl"]) |
| 95 | if not m: |
| 96 | icon = "🍆" |
| 97 | break |
| 98 | if c["state"] == "SUCCESS": |
| 99 | icon = "✅" |
| 100 | break |
| 101 | buildid = m.group(1) |
| 102 | buildid_text = " ({})".format(buildid) |
| 103 | r = await circleci.get( |
| 104 | "project/github/{name}/{owner}/{buildid}".format( |
| 105 | buildid=buildid, **params |
| 106 | ) |
| 107 | ) |
| 108 | if not r["failed"]: |
| 109 | # It was just cancelled (don't check "cancelled"; that's |
| 110 | # true even if the job failed otherwise; it just means |
| 111 | # workflow got cancelled) |
| 112 | icon = "❔" |
| 113 | break |
| 114 | icon = "❌" |
| 115 | async with aiohttp.request( |
| 116 | "get", r["steps"][-1]["actions"][-1]["output_url"] |
| 117 | ) as resp: |
| 118 | log_json = await resp.json() |
| 119 | buf = [] |
| 120 | for e in log_json: |
| 121 | buf.append(e["message"]) |
| 122 | text = "\n" + strip_sccache("\n".join(buf)) |
| 123 | text = text[-1500:] |
| 124 | return "{} {} {}{}{}".format( |
| 125 | icon, commit["oid"][:8], commit["messageHeadline"], buildid_text, text |
| 126 | ) |
| 127 | |
| 128 | for n in nodes: |
| 129 | print(await process_node(n)) |
no test coverage detected