diff --git a/.github/workflows/check-description.yaml b/.github/workflows/check-description.yaml new file mode 100644 index 0000000..76ef242 --- /dev/null +++ b/.github/workflows/check-description.yaml @@ -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 diff --git a/.github/workflows/check-target.yaml b/.github/workflows/check-target.yaml index 8bbbc52..064d72d 100644 --- a/.github/workflows/check-target.yaml +++ b/.github/workflows/check-target.yaml @@ -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 \ No newline at end of file + fi diff --git a/.github/workflows/pr_description_check.py b/.github/workflows/pr_description_check.py new file mode 100644 index 0000000..5e7f69c --- /dev/null +++ b/.github/workflows/pr_description_check.py @@ -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)