Skip to content

In "tests fail on old code" workflow, the old code must be the merge base #34441

In "tests fail on old code" workflow, the old code must be the merge base

In "tests fail on old code" workflow, the old code must be the merge base #34441

Workflow file for this run

name: Pull Request Validation
"on":
pull_request:
types: [opened, synchronize, reopened, edited, auto_merge_enabled, auto_merge_disabled]
branches: [main]
jobs:
# Count the number of commits in a pull request. This can be
# disabled by adding a trailer line of the following form to the
# pull request message:
#
# Disable-Check: commit-count
#
# The check is case-insensitive and ignores other contents on the
# line as well, so it is possible to add several different checks if
# that is necessary.
#
# It is assumed that the trailer is following RFC2822 conventions,
# but this is currently not enforced.
count_commits:
name: Enforce single commit pull request
runs-on: timescaledb-runner-arm64
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Check number of commits
if: github.event.pull_request.auto_merge.merge_method != 'squash'
shell: bash --norc --noprofile {0}
env:
BODY: ${{ github.event.pull_request.body }}
run: |
base=${{ github.event.pull_request.base.sha }}
head=${{ github.event.pull_request.head.sha }}
count=$(git rev-list --no-merges --count $base..$head)
# Hard limit of 5 commits per pull request. This check cannot
# be disabled via the Disable-check trailer or by using squash
# merge.
if [[ "$count" -gt 5 ]]; then
echo "Found $count commits in pull request (there must be no more than 5):"
git log --format=format:'- %h %s' $base..$head
echo
echo "This limit cannot be overridden. Please rebase and reduce"
echo "the number of commits to 5 or fewer."
exit 1
fi
if ! echo "$BODY" | grep -Eqsi '^disable-check:.*\<commit-count\>'
then
if [[ "$count" -ne 1 ]]; then
echo "Found $count commits in pull request (there should be only one):"
git log --format=format:'- %h %s' $base..$head
echo
echo "To disable commit count, add this trailer to pull request message:"
echo
echo "Disable-check: commit-count"
echo
echo "Trailers follow RFC2822 conventions, so no whitespace"
echo "before field name and the check is case-insensitive for"
echo "both the field name and the field body."
exit 1
fi
fi