Skip to content

Commit

Permalink
pr_labeler: add warning for porting_guides changes
Browse files Browse the repository at this point in the history
This adds a warning message when PRs are created that edit
porting_guides by someone outside of the Release Management WG. These
files are automatically generated during the ansible release process and
should not be modified.

Fixes: ansible#503
  • Loading branch information
gotmax23 committed Oct 4, 2023
1 parent 0ad13d7 commit 9f1ea6d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hacking/pr_labeler/data/porting_guide_changes.md
Original file line number Diff line number Diff line change
@@ -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.
<!--- boilerplate: porting_guide_changes --->
24 changes: 24 additions & 0 deletions hacking/pr_labeler/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
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")
Expand Down Expand Up @@ -228,6 +236,21 @@ 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 file.filename.startswith("docs/docsite/rst/porting_guides/"):
matches.append(file.filename)
if not matches:
return
create_boilerplate_comment(ctx, "porting_guide_changes.md", changed_files=matches)


APP = typer.Typer()


Expand Down Expand Up @@ -275,6 +298,7 @@ def process_pr(
add_label_if_new(ctx, "needs_triage")
new_contributor_welcome(ctx)
no_body_nag(ctx)
warn_porting_guide_change(ctx)


@APP.command(name="issue")
Expand Down

0 comments on commit 9f1ea6d

Please sign in to comment.