From 7b0d1fde6475337a9a2e01c5925436931fe4ef03 Mon Sep 17 00:00:00 2001 From: Brian Choromanski Date: Sun, 31 May 2026 11:41:43 -0400 Subject: [PATCH] feat: Enhanced PR Lint/Validation (#7329) Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com> --- .github/workflows/pull-request-lint.yml | 49 ++++++++++++++++++++++++- .github/workflows/pull-requests.yml | 2 + 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-lint.yml b/.github/workflows/pull-request-lint.yml index 98239c422..b670635df 100644 --- a/.github/workflows/pull-request-lint.yml +++ b/.github/workflows/pull-request-lint.yml @@ -3,7 +3,7 @@ name: Pull Request Linter on: workflow_call: pull_request: - types: [edited] # This captures the PR title changing + types: [edited, reopened] # This captures the PR title/body changing branches: - mealie-next @@ -41,3 +41,50 @@ jobs: ignoreLabels: | bot ignore-semantic-pull-request + + validate-template: + name: Validate PR template + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Check required PR template sections + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + + if (pr.user.type === "Bot") { + console.log("Skipping template check for bot"); + return; + } + + const response = await github.rest.repos.getContent({ + owner: context.repo.owner, + repo: context.repo.repo, + path: ".github/pull_request_template.md", + }); + + const template = Buffer.from(response.data.content, "base64").toString("utf8"); + const lines = template.split("\n"); + + const requiredHeadings = []; + let lastHeading = null; + + for (const line of lines) { + if (line.startsWith("## ")) { + lastHeading = line.trim(); + } else if (line.trim() === "_(REQUIRED)_" && lastHeading) { + requiredHeadings.push(lastHeading); + lastHeading = null; + } + } + + const body = pr.body || ""; + const missing = requiredHeadings.filter(h => !body.includes(h)); + + if (missing.length > 0) { + core.setFailed(`Missing headings:\n${missing.join("\n")}`); + } else { + console.log("All required headings present"); + } diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index d3a63b207..ba2c48de4 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -18,6 +18,8 @@ jobs: name: "Lint PR" if: github.event_name == 'pull_request' uses: ./.github/workflows/pull-request-lint.yml + permissions: + pull-requests: write backend-tests: name: "Backend Server Tests"