From 85e5a18ad080e279fe5f0e0b1ad6d569b86f078e Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Tue, 6 Oct 2026 14:52:48 -0400 Subject: [PATCH] chore(github): add a release commit-type box to the PR template CONTRIBUTING.md lists release as a commit type, and release: commits exist in the history, but the PR template had no box for it. Add one above chore, which stays last as the catch-all, worded from process.rst's release label definition, and pin the template's boxes against CONTRIBUTING.md's type list in a new tests/project module. Closes #1102 --- .github/PULL_REQUEST_TEMPLATE.md | 1 + tests/project/test_conventions_doc_claims.py | 4 +- ...test_pr_template_commit_types_1102_unit.py | 43 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/project/test_pr_template_commit_types_1102_unit.py diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index cecd98ce08..72b27e2cb3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -20,6 +20,7 @@ Tick the [commit type](https://github.com/JarryShaw/PyPCAPKit/blob/main/CONTRIBU - [ ] `test` — tests only - [ ] `docs` — documentation only - [ ] `ci` — workflows or build tooling +- [ ] `release` — bumps the version or rolls up a distribution - [ ] `chore` — anything else --- diff --git a/tests/project/test_conventions_doc_claims.py b/tests/project/test_conventions_doc_claims.py index 629d8d25b6..a41a1f0e89 100644 --- a/tests/project/test_conventions_doc_claims.py +++ b/tests/project/test_conventions_doc_claims.py @@ -1410,8 +1410,8 @@ def test_the_page_names_every_commit_type_the_template_ticks(self) -> 'None': :file:`.github/PULL_REQUEST_TEMPLATE.md` is where a contributor actually meets the list, so it is the ground truth rather than a list retyped into this file. - Note the label set is a **superset**: ``release`` and ``const`` are type-ish - labels with no tickbox, so this is a one-way check by design. + Note the label set is a **superset**: ``const`` is a type-ish label with no + tickbox, so this is a one-way check by design. """ types = re.findall(r'^- \[ \] `([a-z]+)` ', self.TEMPLATE.read_text(encoding='utf-8'), diff --git a/tests/project/test_pr_template_commit_types_1102_unit.py b/tests/project/test_pr_template_commit_types_1102_unit.py new file mode 100644 index 0000000000..584c14071f --- /dev/null +++ b/tests/project/test_pr_template_commit_types_1102_unit.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +"""Every commit type :file:`CONTRIBUTING.md` allows has a box in the PR template (#1102). + +:file:`CONTRIBUTING.md` lists the valid ``type`` prefixes of a commit subject, and +:file:`.github/PULL_REQUEST_TEMPLATE.md` asks the contributor to tick the one their +subject carries. The template had no ``release`` box although ``release`` is a listed +type with commits in the history, so a version-bump pull request had nothing to tick. + +""" + +import pathlib +import re +import unittest + +ROOT = pathlib.Path(__file__).resolve().parents[2] + + +class TestPullRequestTemplateCommitTypes(unittest.TestCase): + """The template's commit-type boxes match :file:`CONTRIBUTING.md`'s type list.""" + + def _contributing_types(self) -> 'list[str]': + text = ' '.join((ROOT / 'CONTRIBUTING.md').read_text(encoding='utf-8').split()) + match = re.search(r'`type` is one of (.*?) —', text) + self.assertIsNotNone(match, 'CONTRIBUTING.md no longer states "`type` is one of ..."') + return re.findall(r'`([a-z]+)`', match.group(1)) # type: ignore[union-attr] + + def _template_types(self) -> 'list[str]': + text = (ROOT / '.github' / 'PULL_REQUEST_TEMPLATE.md').read_text(encoding='utf-8') + return re.findall(r'^- \[ \] `([a-z]+)` — ', text, re.MULTILINE) + + def test_every_contributing_type_has_a_template_box(self) -> 'None': + """Each type :file:`CONTRIBUTING.md` lists is tickable, and nothing else is.""" + listed = self._contributing_types() + self.assertGreaterEqual(len(listed), 9, + f'only {listed!r} parsed out of CONTRIBUTING.md; ' + 'the comparison below would pass vacuously') + self.assertEqual(sorted(self._template_types()), sorted(listed), + 'the pull request template\'s commit-type boxes differ from ' + 'the types CONTRIBUTING.md lists') + + +if __name__ == '__main__': + unittest.main()