Skip to content

Commit 6a44340

Browse files
committed
Use regression test for bots
1 parent e486c35 commit 6a44340

3 files changed

Lines changed: 53 additions & 7 deletions

File tree

github_activity/github_activity.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,31 @@ def generate_activity_md(
472472
bot_users = data.attrs["bot_users"]
473473

474474
def ignored_user(username):
475-
if username in bot_users:
475+
if not username:
476+
return False
477+
478+
# First check against GraphQL-detected bot users
479+
# It is common for a bot to have `username` in GitHub and `username[bot]` in commits.
480+
# So this accounts for that.
481+
normalized_username = username.replace("[bot]", "")
482+
if normalized_username in bot_users:
476483
return True
484+
485+
# Next use pattern-based fallback for bots not detected by GraphQL
486+
username_lower = username.lower()
487+
bot_patterns = [
488+
"[bot]", # e.g., github-actions[bot], codecov[bot]
489+
"-bot", # e.g., renovate-bot, release-bot, dependabot
490+
]
491+
if any(pattern in username_lower for pattern in bot_patterns):
492+
return True
493+
494+
# Check against user-specified ignored contributors
477495
if ignored_contributors and any(
478496
fnmatch.fnmatch(username, user) for user in ignored_contributors
479497
):
480498
return True
499+
481500
return False
482501

483502
def filter_ignored(userlist):

tests/test_cli.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ def test_contributor_sorting(tmpdir, file_regression):
143143
file_regression.check(md, extension=".md")
144144

145145

146-
def test_bot_filtering(tmpdir):
146+
@mark.integration
147+
def test_bot_filtering(file_regression):
147148
"""Test that bot users are detected and filtered from output."""
148149
from github_activity.github_activity import get_activity, generate_activity_md
149150

@@ -157,14 +158,17 @@ def test_bot_filtering(tmpdir):
157158
# Verify bot_users attrs exists and was preserved (catches the concat bug)
158159
assert "bot_users" in data.attrs, "bot_users should be in DataFrame attrs"
159160

160-
# Generate markdown and verify no bots appear
161+
# Verify we actually detected some bots
162+
assert len(data.attrs["bot_users"]) > 0, (
163+
"Should have detected bot users in this release"
164+
)
165+
166+
# Generate markdown and save as regression baseline
161167
md = generate_activity_md(
162168
target="jupyter-book/mystmd",
163169
since="mystmd@1.6.5",
164170
until="mystmd@1.6.6",
165171
)
166172

167-
# Ensure changeset-bot is not anywhere in the output
168-
assert "changeset-bot" not in md, (
169-
"changeset-bot should not appear anywhere in output"
170-
)
173+
# Use this regression test to make sure no bots are in the output
174+
file_regression.check(md, extension=".md")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# mystmd@1.6.5...mystmd@1.6.6
2+
3+
([full changelog](https://github.com/jupyter-book/mystmd/compare/mystmd@1.6.5...mystmd@1.6.6))
4+
5+
## Bugs fixed
6+
7+
- Fix execution bug: no need for kernelspec if no executable content [#2454](https://github.com/jupyter-book/mystmd/pull/2454) ([@choldgraf](https://github.com/choldgraf), [@stefanv](https://github.com/stefanv))
8+
9+
## Other merged PRs
10+
11+
- 🚀 Release [#2457](https://github.com/jupyter-book/mystmd/pull/2457) ([@stefanv](https://github.com/stefanv))
12+
- Pull in latest myst-execute [#2456](https://github.com/jupyter-book/mystmd/pull/2456) ([@stefanv](https://github.com/stefanv))
13+
- 🚀 Release [#2455](https://github.com/jupyter-book/mystmd/pull/2455) ([@stefanv](https://github.com/stefanv))
14+
- 🚀 Release [#2416](https://github.com/jupyter-book/mystmd/pull/2416) ([@bsipocz](https://github.com/bsipocz), [@choldgraf](https://github.com/choldgraf), [@stefanv](https://github.com/stefanv))
15+
16+
## Contributors to this release
17+
18+
The following people contributed discussions, new ideas, code and documentation contributions, and review.
19+
See [our definition of contributors](https://github-activity.readthedocs.io/en/latest/#how-does-this-tool-define-contributions-in-the-reports).
20+
21+
([GitHub contributors page for this release](https://github.com/jupyter-book/mystmd/graphs/contributors?from=2025-11-18&to=2025-11-19&type=c))
22+
23+
@bsipocz ([activity](https://github.com/search?q=repo%3Ajupyter-book%2Fmystmd+involves%3Absipocz+updated%3A2025-11-18..2025-11-19&type=Issues)) | @choldgraf ([activity](https://github.com/search?q=repo%3Ajupyter-book%2Fmystmd+involves%3Acholdgraf+updated%3A2025-11-18..2025-11-19&type=Issues)) | @jukent ([activity](https://github.com/search?q=repo%3Ajupyter-book%2Fmystmd+involves%3Ajukent+updated%3A2025-11-18..2025-11-19&type=Issues)) | @stefanv ([activity](https://github.com/search?q=repo%3Ajupyter-book%2Fmystmd+involves%3Astefanv+updated%3A2025-11-18..2025-11-19&type=Issues))

0 commit comments

Comments
 (0)