tools/ci.sh: Fix commit msg checking when PR branch HEAD behind master.
Fixes the problem noted at https://github.com/micropython/micropython/pull/15547#issuecomment-2434479702 which is that, because default CI HEAD for a PR is a (generated) merge commit into the master branch's current HEAD, then if the PR branch isn't fully rebased then the commit check runs against commits from master as well! Also drops running this check on push, the pull_request event is triggered by default on open and update ("synchronized" event), which probably covers the cases where this check should run. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
d34b15ac6f
commit
9591b0a53c
4
.github/workflows/commit_formatting.yml
vendored
4
.github/workflows/commit_formatting.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: Check commit message formatting
|
name: Check commit message formatting
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: '100'
|
fetch-depth: 100
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
- name: Check commit message formatting
|
- name: Check commit message formatting
|
||||||
run: source tools/ci.sh && ci_commit_formatting_run
|
run: source tools/ci.sh && ci_commit_formatting_run
|
||||||
|
|||||||
16
tools/ci.sh
16
tools/ci.sh
@@ -39,12 +39,18 @@ function ci_c_code_formatting_run {
|
|||||||
# commit formatting
|
# commit formatting
|
||||||
|
|
||||||
function ci_commit_formatting_run {
|
function ci_commit_formatting_run {
|
||||||
git remote add upstream https://github.com/micropython/micropython.git
|
# Default GitHub Actions checkout for a PR is a generated merge commit where
|
||||||
git fetch --depth=100 upstream master
|
# the parents are the head of base branch (i.e. master) and the head of the
|
||||||
|
# PR branch, respectively. Use these parents to find the merge-base (i.e.
|
||||||
|
# where the PR branch head was branched)
|
||||||
|
|
||||||
# If the common ancestor commit hasn't been found, fetch more.
|
# If the common ancestor commit hasn't been found, fetch more.
|
||||||
git merge-base upstream/master HEAD || git fetch --unshallow upstream master
|
git merge-base HEAD^1 HEAD^2 || git fetch --unshallow origin
|
||||||
# For a PR, upstream/master..HEAD ends with a merge commit into master, exclude that one.
|
|
||||||
tools/verifygitlog.py -v upstream/master..HEAD --no-merges
|
MERGE_BASE=$(git merge-base HEAD^1 HEAD^2)
|
||||||
|
HEAD=$(git rev-parse HEAD^2)
|
||||||
|
echo "Checking commits between merge base ${MERGE_BASE} and PR head ${HEAD}..."
|
||||||
|
tools/verifygitlog.py -v "${MERGE_BASE}..${HEAD}"
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user