Skip to content

Commit

Permalink
labels
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Feb 13, 2024
1 parent 622eed0 commit 0d31f31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions limbo/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ def _regression(args: argparse.Namespace) -> None:

if os.getenv("GITHUB_ACTIONS"):
if regressions:
_github.comment("Regressions found!")
_github.comment("Regressions found!", labels=[":skull: regressions"])
else:
_github.comment("No regressions :thumbsup:")
_github.comment("No regressions :thumbsup:", labels=[":see_no_evil: no-regressions"])
15 changes: 14 additions & 1 deletion limbo/_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def github_event() -> dict[str, Any]:
return json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text()) # type: ignore[no-any-return]


def comment(msg: str) -> None:
def comment(msg: str, *, labels: list[str] = []) -> None:
event = github_event()
if "pull_request" not in event:
raise ValueError("wrong GitHub event: need pull_request")
Expand All @@ -46,3 +46,16 @@ def comment(msg: str) -> None:
},
json={"body": msg},
).raise_for_status()

if labels:
logger.info(f"adding labels to {repo} #{number}: {labels}")
url = f"https://api.github.com/repos/{repo}/issues/{number}/labels"

requests.post(
url,
headers={
"Authorization": f"Bearer {github_token()}",
"X-GitHub-Api-Version": "2022-11-28",
},
json={"labels": labels},
)

0 comments on commit 0d31f31

Please sign in to comment.