Skip to content

Commit

Permalink
ci: check pr title
Browse files Browse the repository at this point in the history
signed commit cannot be rebased onto main
so rebasing when merging PR has been disabled
in favor of the squash commit.
Thus we want the PR title to match the expected
format:
"[area]: [desc]"
and max 72 characters"

Signed-off-by: Cyril Fougeray <[email protected]>
  • Loading branch information
fouge committed Mar 20, 2024
1 parent dbbc2cb commit 8bb2841
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions .github/workflows/compliance.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
name: Format & Compliance
on: [pull_request]
name: Pull-Request Compliance
on:
pull_request:
types: [opened, edited, reopened]

jobs:
check-compliance:
name: Check formatting & commit message compliance
check-pr-title:
name: Check PR title
runs-on: ubuntu-22.04
container:
image: ghcr.io/worldcoin/${{ vars.DOCKER_IMAGE_NAME }}:${{ vars.DOCKER_IMAGE_TAG }}
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
env:
TITLE: ${{ github.event.pull_request.title }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3
with:
path: "${{ github.job }}/orb"
- name: Check formatting
- name: Check title format
run: |
cd "${{ github.job }}/orb"
git config --global --add safe.directory /__w/open-orb-mcu-firmware/open-orb-mcu-firmware
pre-commit run --all-files --config utils/format/pre-commit-config.yaml
- name: Check commit message
run: |
cd "${{ github.job }}/orb"
# Un-shallow
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# Deepen topic branch; checkout topic branch
git fetch origin ${{ github.event.pull_request.head.ref }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 ))
git checkout ${{ github.event.pull_request.head.ref }}
# Fetch main for common origin
git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} --depth=50
gitlint --config utils/format/.gitlint --commits ${{ github.event.pull_request.base.ref }}..
- name: Guide to contributing
if: failure()
run: |
echo "Take a look at CONTRIBUTING.md"
# has a colon which separates the area from the description
# max 72 characters
exit_code=0
if [[ ! ${TITLE} =~ ^[^:]+:.+$ ]]; then
echo "PR title must specify an area and a description, see README.md"
exit_code=1
fi
if [[ ${#TITLE} -gt 72 ]]; then
echo "PR title is too long, see README.md"
exit_code=1
fi
exit $exit_code

0 comments on commit 8bb2841

Please sign in to comment.