ci: remove commit count limit from test-each-commit

Extend `test-each-commit` to run on every non-head pull request commit.
The PR tip is excluded because it is already covered by other CI jobs.
Runner was changed to a performant cirrus runner.

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
This commit is contained in:
LőrincandMarcoFalke committed 2026-02-04 20:11:02 +01:00
1 parent 4ae00e9a71
commit 04c4d71008
1 file changed
+30 -21
+30 -21
View File
@@ -56,12 +56,11 @@ jobs:
fi fi
test-each-commit: test-each-commit:
name: 'test max 6 ancestor commits' name: 'test ancestor commits'
runs-on: ubuntu-24.04 needs: runners
runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md' || 'ubuntu-24.04' }}
if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1 if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1
timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below. timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes.
env:
MAX_COUNT: 6 # Keep in sync with name above
steps: steps:
- name: Determine fetch depth - name: Determine fetch depth
run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV" run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV"
@@ -72,25 +71,35 @@ jobs:
fetch-depth: ${{ env.FETCH_DEPTH }} fetch-depth: ${{ env.FETCH_DEPTH }}
- name: Determine commit range - name: Determine commit range
run: | run: |
# Checkout HEAD~ and find the test base commit # Checkout HEAD~ and find the test base commit.
# Checkout HEAD~ because it would be wasteful to rerun tests on the PR # Checkout HEAD~ because it would be wasteful to rerun
# head commit that are already run by other jobs. # tests on the PR head commit that are already run
# by other jobs.
git checkout HEAD~ git checkout HEAD~
# Figure out test base commit by listing ancestors of HEAD, excluding # Moreover, pull requests that contain a merge commit
# ancestors of the most recent merge commit, limiting the list to the # are generally draft pull requests that merge in other
# newest MAX_COUNT ancestors, ordering it from oldest to newest, and # pull requests, so only check the relevant commits
# after the last merge commit. A merge commit could
# also be a subtree merge commit, which may be
# worthwhile to check. However, it is rare that the
# subtree merge commit is not the top commit (which
# would be skipped anyway by this task, because it is
# run by all other tasks). Also, `git rebase --exec`
# does not work on merge commits, so if this was
# important to check, the logic would have to be
# rewritten.
#
# Figure out test base commit by listing ancestors of
# HEAD, excluding ancestors of the most recent merge
# commit, ordering them from oldest to newest, and
# taking the first one. # taking the first one.
# #
# If the branch contains up to MAX_COUNT ancestor commits after the # In the command below, the ^@ suffix is used to refer
# most recent merge commit, all of those commits will be tested. If it # to all parents of the merge commit as described in:
# contains more, only the most recent MAX_COUNT commits will be
# tested.
#
# In the command below, the ^@ suffix is used to refer to all parents
# of the merge commit as described in:
# https://git-scm.com/docs/git-rev-parse#_other_rev_parent_shorthand_notations # https://git-scm.com/docs/git-rev-parse#_other_rev_parent_shorthand_notations
# and the ^ prefix is used to exclude these parents and all their # and the ^ prefix is used to exclude these parents
# ancestors from the rev-list output as described in: # and all their ancestors from the rev-list output
# as described in:
# https://git-scm.com/docs/git-rev-list # https://git-scm.com/docs/git-rev-list
MERGE_BASE=$(git rev-list -n1 --merges HEAD) MERGE_BASE=$(git rev-list -n1 --merges HEAD)
EXCLUDE_MERGE_BASE_ANCESTORS= EXCLUDE_MERGE_BASE_ANCESTORS=
@@ -98,7 +107,7 @@ jobs:
if test -n "$MERGE_BASE"; then if test -n "$MERGE_BASE"; then
EXCLUDE_MERGE_BASE_ANCESTORS=^${MERGE_BASE}^@ EXCLUDE_MERGE_BASE_ANCESTORS=^${MERGE_BASE}^@
fi fi
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV" echo "TEST_BASE=$(git rev-list -n${{ github.event.pull_request.commits }} --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
- run: | - run: |
git fetch origin "${GITHUB_BASE_REF}" git fetch origin "${GITHUB_BASE_REF}"
git config user.email "ci@example.com" git config user.email "ci@example.com"