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
18 changes: 18 additions & 0 deletions .github/workflows/check-description.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# .github/workflows/check-target.yaml
name: Description mentions every changed file
on:
pull_request:
types: [opened, edited, synchronize, reopened, labeled, unlabeled]
jobs:
check-description:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Pull request description mentions every changed file
env:
PR_BODY: ${{ github.event.pull_request.body }}
GH_TOKEN: ${{ github.token }}
run: |
gh pr diff ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} --name-only > tmp_changed_files.txt
python3 .github/workflows/pr_description_check.py
2 changes: 1 addition & 1 deletion .github/workflows/check-target.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
echo "Targeting main requires the 'release' label"
echo "::error::Please change your target branch to the current working update branch (e.g. maizebus2.1). See https://docs.github.com/en/pull-requests/how-tos/create-pull-requests/changing-the-base-branch-of-a-pull-request"
exit 1
fi
fi
35 changes: 35 additions & 0 deletions .github/workflows/pr_description_check.py
Comment thread
iswheeler marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os

BLACK = "\033[0;30m";
RED = "\033[0;31m";
GREEN = "\033[0;32m";
YELLOW = "\033[0;33m";
BLUE = "\033[0;34m";
MAGENTA = "\033[0;35m";
CYAN = "\033[0;36m";
WHITE = "\033[0;37m";
RESET = "\033[0m";

pr_body = os.environ["PR_BODY"]

all_accounted_for = True

with open("tmp_changed_files.txt") as f:
lines = f.read().split("\n")
for line in lines:
if line.strip() == "":
continue # Skip empty lines
parts = line.split("/")
filename = parts[len(parts) - 1]
if filename in pr_body:
print(GREEN+"✓ Changed file "+filename+" in PR description"+RESET)
else:
all_accounted_for = False
print(RED+"✗ Changed file "+filename+" not found in PR description"+RESET)


if all_accounted_for:
exit(0)
else:
print("::error::Please edit your pull request description to make sure it lists all changed files. See above for details")
exit(1)
Loading