Skip to content

Commit

Permalink
ci: added check for fixup commits
Browse files Browse the repository at this point in the history
  • Loading branch information
frazarshad committed Aug 7, 2024
1 parent e7c21af commit eb66d10
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/mergify-ready.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,32 @@ jobs:
echo -e "$fixup_commits"
exit 1
fi
no-fixup-commits:
runs-on: ubuntu-latest
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.base.ref == 'master' &&
contains(github.event.pull_request.labels.*.name, 'automerge:rebase') &&
!contains(github.event.pull_request.labels.*.name, 'bypass:linear-history')
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check for fixup commits
id: fixup-commits
run: |
if [[ $(git rev-list "$BASE_SHA".."$HEAD_SHA" --grep="^fixup! " | wc -l) -eq 0 ]]; then
echo "No fixup commits found in commit history"
else
echo "Fixup commits found in commit history"
exit 1
fi
12 changes: 12 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ queue_rules:
- label=proto:expect-breakage
merge_conditions:
- base=master
# Rebase PRs with fixup commits are allowed to enter the merge queue but
# should not be allowed to merge if there are leftover fixup commits after rebase
- or:
- label=bypass:linear-history
- check-success=no-fixup-commits
- check-skipped=no-fixup-commits
# Require integration tests before merging only
- or:
- label=bypass:integration
Expand All @@ -45,6 +51,12 @@ queue_rules:
- label=proto:expect-breakage
merge_conditions:
- base=master
# Rebase PRs with fixup commits are allowed to enter the merge queue but
# should not be allowed to merge if there are leftover fixup commits after rebase
- or:
- label=bypass:linear-history
- check-success=no-fixup-commits
- check-skipped=no-fixup-commits
# Require integration tests before merging only
- or:
- label=bypass:integration
Expand Down

0 comments on commit eb66d10

Please sign in to comment.