From 8e551f7b27ab7747ffbb3e58eb70f5a0615c23a1 Mon Sep 17 00:00:00 2001 From: choldgraf Date: Mon, 15 Dec 2025 13:31:53 -0800 Subject: [PATCH 1/3] Use a local release for bot test --- tests/test_cli.py | 22 ++++++++----- tests/test_cli/test_bot_filtering.md | 47 ++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 7efef3d..1765013 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -143,16 +143,22 @@ def test_contributor_sorting(tmpdir, file_regression): file_regression.check(md, extension=".md") -@mark.integration def test_bot_filtering(file_regression): """Test that bot users are detected and filtered from output.""" from github_activity.github_activity import get_activity, generate_activity_md - # Use jupyter-book/mystmd because it's a small release, and know theres bot activity + # This is a release that has dependabot activity, so we test that it no longer + # shows up in the changelog. It *will* show up in the release below because it's + # from before this feature was implemented. + # ref: https://github.com/executablebooks/github-activity/releases/tag/v1.1.0 + org = "executablebooks" + repo = "github-activity" + since = "v1.0.2" + until = "v1.1.0" data = get_activity( - target="jupyter-book/mystmd", - since="mystmd@1.6.5", - until="mystmd@1.6.6", + target=f"{org}/{repo}", + since=since, + until=until, ) # Verify bot_users attrs exists and was preserved (catches the concat bug) @@ -165,9 +171,9 @@ def test_bot_filtering(file_regression): # Generate markdown and save as regression baseline md = generate_activity_md( - target="jupyter-book/mystmd", - since="mystmd@1.6.5", - until="mystmd@1.6.6", + target=f"{org}/{repo}", + since=since, + until=until, ) # Use this regression test to make sure no bots are in the output diff --git a/tests/test_cli/test_bot_filtering.md b/tests/test_cli/test_bot_filtering.md index ea0f551..611a5d0 100644 --- a/tests/test_cli/test_bot_filtering.md +++ b/tests/test_cli/test_bot_filtering.md @@ -1,23 +1,52 @@ -# mystmd@1.6.5...mystmd@1.6.6 +# v1.0.2...v1.1.0 -([full changelog](https://github.com/jupyter-book/mystmd/compare/mystmd@1.6.5...mystmd@1.6.6)) +([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.1.0)) + +## Enhancements made + +- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@choldgraf](https://github.com/choldgraf), [@nabobalis](https://github.com/nabobalis)) ## Bugs fixed -- 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)) +- Add `pytz` to requirements [#147](https://github.com/executablebooks/github-activity/pull/147) ([@jtpio](https://github.com/jtpio), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) +- Ensure PRs only show up once per changelog [#130](https://github.com/executablebooks/github-activity/pull/130) ([@choldgraf](https://github.com/choldgraf), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) + +## Maintenance and upkeep improvements + +- MAINT: group the dependabot updates into one PR [#141](https://github.com/executablebooks/github-activity/pull/141) ([@bsipocz](https://github.com/bsipocz)) +- Expose GitHub API call error [#138](https://github.com/executablebooks/github-activity/pull/138) ([@stefanv](https://github.com/stefanv), [@choldgraf](https://github.com/choldgraf)) +- Update pre-commit to use Ruff; update versions and add a few rules [#137](https://github.com/executablebooks/github-activity/pull/137) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz)) +- Change token to readonly PAT so we don't hit rate limits [#134](https://github.com/executablebooks/github-activity/pull/134) ([@choldgraf](https://github.com/choldgraf), [@bsipocz](https://github.com/bsipocz)) +- Fix tests and move contributing docs into our docs [#133](https://github.com/executablebooks/github-activity/pull/133) ([@choldgraf](https://github.com/choldgraf)) + +## Documentation improvements + +- make sure generated anchor links resolve [#122](https://github.com/executablebooks/github-activity/pull/122) ([@minrk](https://github.com/minrk), [@consideRatio](https://github.com/consideRatio)) +- Add changelog for v1.0.3 [#120](https://github.com/executablebooks/github-activity/pull/120) ([@consideRatio](https://github.com/consideRatio)) +- Add changelog for v1.0.2 [#117](https://github.com/executablebooks/github-activity/pull/117) ([@consideRatio](https://github.com/consideRatio)) + +## Continuous integration improvements + +- ci: fix github action tag in publish workflow [#119](https://github.com/executablebooks/github-activity/pull/119) ([@consideRatio](https://github.com/consideRatio)) +- ci: fix location of dependabot.yaml [#118](https://github.com/executablebooks/github-activity/pull/118) ([@consideRatio](https://github.com/consideRatio)) ## Other merged PRs -- 🚀 Release [#2457](https://github.com/jupyter-book/mystmd/pull/2457) ([@stefanv](https://github.com/stefanv)) -- Pull in latest myst-execute [#2456](https://github.com/jupyter-book/mystmd/pull/2456) ([@stefanv](https://github.com/stefanv)) -- 🚀 Release [#2455](https://github.com/jupyter-book/mystmd/pull/2455) ([@stefanv](https://github.com/stefanv)) -- 🚀 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)) +- RLS: v1.1.0 [#149](https://github.com/executablebooks/github-activity/pull/149) ([@choldgraf](https://github.com/choldgraf)) +- Use GraphQL API for bot detection [#146](https://github.com/executablebooks/github-activity/pull/146) ([@choldgraf](https://github.com/choldgraf), [@stefanv](https://github.com/stefanv)) +- Update test suite to use fewer GitHub API calls [#144](https://github.com/executablebooks/github-activity/pull/144) ([@choldgraf](https://github.com/choldgraf), [@bsipocz](https://github.com/bsipocz), [@stefanv](https://github.com/stefanv)) +- Bump actions/checkout from 5 to 6 in the actions group [#143](https://github.com/executablebooks/github-activity/pull/143) ([@bsipocz](https://github.com/bsipocz)) +- Bump actions/checkout from 4 to 5 [#140](https://github.com/executablebooks/github-activity/pull/140) ([@bsipocz](https://github.com/bsipocz)) +- Bump actions/setup-python from 5 to 6 [#139](https://github.com/executablebooks/github-activity/pull/139) ([@bsipocz](https://github.com/bsipocz)) +- add pyproject.toml [#132](https://github.com/executablebooks/github-activity/pull/132) ([@minrk](https://github.com/minrk), [@choldgraf](https://github.com/choldgraf)) +- [DOC] Clarify some intended functionality in docs [#127](https://github.com/executablebooks/github-activity/pull/127) ([@choldgraf](https://github.com/choldgraf), [@manics](https://github.com/manics)) +- Use latest github release first instead of github tag [#125](https://github.com/executablebooks/github-activity/pull/125) ([@choldgraf](https://github.com/choldgraf), [@nabobalis](https://github.com/nabobalis)) ## Contributors to this release The following people contributed discussions, new ideas, code and documentation contributions, and review. See [our definition of contributors](https://github-activity.readthedocs.io/en/latest/#how-does-this-tool-define-contributions-in-the-reports). -([GitHub contributors page for this release](https://github.com/jupyter-book/mystmd/graphs/contributors?from=2025-11-18&to=2025-11-19&type=c)) +([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2025-04-11&to=2025-12-09&type=c)) -@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)) +@bsipocz ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Absipocz+updated%3A2025-04-11..2025-12-09&type=Issues)) | @choldgraf ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Acholdgraf+updated%3A2025-04-11..2025-12-09&type=Issues)) | @consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @jtpio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Ajtpio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @manics ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Amanics+updated%3A2025-04-11..2025-12-09&type=Issues)) | @minrk ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Aminrk+updated%3A2025-04-11..2025-12-09&type=Issues)) | @nabobalis ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Anabobalis+updated%3A2025-04-11..2025-12-09&type=Issues)) | @stefanv ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Astefanv+updated%3A2025-04-11..2025-12-09&type=Issues)) From 2865636e5f6987d68cdd253846612360e038a1c4 Mon Sep 17 00:00:00 2001 From: choldgraf Date: Mon, 15 Dec 2025 13:42:19 -0800 Subject: [PATCH 2/3] Consolidate a few tests into one --- tests/test_cli.py | 93 ++++++---------------- tests/test_cli/test_bot_filtering.md | 52 ------------ tests/test_cli/test_contributor_sorting.md | 28 ------- tests/test_cli/test_pr_split.md | 14 ---- 4 files changed, 25 insertions(+), 162 deletions(-) delete mode 100644 tests/test_cli/test_bot_filtering.md delete mode 100644 tests/test_cli/test_contributor_sorting.md delete mode 100644 tests/test_cli/test_pr_split.md diff --git a/tests/test_cli.py b/tests/test_cli.py index 1765013..224a20a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -92,60 +92,12 @@ def test_cli_nonexistent_branch(tmpdir): assert "Merged PRs" not in md -def test_pr_split(tmpdir, file_regression): - """Test that PRs are properly split by tags/prefixes.""" - path_tmp = Path(tmpdir) - path_output = path_tmp.joinpath("out.md") - - url = "https://github.com/executablebooks/github-activity" - - # Test PR tag/prefix splitting using recent consecutive releases - cmd = f"github-activity {url} -s v1.0.2 -u v1.0.3 -o {path_output}" - run(cmd.split(), check=True) - md = path_output.read_text() - md = md.split("## Contributors to this release")[0] - file_regression.check(md, extension=".md") - - -def test_cli_all(tmpdir, file_regression): - """Test that a full changelog is created""" - path_tmp = Path(tmpdir) - path_output = path_tmp.joinpath("out.md") - # Use recent consecutive releases to reduce API calls - cmd = f"github-activity executablebooks/github-activity -s v1.0.2 -u v1.0.3 -o {path_output}" - run(cmd.split(), check=True) - md = path_output.read_text() - file_regression.check(md, extension=".md") - - -def test_cli_ignore_user(tmpdir): - """Test that a full changelog is created""" - path_tmp = Path(tmpdir) - path_output = path_tmp.joinpath("out.md") - # Add end date to limit query range - cmd = f"github-activity executablebooks/github-activity --ignore-contributor choldgraf -s v1.0.2 -u v1.0.3 -o {path_output}" - run(cmd.split(), check=True) - md = path_output.read_text() - assert "@choldgraf" not in md - - -def test_contributor_sorting(tmpdir, file_regression): - """Test that PR author appears first, then rest of contributors, sorted""" - path_tmp = Path(tmpdir) - path_output = path_tmp.joinpath("out.md") - - org, repo = ("executablebooks", "github-activity") - - # Test contributor sorting using recent consecutive releases - cmd = f"github-activity {org}/{repo} -s v0.2.0 -u v0.3.0 -o {path_output}" - run(cmd.split(), check=True) - md = path_output.read_text() - file_regression.check(md, extension=".md") - +def test_changelog_features(file_regression): + """Combined test for multiple changelog features to minimize API calls. -def test_bot_filtering(file_regression): - """Test that bot users are detected and filtered from output.""" - from github_activity.github_activity import get_activity, generate_activity_md + This tests a few things in one regression test. + """ + from github_activity.github_activity import generate_activity_md # This is a release that has dependabot activity, so we test that it no longer # shows up in the changelog. It *will* show up in the release below because it's @@ -155,26 +107,31 @@ def test_bot_filtering(file_regression): repo = "github-activity" since = "v1.0.2" until = "v1.1.0" - data = get_activity( + + # Test general changelog structure with a regression test + md_full = generate_activity_md( target=f"{org}/{repo}", since=since, until=until, + ignored_contributors=["choldgraf"], ) + file_regression.check(md_full, basename="test_cli_all", extension=".md") - # Verify bot_users attrs exists and was preserved (catches the concat bug) - assert "bot_users" in data.attrs, "bot_users should be in DataFrame attrs" + # Test that PRs are split into multiple sections + md_split = md_full.split("## Contributors to this release")[0] + file_regression.check(md_split, basename="test_pr_split", extension=".md") - # Verify we actually detected some bots - assert len(data.attrs["bot_users"]) > 0, ( - "Should have detected bot users in this release" - ) + # Test that contributor sorting works, minus @choldgraf since we filtered him out (sorry Chris) + assert ( + "- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis))" + in md_full + ), "Contributors should be sorted as expected" - # Generate markdown and save as regression baseline - md = generate_activity_md( - target=f"{org}/{repo}", - since=since, - until=until, + # Test that ignored usernames are ignored + assert "choldgraf" not in md_full.lower(), ( + "Ignored contributor should not appear in output" + ) + # Test that bots are removed + assert "dependabot" not in md_full.lower(), ( + "Bot user dependabot should not appear in output" ) - - # Use this regression test to make sure no bots are in the output - file_regression.check(md, extension=".md") diff --git a/tests/test_cli/test_bot_filtering.md b/tests/test_cli/test_bot_filtering.md deleted file mode 100644 index 611a5d0..0000000 --- a/tests/test_cli/test_bot_filtering.md +++ /dev/null @@ -1,52 +0,0 @@ -# v1.0.2...v1.1.0 - -([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.1.0)) - -## Enhancements made - -- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@choldgraf](https://github.com/choldgraf), [@nabobalis](https://github.com/nabobalis)) - -## Bugs fixed - -- Add `pytz` to requirements [#147](https://github.com/executablebooks/github-activity/pull/147) ([@jtpio](https://github.com/jtpio), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) -- Ensure PRs only show up once per changelog [#130](https://github.com/executablebooks/github-activity/pull/130) ([@choldgraf](https://github.com/choldgraf), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) - -## Maintenance and upkeep improvements - -- MAINT: group the dependabot updates into one PR [#141](https://github.com/executablebooks/github-activity/pull/141) ([@bsipocz](https://github.com/bsipocz)) -- Expose GitHub API call error [#138](https://github.com/executablebooks/github-activity/pull/138) ([@stefanv](https://github.com/stefanv), [@choldgraf](https://github.com/choldgraf)) -- Update pre-commit to use Ruff; update versions and add a few rules [#137](https://github.com/executablebooks/github-activity/pull/137) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz)) -- Change token to readonly PAT so we don't hit rate limits [#134](https://github.com/executablebooks/github-activity/pull/134) ([@choldgraf](https://github.com/choldgraf), [@bsipocz](https://github.com/bsipocz)) -- Fix tests and move contributing docs into our docs [#133](https://github.com/executablebooks/github-activity/pull/133) ([@choldgraf](https://github.com/choldgraf)) - -## Documentation improvements - -- make sure generated anchor links resolve [#122](https://github.com/executablebooks/github-activity/pull/122) ([@minrk](https://github.com/minrk), [@consideRatio](https://github.com/consideRatio)) -- Add changelog for v1.0.3 [#120](https://github.com/executablebooks/github-activity/pull/120) ([@consideRatio](https://github.com/consideRatio)) -- Add changelog for v1.0.2 [#117](https://github.com/executablebooks/github-activity/pull/117) ([@consideRatio](https://github.com/consideRatio)) - -## Continuous integration improvements - -- ci: fix github action tag in publish workflow [#119](https://github.com/executablebooks/github-activity/pull/119) ([@consideRatio](https://github.com/consideRatio)) -- ci: fix location of dependabot.yaml [#118](https://github.com/executablebooks/github-activity/pull/118) ([@consideRatio](https://github.com/consideRatio)) - -## Other merged PRs - -- RLS: v1.1.0 [#149](https://github.com/executablebooks/github-activity/pull/149) ([@choldgraf](https://github.com/choldgraf)) -- Use GraphQL API for bot detection [#146](https://github.com/executablebooks/github-activity/pull/146) ([@choldgraf](https://github.com/choldgraf), [@stefanv](https://github.com/stefanv)) -- Update test suite to use fewer GitHub API calls [#144](https://github.com/executablebooks/github-activity/pull/144) ([@choldgraf](https://github.com/choldgraf), [@bsipocz](https://github.com/bsipocz), [@stefanv](https://github.com/stefanv)) -- Bump actions/checkout from 5 to 6 in the actions group [#143](https://github.com/executablebooks/github-activity/pull/143) ([@bsipocz](https://github.com/bsipocz)) -- Bump actions/checkout from 4 to 5 [#140](https://github.com/executablebooks/github-activity/pull/140) ([@bsipocz](https://github.com/bsipocz)) -- Bump actions/setup-python from 5 to 6 [#139](https://github.com/executablebooks/github-activity/pull/139) ([@bsipocz](https://github.com/bsipocz)) -- add pyproject.toml [#132](https://github.com/executablebooks/github-activity/pull/132) ([@minrk](https://github.com/minrk), [@choldgraf](https://github.com/choldgraf)) -- [DOC] Clarify some intended functionality in docs [#127](https://github.com/executablebooks/github-activity/pull/127) ([@choldgraf](https://github.com/choldgraf), [@manics](https://github.com/manics)) -- Use latest github release first instead of github tag [#125](https://github.com/executablebooks/github-activity/pull/125) ([@choldgraf](https://github.com/choldgraf), [@nabobalis](https://github.com/nabobalis)) - -## Contributors to this release - -The following people contributed discussions, new ideas, code and documentation contributions, and review. -See [our definition of contributors](https://github-activity.readthedocs.io/en/latest/#how-does-this-tool-define-contributions-in-the-reports). - -([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2025-04-11&to=2025-12-09&type=c)) - -@bsipocz ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Absipocz+updated%3A2025-04-11..2025-12-09&type=Issues)) | @choldgraf ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Acholdgraf+updated%3A2025-04-11..2025-12-09&type=Issues)) | @consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @jtpio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Ajtpio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @manics ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Amanics+updated%3A2025-04-11..2025-12-09&type=Issues)) | @minrk ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Aminrk+updated%3A2025-04-11..2025-12-09&type=Issues)) | @nabobalis ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Anabobalis+updated%3A2025-04-11..2025-12-09&type=Issues)) | @stefanv ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Astefanv+updated%3A2025-04-11..2025-12-09&type=Issues)) diff --git a/tests/test_cli/test_contributor_sorting.md b/tests/test_cli/test_contributor_sorting.md deleted file mode 100644 index 198f512..0000000 --- a/tests/test_cli/test_contributor_sorting.md +++ /dev/null @@ -1,28 +0,0 @@ -# v0.2.0...v0.3.0 - -([full changelog](https://github.com/executablebooks/github-activity/compare/v0.2.0...v0.3.0)) - -## New features added - -- Add ability to use GH CLI Authentication [#66](https://github.com/executablebooks/github-activity/pull/66) ([@choldgraf](https://github.com/choldgraf)) - -## Enhancements made - -- [ENH] Add a bootstrap function for all changelog entries [#64](https://github.com/executablebooks/github-activity/pull/64) ([@blink1073](https://github.com/blink1073), [@choldgraf](https://github.com/choldgraf), [@jtpio](https://github.com/jtpio)) - -## Bugs fixed - -- BUG: import dateutil.parser [#73](https://github.com/executablebooks/github-activity/pull/73) ([@agoose77](https://github.com/agoose77), [@choldgraf](https://github.com/choldgraf), [@consideRatio](https://github.com/consideRatio)) - -## Maintenance and upkeep improvements - -- MAINT: Add check for installed gh cli [#72](https://github.com/executablebooks/github-activity/pull/72) ([@choldgraf](https://github.com/choldgraf), [@stefanv](https://github.com/stefanv)) - -## Contributors to this release - -The following people contributed discussions, new ideas, code and documentation contributions, and review. -See [our definition of contributors](https://github-activity.readthedocs.io/en/latest/#how-does-this-tool-define-contributions-in-the-reports). - -([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2021-12-01&to=2023-02-13&type=c)) - -@agoose77 ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Aagoose77+updated%3A2021-12-01..2023-02-13&type=Issues)) | @blink1073 ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Ablink1073+updated%3A2021-12-01..2023-02-13&type=Issues)) | @choldgraf ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Acholdgraf+updated%3A2021-12-01..2023-02-13&type=Issues)) | @consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2021-12-01..2023-02-13&type=Issues)) | @jtpio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Ajtpio+updated%3A2021-12-01..2023-02-13&type=Issues)) | @stefanv ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Astefanv+updated%3A2021-12-01..2023-02-13&type=Issues)) diff --git a/tests/test_cli/test_pr_split.md b/tests/test_cli/test_pr_split.md deleted file mode 100644 index 6947f38..0000000 --- a/tests/test_cli/test_pr_split.md +++ /dev/null @@ -1,14 +0,0 @@ -# v1.0.2...v1.0.3 - -([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.0.3)) - -## Documentation improvements - -- Add changelog for v1.0.3 [#120](https://github.com/executablebooks/github-activity/pull/120) ([@consideRatio](https://github.com/consideRatio)) -- Add changelog for v1.0.2 [#117](https://github.com/executablebooks/github-activity/pull/117) ([@consideRatio](https://github.com/consideRatio)) - -## Continuous integration improvements - -- ci: fix github action tag in publish workflow [#119](https://github.com/executablebooks/github-activity/pull/119) ([@consideRatio](https://github.com/consideRatio)) -- ci: fix location of dependabot.yaml [#118](https://github.com/executablebooks/github-activity/pull/118) ([@consideRatio](https://github.com/consideRatio)) - From af7ef865757021e388a873b11f8ec841c5e7a08f Mon Sep 17 00:00:00 2001 From: choldgraf Date: Mon, 15 Dec 2025 13:48:22 -0800 Subject: [PATCH 3/3] Consolidate on one test --- github_activity/github_activity.py | 21 ++++++++++------- tests/test_cli.py | 9 +++---- tests/test_cli/test_cli_all.md | 38 ++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/github_activity/github_activity.py b/github_activity/github_activity.py index 40018c8..4456da2 100644 --- a/github_activity/github_activity.py +++ b/github_activity/github_activity.py @@ -472,7 +472,8 @@ def generate_activity_md( bot_users = data.attrs["bot_users"] def ignored_user(username): - if not username: + # Handle None, empty strings, and non-string types (like NaN) + if not username or not isinstance(username, str): return False # First check against GraphQL-detected bot users @@ -561,17 +562,19 @@ def filter_ignored(userlist): item_commenters_counts >= comment_response_cutoff ].index.tolist() for person in item_commenters_counts: - all_contributors.add(person) + # Filter out NaN values and non-strings + if isinstance(person, str): + all_contributors.add(person) # record contributor list (ordered, unique) data.at[ix, "contributors"] = list(item_contributors) comment_contributor_counts = pd.Series(comment_helpers).value_counts() - all_contributors |= set( - comment_contributor_counts[ - comment_contributor_counts >= comment_others_cutoff - ].index.tolist() - ) + # Filter out NaN values and non-strings + comment_contributors = comment_contributor_counts[ + comment_contributor_counts >= comment_others_cutoff + ].index.tolist() + all_contributors |= set(c for c in comment_contributors if isinstance(c, str)) # Filter the PRs by branch (or ref) if given if branch is not None: @@ -610,7 +613,9 @@ def filter_ignored(userlist): closed_prs = closed_prs.query("state != 'CLOSED'") # Add any contributors to a merged PR to our contributors list - all_contributors |= set(closed_prs["contributors"].explode().unique().tolist()) + # Filter out NaN values and non-strings + pr_contributors = closed_prs["contributors"].explode().unique().tolist() + all_contributors |= set(c for c in pr_contributors if isinstance(c, str)) # Define categories for a few labels if tags is None: diff --git a/tests/test_cli.py b/tests/test_cli.py index 224a20a..437255a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -109,6 +109,7 @@ def test_changelog_features(file_regression): until = "v1.1.0" # Test general changelog structure with a regression test + # PRs should be split by issue label. md_full = generate_activity_md( target=f"{org}/{repo}", since=since, @@ -117,10 +118,6 @@ def test_changelog_features(file_regression): ) file_regression.check(md_full, basename="test_cli_all", extension=".md") - # Test that PRs are split into multiple sections - md_split = md_full.split("## Contributors to this release")[0] - file_regression.check(md_split, basename="test_pr_split", extension=".md") - # Test that contributor sorting works, minus @choldgraf since we filtered him out (sorry Chris) assert ( "- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis))" @@ -128,10 +125,10 @@ def test_changelog_features(file_regression): ), "Contributors should be sorted as expected" # Test that ignored usernames are ignored - assert "choldgraf" not in md_full.lower(), ( + assert "@choldgraf" not in md_full.lower(), ( "Ignored contributor should not appear in output" ) # Test that bots are removed - assert "dependabot" not in md_full.lower(), ( + assert "@dependabot" not in md_full.lower(), ( "Bot user dependabot should not appear in output" ) diff --git a/tests/test_cli/test_cli_all.md b/tests/test_cli/test_cli_all.md index 77915de..8f2308a 100644 --- a/tests/test_cli/test_cli_all.md +++ b/tests/test_cli/test_cli_all.md @@ -1,9 +1,27 @@ -# v1.0.2...v1.0.3 +# v1.0.2...v1.1.0 -([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.0.3)) +([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.1.0)) + +## Enhancements made + +- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) + +## Bugs fixed + +- Add `pytz` to requirements [#147](https://github.com/executablebooks/github-activity/pull/147) ([@jtpio](https://github.com/jtpio), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) +- Ensure PRs only show up once per changelog [#130](https://github.com/executablebooks/github-activity/pull/130) ([@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis)) + +## Maintenance and upkeep improvements + +- MAINT: group the dependabot updates into one PR [#141](https://github.com/executablebooks/github-activity/pull/141) ([@bsipocz](https://github.com/bsipocz)) +- Expose GitHub API call error [#138](https://github.com/executablebooks/github-activity/pull/138) ([@stefanv](https://github.com/stefanv)) +- Update pre-commit to use Ruff; update versions and add a few rules [#137](https://github.com/executablebooks/github-activity/pull/137) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz)) +- Change token to readonly PAT so we don't hit rate limits [#134](https://github.com/executablebooks/github-activity/pull/134) ([@bsipocz](https://github.com/bsipocz)) +- Fix tests and move contributing docs into our docs [#133](https://github.com/executablebooks/github-activity/pull/133) () ## Documentation improvements +- make sure generated anchor links resolve [#122](https://github.com/executablebooks/github-activity/pull/122) ([@minrk](https://github.com/minrk), [@consideRatio](https://github.com/consideRatio)) - Add changelog for v1.0.3 [#120](https://github.com/executablebooks/github-activity/pull/120) ([@consideRatio](https://github.com/consideRatio)) - Add changelog for v1.0.2 [#117](https://github.com/executablebooks/github-activity/pull/117) ([@consideRatio](https://github.com/consideRatio)) @@ -12,11 +30,23 @@ - ci: fix github action tag in publish workflow [#119](https://github.com/executablebooks/github-activity/pull/119) ([@consideRatio](https://github.com/consideRatio)) - ci: fix location of dependabot.yaml [#118](https://github.com/executablebooks/github-activity/pull/118) ([@consideRatio](https://github.com/consideRatio)) +## Other merged PRs + +- RLS: v1.1.0 [#149](https://github.com/executablebooks/github-activity/pull/149) () +- Use GraphQL API for bot detection [#146](https://github.com/executablebooks/github-activity/pull/146) ([@stefanv](https://github.com/stefanv)) +- Update test suite to use fewer GitHub API calls [#144](https://github.com/executablebooks/github-activity/pull/144) ([@bsipocz](https://github.com/bsipocz), [@stefanv](https://github.com/stefanv)) +- Bump actions/checkout from 5 to 6 in the actions group [#143](https://github.com/executablebooks/github-activity/pull/143) ([@bsipocz](https://github.com/bsipocz)) +- Bump actions/checkout from 4 to 5 [#140](https://github.com/executablebooks/github-activity/pull/140) ([@bsipocz](https://github.com/bsipocz)) +- Bump actions/setup-python from 5 to 6 [#139](https://github.com/executablebooks/github-activity/pull/139) ([@bsipocz](https://github.com/bsipocz)) +- add pyproject.toml [#132](https://github.com/executablebooks/github-activity/pull/132) ([@minrk](https://github.com/minrk)) +- [DOC] Clarify some intended functionality in docs [#127](https://github.com/executablebooks/github-activity/pull/127) ([@manics](https://github.com/manics)) +- Use latest github release first instead of github tag [#125](https://github.com/executablebooks/github-activity/pull/125) ([@nabobalis](https://github.com/nabobalis)) + ## Contributors to this release The following people contributed discussions, new ideas, code and documentation contributions, and review. See [our definition of contributors](https://github-activity.readthedocs.io/en/latest/#how-does-this-tool-define-contributions-in-the-reports). -([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2025-04-11&to=2025-04-11&type=c)) +([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2025-04-11&to=2025-12-09&type=c)) -@consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2025-04-11..2025-04-11&type=Issues)) +@bsipocz ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Absipocz+updated%3A2025-04-11..2025-12-09&type=Issues)) | @consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @jtpio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Ajtpio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @manics ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Amanics+updated%3A2025-04-11..2025-12-09&type=Issues)) | @minrk ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Aminrk+updated%3A2025-04-11..2025-12-09&type=Issues)) | @nabobalis ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Anabobalis+updated%3A2025-04-11..2025-12-09&type=Issues)) | @stefanv ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Astefanv+updated%3A2025-04-11..2025-12-09&type=Issues))