Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/scripts/pr_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import re
import sys
import tomllib
from pathlib import Path

import tomllib
from git import Repo


Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ jobs:
run: |
ruff check

- name: "Check Changelog Snippets"
run: |
uv run .ci/scripts/check_changelog_snippets.py

- name: "Run extra lint checks"
run: |
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh
Expand Down
3 changes: 2 additions & 1 deletion templates/ci/Makefile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lint:
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows
bump-my-version bump --dry-run --allow-dirty release
ruff format --check --diff
ruff check
ruff check --output-format concise
{%- if check_manifest %}
check-manifest
{%- endif %}
Expand All @@ -20,3 +20,4 @@ lint:
{%- if check_stray_pulpcore_imports %}
sh .ci/scripts/check_pulpcore_imports.sh
{%- endif %}
python .ci/scripts/check_changelog_snippets.py
46 changes: 46 additions & 0 deletions templates/github/.ci/scripts/check_changelog_snippets.py.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# ]
# ///
import re
import sys
from pathlib import Path

import tomllib

EXCEPTIONS = [
".TEMPLATE.md",
".gitkeep",
".gitignore",
{%- for plugin in plugins %}
{%- if plugin.app_label == "core" %}
"plugin_api",
{%- else %}
"{{ plugin.name | snake }}",
{%- endif %}
{%- endfor %}
]


def snippet_valid(path: Path, changelog_exts: list[str]) -> bool:
return (path.name in EXCEPTIONS) or (
path.suffix in changelog_exts
and (path.stem.startswith("+") or re.fullmatch(r"\d*", path.stem))
)


if __name__ == "__main__":
with Path("pyproject.toml").open("rb") as fp:
pyproject_toml = tomllib.load(fp)
try:
changelog_exts = [
f".{item['directory']}" for item in pyproject_toml["tool"]["towncrier"]["type"]
]
except KeyError:
changelog_exts = [".feature", ".bugfix", ".doc", ".removal", ".misc"]
matches = Path("CHANGES").rglob("*")
invalid_snippets = ", ".join(f"'{s}'" for s in matches if not snippet_valid(s, changelog_exts))
if invalid_snippets:
sys.exit(f"LINT: Invalid changelog entries: {invalid_snippets}.")
4 changes: 4 additions & 0 deletions templates/github/.github/workflows/lint.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
run: |
ruff check

- name: "Check Changelog Snippets"
run: |
uv run .ci/scripts/check_changelog_snippets.py

- name: "Run extra lint checks"
run: |
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh
Expand Down
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import re
import stat
import textwrap
import tomllib
from datetime import timedelta
from pathlib import Path

import requests_cache
import tomlkit
import tomllib
import yaml
from packaging.specifiers import SpecifierSet
from packaging.version import Version
Expand Down
Loading