Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/scripts/create_standup_discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,14 @@ def main():
# Gather all comments first
comments = []
for user in CONTRIBUTORS:
merged_prs, reviewed_prs, issues_opened = gather_activity(user, since_date)
merged_prs, opened_prs, reviewed_prs, issues_opened = gather_activity(
user, since_date
)
bottlenecks = gather_potential_bottlenecks(user, since_date)
comment_body = format_contributor_comment(
user,
merged_prs,
opened_prs,
reviewed_prs,
issues_opened,
bottlenecks,
Expand Down
25 changes: 23 additions & 2 deletions .github/scripts/respond_to_standup_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
`discussion_comment` events. The workflow's `if:` block already filters
to the Check-ins category and `Weekly Check-in:` titles; this script does
the precise regex match and the per-week cap.

Local dry run:

DRY_RUN=1 \
COMMENT_ID=dry-run \
COMMENT_BODY=/check-in \
COMMENT_AUTHOR="$(uv run --no-project python -c \
'import sys; sys.stderr.write("GitHub username: "); print(input())')" \
DISCUSSION_CREATED_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
DISCUSSION_ID=dry-run \
GITHUB_REPOSITORY=payjoin/rust-payjoin \
BOT_LOGIN=payjoin-robot \
STANDUP_TOKEN="$(uv run --no-project python -c \
'from getpass import getpass; print(getpass("GitHub token: "))')" \
uv run --with requests \
python .github/scripts/respond_to_standup_comment.py
"""

import os
Expand All @@ -24,6 +40,7 @@
TRIGGER_RE = re.compile(r"(?im)(^|\s)/check-in\b")
SUCCESS_MARKER = "### Shipped"
ERROR_BODY = "_Bot couldn't gather activity right now. Try again in a few minutes._"
DRY_RUN = os.environ.get("DRY_RUN")


def has_prior_success(discussion_id, author):
Expand Down Expand Up @@ -66,6 +83,9 @@ def has_prior_success(discussion_id, author):

def post_reply(discussion_id, reply_to_id, body):
"""Post a threaded reply via GraphQL ``addDiscussionComment``."""
if DRY_RUN:
print(body)
return
graphql(
"""
mutation($discussionId: ID!, $replyToId: ID!, $body: String!) {
Expand Down Expand Up @@ -103,7 +123,7 @@ def main():
print("Loop guard: comment author is the bot; exiting.")
return

if has_prior_success(discussion_id, comment_author):
if not DRY_RUN and has_prior_success(discussion_id, comment_author):
print(
f"Per-week cap: {comment_author} already received a successful "
"summary in this Discussion; exiting."
Expand All @@ -113,13 +133,14 @@ def main():
since_date = parse_github_datetime(discussion_created_at) - timedelta(days=7)

try:
merged_prs, reviewed_prs, issues_opened = gather_activity(
merged_prs, opened_prs, reviewed_prs, issues_opened = gather_activity(
comment_author, since_date
)
bottlenecks = gather_potential_bottlenecks(comment_author, since_date)
body = format_contributor_comment(
comment_author,
merged_prs,
opened_prs,
reviewed_prs,
issues_opened,
bottlenecks,
Expand Down
18 changes: 14 additions & 4 deletions .github/scripts/standup_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def gather_activity(user, since_date):
# PRs merged (authored)
merged_prs = search_issues(f"author:{user} type:pr merged:>{since}")

# PRs opened
opened_prs = search_issues(f"author:{user} is:pr created:>{since}")

# PRs reviewed use search to find candidate PRs then confirm
# the reviewer actually submitted a review during the standup window.
review_candidates = search_issues(
Expand All @@ -212,10 +215,10 @@ def gather_activity(user, since_date):
seen_ids.add(pr["id"])
reviewed_prs.append(pr)

# Issues opened
issues_opened = search_issues(f"author:{user} type:issue created:>{since}")
# Issues opened. is:issue excludes pull requests from GraphQL search results.
issues_opened = search_issues(f"author:{user} is:issue created:>{since}")

return merged_prs, reviewed_prs, issues_opened
return merged_prs, opened_prs, reviewed_prs, issues_opened


def gather_potential_bottlenecks(user, since_date):
Expand Down Expand Up @@ -245,6 +248,7 @@ def gather_potential_bottlenecks(user, since_date):
def format_contributor_comment(
user,
merged_prs,
opened_prs,
reviewed_prs,
issues_opened,
bottlenecks,
Expand All @@ -265,13 +269,19 @@ def format_contributor_comment(

# SHIPPED section
lines.append("### Shipped")
if merged_prs or reviewed_prs or issues_opened:
if merged_prs or opened_prs or reviewed_prs or issues_opened:
if merged_prs:
lines.append("")
lines.append("**PRs merged:**")
for pr in merged_prs:
lines.append(f"- [{pr['title']}]({pr['html_url']})")

if opened_prs:
lines.append("")
lines.append("**PRs opened:**")
for pr in opened_prs:
lines.append(f"- [{pr['title']}]({pr['html_url']})")

if reviewed_prs:
lines.append("")
lines.append("**PRs reviewed:**")
Expand Down
Loading