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 17, 2023
1 parent 76506fb commit 2f9dff3
Show file tree
Hide file tree
Showing 2 changed files with 37 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 --->
29 changes: 29 additions & 0 deletions hacking/pr_labeler/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dataclasses
import json
import os
import re
from collections.abc import Collection
from contextlib import suppress
from functools import cached_property
Expand All @@ -26,6 +27,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 +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()


Expand Down Expand Up @@ -275,6 +303,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 2f9dff3

Please sign in to comment.