Skip to content

Commit

Permalink
Add logging to debug bedevere label staging (python#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariatta authored Oct 12, 2023
1 parent 7dce21c commit 72090a4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
3 changes: 3 additions & 0 deletions bedevere/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from . import backport, gh_issue, close_pr, filepaths, news, stage

import sentry_sdk
import logging


router = routing.Router(backport.router, gh_issue.router, close_pr.router,
filepaths.router, news.router,
Expand All @@ -24,6 +26,7 @@
sentry_sdk.init(os.environ.get("SENTRY_DSN"))

async def main(request):
logging.basicConfig(level=logging.DEBUG)
try:
body = await request.read()
secret = os.environ.get("GH_SECRET")
Expand Down
5 changes: 5 additions & 0 deletions bedevere/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import enum
import random
import logging

import gidgethub.routing

Expand Down Expand Up @@ -93,6 +94,7 @@ async def _remove_stage_labels(gh, issue):

async def stage(gh, issue, blocked_on):
"""Remove any "awaiting" labels and apply the specified one."""
logging.info("Staging: issue %s, Issue labels: %s, blocked on: %s", issue["number"], issue["labels"], blocked_on.value)
label_name = blocked_on.value
if any(label_name == label["name"] for label in issue["labels"]):
return
Expand Down Expand Up @@ -188,6 +190,7 @@ async def new_review(event, gh, *args, **kwargs):
review = event.data["review"]
reviewer = util.user_login(review)
state = review["state"].lower()
logging.info("PR# %s Review submitted by %s", pull_request["number"], reviewer, )
if state == "commented":
# Don't care about comment reviews.
return
Expand All @@ -199,11 +202,13 @@ async def new_review(event, gh, *args, **kwargs):
return
else:
# Waiting for a core developer to leave a review.
logging.info("PR# %s, Review by non core developer, adding awaiting core review %s", pull_request["number"], reviewer )
await stage(
gh, await util.issue_for_PR(gh, pull_request), Blocker.core_review
)
else:
if state == "approved":
logging.info("PR# %s approved by core dev: %s", pull_request["number"], reviewer)
if pull_request["state"] == "open":
await stage(
gh, await util.issue_for_PR(gh, pull_request), Blocker.merge
Expand Down
Loading

0 comments on commit 72090a4

Please sign in to comment.