Skip to content

Commit

Permalink
Skips changelog validation if NPFC present in PR body
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-34 committed Oct 13, 2024
1 parent d7d9e5a commit d8afd62
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tools/changelog/check_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
DO NOT MANUALLY RUN THIS SCRIPT.
---------------------------------
Expected envrionmental variables:
Expected environmental variables:
-----------------------------------
GITHUB_REPOSITORY: Github action variable representing the active repo (Action provided)
BOT_TOKEN: A repository account token, this will allow the action to push the changes (Action provided)
Expand Down Expand Up @@ -37,6 +37,13 @@


def build_changelog(pr: dict) -> dict:
# Check for the presence of :cl: or 🆑 tags in the PR body
if not (":cl:" in pr.body or "🆑" in pr.body):
# Check if "NPFC" is in the PR body
if "NPFC" in pr.body:
pr.add_to_labels(CL_NOT_NEEDED)
raise Exception("Changelog tags (:cl: or 🆑) are missing, but 'NPFC' is present. Skipping changelog validation.")

changelog = parse_changelog(pr.body)
changelog["author"] = changelog["author"] or pr.user.login
return changelog
Expand Down Expand Up @@ -146,7 +153,7 @@ def parse_changelog(message: str) -> dict:
cl_required = False

if not cl_required:
# remove invalid, remove valid
# Remove invalid, remove valid
if has_invalid_label:
pr.remove_from_labels(CL_INVALID)
if has_valid_label:
Expand All @@ -162,14 +169,14 @@ def parse_changelog(message: str) -> dict:
print("Changelog parsing error:")
print(e)

# add invalid, remove valid
# Add invalid, remove valid
if not has_invalid_label:
pr.add_to_labels(CL_INVALID)
if has_valid_label:
pr.remove_from_labels(CL_VALID)
exit(1)

# remove invalid, add valid
# Remove invalid, add valid
if has_invalid_label:
pr.remove_from_labels(CL_INVALID)
if not has_valid_label:
Expand Down

0 comments on commit d8afd62

Please sign in to comment.