mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
Backport PRs are titled "[BACKPORT 1.18] fix(mavlink): ...". The PR title check anchors on the conventional commit type, so it fails all of them even though the header after the tag is valid. Replaying the check over the 210 PRs opened against release/1.16, release/1.17 and release/1.18, 62 fail only because of the tag. Skip a leading backport tag before validating the header. The header after the tag still has to be a conventional commit. The tag is accepted only on PRs that target a release/* branch, so a backport opened against main by mistake fails with a comment that says so. The title suggested in the failure comment keeps the tag. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Ramon Roche <mrpollo@gmail.com>
115 lines
3.8 KiB
YAML
115 lines
3.8 KiB
YAML
name: Commit Quality
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, edited, synchronize, reopened]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
issues: write
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
|
|
|
|
jobs:
|
|
pr-title:
|
|
name: PR Title
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
sparse-checkout: Tools/ci
|
|
fetch-depth: 1
|
|
|
|
- name: Check PR title
|
|
id: check
|
|
env:
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
BASE_REF: ${{ github.event.pull_request.base.ref }}
|
|
run: |
|
|
python3 Tools/ci/check_pr_title.py "$PR_TITLE" --base-ref "$BASE_REF" --markdown-file comment.md && rc=0 || rc=$?
|
|
echo "exit_code=$rc" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Post or clear comment
|
|
if: env.IS_FORK == 'false'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
if [ "${{ steps.check.outputs.exit_code }}" != "0" ]; then
|
|
if [ ! -s comment.md ]; then
|
|
echo "The PR title check failed without producing a report." > comment.md
|
|
fi
|
|
python3 Tools/ci/pr_comment.py --marker pr-title --pr "$PR_NUMBER" --result fail < comment.md
|
|
else
|
|
python3 Tools/ci/pr_comment.py --marker pr-title --pr "$PR_NUMBER" --result pass
|
|
fi
|
|
|
|
- name: Result
|
|
if: steps.check.outputs.exit_code != '0'
|
|
run: |
|
|
if [ "$IS_FORK" = "true" ]; then
|
|
# Output the entire content of the comment on the job log as a substitute for the comment.
|
|
tee -a "$GITHUB_STEP_SUMMARY" < comment.md
|
|
else
|
|
echo "::error::PR title check failed. See the PR comment for details."
|
|
fi
|
|
exit 1
|
|
|
|
pr-body:
|
|
name: PR Description
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
if: env.IS_FORK == 'false'
|
|
uses: actions/checkout@v6
|
|
with:
|
|
sparse-checkout: Tools/ci
|
|
fetch-depth: 1
|
|
|
|
- name: Check PR body
|
|
id: check
|
|
env:
|
|
PR_BODY: ${{ github.event.pull_request.body }}
|
|
run: |
|
|
message=""
|
|
if [ -z "$PR_BODY" ]; then
|
|
message="PR description is empty. Please add a summary of the changes."
|
|
echo "::warning::PR description is empty."
|
|
else
|
|
cleaned=$(echo "$PR_BODY" | sed 's/<!--.*-->//g' | tr -d '[:space:]')
|
|
if [ -z "$cleaned" ]; then
|
|
message="PR description contains only template comments. Please fill in the details."
|
|
echo "::warning::PR description contains only template comments."
|
|
fi
|
|
fi
|
|
echo "message=$message" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Post or clear comment
|
|
if: env.IS_FORK == 'false'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
if [ -n "${{ steps.check.outputs.message }}" ]; then
|
|
printf '%s\n' \
|
|
"## PR Description (advisory)" \
|
|
"" \
|
|
"This is **not blocking**, but your PR description appears to be empty or incomplete." \
|
|
"" \
|
|
"${{ steps.check.outputs.message }}" \
|
|
"" \
|
|
"A good PR description helps reviewers understand what changed and why." \
|
|
"" \
|
|
"---" \
|
|
"*This comment will be automatically removed once the issue is resolved.*" \
|
|
| python3 Tools/ci/pr_comment.py --marker pr-body --pr "$PR_NUMBER" --result warn
|
|
else
|
|
python3 Tools/ci/pr_comment.py --marker pr-body --pr "$PR_NUMBER" --result pass
|
|
fi
|