Skip to content

Commit 79db35e

Browse files
authored
Allow standup without contributor list (payjoin#1751)
2 parents f8190f4 + 2bd45a6 commit 79db35e

2 files changed

Lines changed: 58 additions & 10 deletions

File tree

.github/scripts/compile_standup.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Update the latest Weekly Check-in Discussion body with participation summary."""
33

44
import os
5+
import re
56
from pathlib import Path
67

78
import requests
@@ -16,8 +17,21 @@
1617
}
1718

1819
_CONFIG_PATH = Path(__file__).resolve().parent.parent / "standup-contributors.yml"
19-
with open(_CONFIG_PATH) as _f:
20-
CONTRIBUTORS = [c["username"] for c in yaml.safe_load(_f)["contributors"]]
20+
21+
22+
def load_contributors():
23+
"""Return configured proactive check-in prompts, if any."""
24+
if not _CONFIG_PATH.exists():
25+
return []
26+
with open(_CONFIG_PATH) as f:
27+
data = yaml.safe_load(f) or {}
28+
return [c["username"] for c in data.get("contributors", [])]
29+
30+
31+
CONTRIBUTORS = load_contributors()
32+
BOT_LOGIN = "payjoin-bot"
33+
SUCCESS_MARKER = "### Shipped"
34+
TRIGGER_RE = re.compile(r"(?im)(^|\s)/check-in\b")
2135

2236

2337
def graphql(query, variables=None):
@@ -70,8 +84,10 @@ def get_discussion_comments(discussion_id):
7084
comments(first: 50) {
7185
nodes {
7286
body
87+
author { login }
7388
replies(first: 50) {
7489
nodes {
90+
body
7591
author { login }
7692
}
7793
}
@@ -87,8 +103,9 @@ def get_discussion_comments(discussion_id):
87103

88104

89105
def check_participation(comments):
90-
"""Return list of contributors who replied to their thread."""
106+
"""Return list of contributors who participated in this check-in."""
91107
participated = []
108+
seen = set()
92109
for comment in comments:
93110
body = comment["body"]
94111
for user in CONTRIBUTORS:
@@ -97,8 +114,19 @@ def check_participation(comments):
97114
reply_authors = {
98115
r["author"]["login"] for r in comment["replies"]["nodes"] if r["author"]
99116
}
100-
if user in reply_authors:
117+
if user in reply_authors and user not in seen:
101118
participated.append(user)
119+
seen.add(user)
120+
author = (comment.get("author") or {}).get("login")
121+
if not author or author in seen or not TRIGGER_RE.search(body):
122+
continue
123+
for reply in comment["replies"]["nodes"]:
124+
reply_author = (reply.get("author") or {}).get("login")
125+
reply_body = reply.get("body") or ""
126+
if reply_author == BOT_LOGIN and reply_body.startswith(SUCCESS_MARKER):
127+
participated.append(author)
128+
seen.add(author)
129+
break
102130
return participated
103131

104132

.github/scripts/create_standup_discussion.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@
2121
CATEGORY_NODE_ID = os.environ["DISCUSSION_CATEGORY_NODE_ID"]
2222

2323
_CONFIG_PATH = Path(__file__).resolve().parent.parent / "standup-contributors.yml"
24-
with open(_CONFIG_PATH) as _f:
25-
CONTRIBUTORS = [c["username"] for c in yaml.safe_load(_f)["contributors"]]
24+
25+
26+
def load_contributors():
27+
"""Return configured proactive check-in prompts, if any."""
28+
if not _CONFIG_PATH.exists():
29+
return []
30+
with open(_CONFIG_PATH) as f:
31+
data = yaml.safe_load(f) or {}
32+
return [c["username"] for c in data.get("contributors", [])]
33+
34+
35+
CONTRIBUTORS = load_contributors()
2636

2737

2838
def get_repo_node_id():
@@ -171,11 +181,21 @@ def main():
171181

172182
repo_node_id = get_repo_node_id()
173183
title = f"Weekly Check-in: {week_label}"
184+
if CONTRIBUTORS:
185+
intro = (
186+
"Weekly standup — each contributor has a thread below "
187+
"with auto-gathered activity.\n\n"
188+
"**Reply to your thread by end-of-day Monday (your timezone).** "
189+
)
190+
else:
191+
intro = (
192+
"Weekly standup — comment `/check-in` by end-of-day Monday "
193+
"(your timezone) for an auto-gathered activity thread.\n\n"
194+
)
195+
174196
body = (
175-
"Weekly standup — each contributor has a thread below "
176-
"with auto-gathered activity.\n\n"
177-
"**Reply to your thread by end-of-day Monday (your timezone).** "
178-
"Copy the template below and fill it in:\n\n"
197+
intro
198+
+ "Copy the template below and fill it in:\n\n"
179199
"```markdown\n"
180200
"### Shipped\n"
181201
"<!-- Add anything the bot missed: design work, specs, "

0 commit comments

Comments
 (0)