diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 15028b4a..c947d0d5 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -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