skip changelog check for docs-only PRs

This commit is contained in:
David Hewitt 2023-09-21 21:38:07 +01:00
parent d7cf4270f3
commit 668918f5d3
4 changed files with 16 additions and 4 deletions

View File

@ -4,6 +4,7 @@ By submitting these contributions you agree for them to be dual-licensed under P
Please consider adding the following to your pull request:
- an entry for this PR in newsfragments - see [https://pyo3.rs/main/contributing.html#documenting-changes]
- or start the PR title with `docs:` if this is a docs-only change to skip the check
- docs to all new functions and / or detail in the guide
- tests for all new or changed functions

View File

@ -2,7 +2,7 @@ name: changelog
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
types: [opened, synchronize, labeled, unlabeled, edited]
jobs:
check:

View File

@ -111,6 +111,8 @@ To include your changes in the release notes, you should create one (or more) ne
- `removed` - for features which have been removed
- `fixed` - for "changed" features which were classed as a bugfix
Docs-only PRs do not need news items; start your PR title with `docs:` to skip the check.
### Style guide
#### Generic code

View File

@ -416,6 +416,12 @@ def address_sanitizer(session: nox.Session):
)
_IGNORE_CHANGELOG_PR_CATEGORIES = (
"release",
"docs",
)
@nox.session(name="check-changelog")
def check_changelog(session: nox.Session):
event_path = os.environ.get("GITHUB_EVENT_PATH")
@ -425,8 +431,9 @@ def check_changelog(session: nox.Session):
with open(event_path) as event_file:
event = json.load(event_file)
if event["pull_request"]["title"].startswith("release:"):
session.skip("PR title starts with release")
for category in _IGNORE_CHANGELOG_PR_CATEGORIES:
if event["pull_request"]["title"].startswith(f"{category}:"):
session.skip(f"PR title starts with {category}")
for label in event["pull_request"]["labels"]:
if label["name"] == "CI-skip-changelog":
@ -448,7 +455,9 @@ def check_changelog(session: nox.Session):
if not fragments:
session.error(
"Changelog entry not found, please add one (or more) to `newsfragments` directory. For more information see https://github.com/PyO3/pyo3/blob/main/Contributing.md#documenting-changes"
"Changelog entry not found, please add one (or more) to the `newsfragments` directory.\n"
"Alternatively, start the PR title with `docs:` if this PR is a docs-only PR.\n"
"See https://github.com/PyO3/pyo3/blob/main/Contributing.md#documenting-changes for more information."
)
print("Found newsfragments:")