From d09a49ff02cc6290eaccc402a89a5f06216f9c32 Mon Sep 17 00:00:00 2001 From: Zakk Date: Sun, 11 Oct 2026 05:22:48 +1100 Subject: [PATCH] .github: check commit rules and the PR template in pr-rules Contributors delete the template, so reviewers cannot see whether pkgcheck ran or AI was used. The boxes stay optional because not every contributor can run pkgcheck with --net and the AI box applies only when AI was used. The autobump bot does not fill in the template and is skipped. The commit rules move from pkgcheck into the same workflow, because both checks read the pull request rather than the ebuilds and must rerun when the description is edited, which pkgcheck should not. pkgcheck-comment now also closes a pull request without the template, and its reply lists the commit and template problems in separate sections. Signed-off-by: Zakk --- .github/workflows/pkgcheck-comment.yml | 33 +++++++++++++++++---- .github/workflows/pkgcheck.yml | 21 ------------- .github/workflows/pr-rules.yml | 41 ++++++++++++++++++++++++++ scripts/pr-template.sh | 11 +++++++ 4 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/pr-rules.yml create mode 100755 scripts/pr-template.sh diff --git a/.github/workflows/pkgcheck-comment.yml b/.github/workflows/pkgcheck-comment.yml index 02823130c4..b51655a3d7 100644 --- a/.github/workflows/pkgcheck-comment.yml +++ b/.github/workflows/pkgcheck-comment.yml @@ -44,7 +44,7 @@ jobs: RUN_URL: ${{ github.event.workflow_run.html_url }} run: scripts/pkgcheck-comment.sh pkgcheck-report - - name: close a pull request with malformed commits + - name: close a pull request that breaks the pull request rules env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} HEAD_SHA: ${{ github.event.workflow_run.head_sha }} @@ -53,9 +53,15 @@ jobs: pr=$(jq -r --arg sha "$HEAD_SHA" 'first(.[][] | select(.head.sha == $sha) | .number) // empty' <<< "$pulls") [ -n "$pr" ] || exit 0 bad=$(scripts/commit-rules.sh "$pr") - [ -n "$bad" ] || exit 0 - cat > body.md < body.md + if [ -n "$bad" ]; then + cat >> body.md <> body.md <> body.md < +# prints the checkboxes of .github/pull_request_template.md missing from the pull request description +set -euo pipefail +pr=$(gh api "repos/$GITHUB_REPOSITORY/pulls/${1:?pull request number}") +[ "$(jq -r .user.login <<< "$pr")" != 'gentoo-zh-autobump[bot]' ] || exit 0 +body=$(jq -r '.body // ""' <<< "$pr") +# shellcheck disable=SC2016 # literal backticks of the template +for box in 'I have run `pkgcheck scan --commits --net`' 'If I used AI:'; do + grep -iF -- "$box" <<< "$body" | grep -qE '^- \[[ xX]\] ' || echo "- $box" +done