From 55bdadccabec8ba126ee36406e0a571cf20c5ec9 Mon Sep 17 00:00:00 2001 From: Amine Saboni Date: Wed, 18 Feb 2026 10:57:04 +0100 Subject: [PATCH] ci: enforce pr title format via a github actions workflow --- .github/workflows/pr-title.yaml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/pr-title.yaml diff --git a/.github/workflows/pr-title.yaml b/.github/workflows/pr-title.yaml new file mode 100644 index 00000000..8a432ca1 --- /dev/null +++ b/.github/workflows/pr-title.yaml @@ -0,0 +1,46 @@ +name: PR Title Convention + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + branches: [main] + +permissions: + pull-requests: read + +jobs: + check-title: + name: Validate PR title + runs-on: ubuntu-22.04 + timeout-minutes: 1 + steps: + - name: Check conventional commit format + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + # Allowed conventional commit types + TYPES="feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert" + + # Pattern: type(optional-scope): description + # OR: type!: description (breaking change) + PATTERN="^($TYPES)(\(.+\))?\!?: .+" + + if echo "$PR_TITLE" | grep -qP "$PATTERN"; then + echo "PR title is valid: $PR_TITLE" + else + echo "::error::PR title does not follow Conventional Commits." + echo "" + echo "Got: $PR_TITLE" + echo "" + echo "Expected: [optional scope]: " + echo "" + echo "Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert" + echo "Read more: https://www.conventionalcommits.org/en/v1.0.0/" + echo "" + echo "Examples:" + echo " feat: add new optimization algorithm" + echo " fix: resolve memory leak in model loading" + echo " ci(pruna): pin transformers version" + echo "" + exit 1 + fi \ No newline at end of file