diff --git a/hacking/pr_labeler/data/porting_guide_changes.md b/hacking/pr_labeler/data/porting_guide_changes.md new file mode 100644 index 0000000000..0e0cc12e3f --- /dev/null +++ b/hacking/pr_labeler/data/porting_guide_changes.md @@ -0,0 +1,8 @@ +The following files are automatically generated and should not be modified outside of the ansible release process: + +{% for file in changed_files %} +- {{ file }} +{% endfor %} + +Please double check your changes. + diff --git a/hacking/pr_labeler/label.py b/hacking/pr_labeler/label.py index 265d4b5e42..e13f13c47e 100644 --- a/hacking/pr_labeler/label.py +++ b/hacking/pr_labeler/label.py @@ -6,6 +6,7 @@ from __future__ import annotations import dataclasses import json import os +import re from collections.abc import Collection from contextlib import suppress from functools import cached_property @@ -26,6 +27,14 @@ REPO = "ansible-documentation" LABELS_BY_CODEOWNER: dict[OwnerTuple, list[str]] = { ("TEAM", "@ansible/steering-committee"): ["sc_approval"], } +RELEASE_MANAGEMENT_MEMBERS = { + "anweshadas", + "felixfontein", + "gotmax23", + "mariolenz", + "rooftopcellist", + "webknjaz", +} HERE = Path(__file__).resolve().parent ROOT = HERE.parent.parent CODEOWNERS = (ROOT / ".github/CODEOWNERS").read_text("utf-8") @@ -228,6 +237,25 @@ def no_body_nag(ctx: IssueOrPrCtx) -> None: create_boilerplate_comment(ctx, "no_body_nag.md") +def warn_porting_guide_change(ctx: PRLabelerCtx) -> None: + """ + Complain if a user outside of the Release Management WG changes porting_guide + """ + if ctx.pr.user.login in RELEASE_MANAGEMENT_MEMBERS: + return + matches: list[str] = [] + for file in ctx.pr.get_files(): + if re.fullmatch( + # Match community porting guides but not core porting guides + r"docs/docsite/rst/porting_guides/porting_guide_\d.*.rst", + file.filename, + ): + matches.append(file.filename) + if not matches: + return + create_boilerplate_comment(ctx, "porting_guide_changes.md", changed_files=matches) + + APP = typer.Typer() @@ -274,6 +302,7 @@ def process_pr( handle_codeowner_labels(ctx) new_contributor_welcome(ctx) no_body_nag(ctx) + warn_porting_guide_change(ctx) @APP.command(name="issue")