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 <zakk@gentoozh.org>
113 lines
3.9 KiB
YAML
113 lines
3.9 KiB
YAML
name: pkgcheck-comment
|
|
on:
|
|
workflow_run:
|
|
workflows: [pkgcheck]
|
|
types: [completed]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
actions: read
|
|
|
|
jobs:
|
|
comment:
|
|
if: github.event.workflow_run.event == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: check for the report
|
|
id: report
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RUN_ID: ${{ github.event.workflow_run.id }}
|
|
run: |
|
|
artifacts=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts" --paginate --slurp)
|
|
available=$(jq 'any(.[] | .artifacts[]; .name == "pkgcheck-report")' <<< "$artifacts")
|
|
echo "available=$available" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: download the report
|
|
if: steps.report.outputs.available == 'true'
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: pkgcheck-report
|
|
path: pkgcheck-report
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: post the report
|
|
if: steps.report.outputs.available == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
RUN_URL: ${{ github.event.workflow_run.html_url }}
|
|
run: scripts/pkgcheck-comment.sh pkgcheck-report
|
|
|
|
- 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 }}
|
|
run: |
|
|
pulls=$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&per_page=100" --paginate --slurp)
|
|
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")
|
|
missing=$(scripts/pr-template.sh "$pr")
|
|
[ -n "$bad$missing" ] || exit 0
|
|
echo "This pull request was closed automatically because it breaks the rules below." > body.md
|
|
if [ -n "$bad" ]; then
|
|
cat >> body.md <<EOF
|
|
|
|
## Commits
|
|
|
|
These commits break the commit rules:
|
|
|
|
$bad
|
|
|
|
### Commit rules
|
|
|
|
1. **Subject**: start with the package or file the commit changes, a colon and a short summary.
|
|
\`\`\`
|
|
app-misc/foo: add 1.2.3, drop 1.2.2
|
|
app-misc/foo: fix the build with GCC 16
|
|
profiles: mask app-misc/foo
|
|
foo.eclass: support EAPI 9
|
|
\`\`\`
|
|
2. **Sign-off**: every commit ends with a \`Signed-off-by\` line.
|
|
\`\`\`
|
|
Signed-off-by: Your Name <you@example.com>
|
|
\`\`\`
|
|
\`git commit -s\` and \`pkgdev commit --signoff\` add it for you.
|
|
3. **No merge commits**: update the branch with \`git rebase\`, not \`git merge\` or the Update branch button.
|
|
|
|
### How to fix
|
|
|
|
\`\`\`
|
|
git fetch https://github.com/gentoo-zh/overlay.git master
|
|
git rebase -i FETCH_HEAD # mark a commit "reword" to fix its subject
|
|
git rebase --signoff FETCH_HEAD # add Signed-off-by to every commit
|
|
git push --force-with-lease
|
|
\`\`\`
|
|
|
|
A closed pull request cannot be reopened after a force push.
|
|
EOF
|
|
fi
|
|
if [ -n "$missing" ]; then
|
|
cat >> body.md <<EOF
|
|
|
|
## Pull request template
|
|
|
|
The description lost these checkboxes of the [pull request template](https://github.com/gentoo-zh/overlay/blob/master/.github/pull_request_template.md):
|
|
|
|
$missing
|
|
|
|
Write the description above the template and keep the checkboxes. Leave a box unticked when it does not apply.
|
|
EOF
|
|
fi
|
|
cat >> body.md <<EOF
|
|
|
|
Fix the problems above and open a new pull request. See [CONTRIBUTING.en.md](https://github.com/gentoo-zh/overlay/blob/master/CONTRIBUTING.en.md).
|
|
EOF
|
|
gh pr close "$pr" -R "$GITHUB_REPOSITORY" --comment "$(cat body.md)"
|