Feature/182 local client #63
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Commit Messages | |
| on: | |
| pull_request: | |
| jobs: | |
| validate-commits: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check commit message format | |
| run: | | |
| BASE_SHA=${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA=${{ github.event.pull_request.head.sha }} | |
| ALLOWED_TYPES="feat|fix|refs|doc|perf|refactor|style|test|chore|ci|revert" | |
| SCOPE_PATTERN="([a-z][a-z0-9-]*)" | |
| TICKET_PATTERN="#[0-9]+:" | |
| FULL_PATTERN="^($ALLOWED_TYPES)(\($SCOPE_PATTERN\))? $TICKET_PATTERN.+$" | |
| # Validate the format of all new submissions | |
| for commit in $(git rev-list $BASE_SHA..$HEAD_SHA); do | |
| msg=$(git show -s --format=%s $commit) | |
| # skip merge | |
| if [[ "$msg" =~ ^Merge ]]; then | |
| continue | |
| fi | |
| # Basic format check regular expression | |
| if ! echo "$msg" | grep -qE "$FULL_PATTERN"; then | |
| echo "::error::Invalid commit format: $msg" | |
| echo "Commit must follow: <type>(<scope>) #<ticket>: <description>" | |
| echo "Allowed types: $ALLOWED_TYPES" | |
| echo "Scope: lowercase with hyphen (optional)" | |
| exit 1 | |
| fi | |
| # Verify that non-chore/ci commits contain tickets | |
| if ! echo "$msg" | grep -qE "$TICKET_PATTERN"; then | |
| echo "::error::Ticket number missing: $msg" | |
| echo "All non-merge commits must reference a ticket" | |
| exit 1 | |
| fi | |
| done |