Skip to content

ci: add PR size and title checks, configure commitizen#4638

Open
greysonlalonde wants to merge 1 commit intomainfrom
gl/ci/pr-checks-and-commitizen
Open

ci: add PR size and title checks, configure commitizen#4638
greysonlalonde wants to merge 1 commit intomainfrom
gl/ci/pr-checks-and-commitizen

Conversation

@greysonlalonde
Copy link
Contributor

Summary

  • Add pr-size.yml workflow that auto-labels PRs by size and blocks merging PRs over 500 lines
  • Add pr-title.yml workflow that enforces conventional commit format on PR titles
  • Configure commitizen in pyproject.toml with strict schema pattern for conventional commits

Details

These enforce the conventions defined in RELEASE_PROCESS.md:

  • PR size: XS/S/M/L/XL labels applied automatically. XL fails CI. Excludes lock files, CLI templates, JSON, test duration caches, and VCR cassettes from the count.
  • PR title: Must match <type>(<scope>): <description> with allowed types: feat, fix, refactor, perf, test, docs, chore, ci, style, revert. Lowercase description, no trailing period.
  • Commitizen: Configured with the same type and pattern rules for local pre-commit enforcement.

Both pr-size and pr-title should be added as required status checks on main once they run for the first time.

Test plan

  • Open a PR with a non-conventional title and verify pr-title check fails
  • Open a PR over 500 lines and verify pr-size check fails and labels as size/XL
  • Verify commitizen rejects non-conforming local commits

Add two new GitHub Actions workflows:
- pr-size.yml: auto-labels PRs by size and fails CI on PRs over 500 lines
- pr-title.yml: enforces conventional commit format on PR titles

Configure commitizen in pyproject.toml with strict schema pattern matching
for conventional commits.
Comment on lines +9 to +38
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
refactor
perf
test
docs
chore
ci
style
revert
requireScope: false
subjectPattern: ^[a-z].+[^.]$
subjectPatternError: >
The PR title "{title}" does not follow conventional commit format.

Expected: <type>(<scope>): <lowercase description without trailing period>

Examples:
feat(memory): add lancedb storage backend
fix(agents): resolve deadlock in concurrent execution
chore(deps): bump pydantic to 2.11.9

See RELEASE_PROCESS.md for the full commit message convention.

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI about 22 hours ago

To fix the problem, explicitly declare a minimal permissions block in the workflow so that the GITHUB_TOKEN has only the rights needed. This job reads pull request information to validate the title and does not need to write to the repo, so contents: read and pull-requests: read are sufficient and follow the principle of least privilege.

The best fix without changing existing functionality is to add a permissions section at the workflow root (top level), so it applies to all jobs, right below the name: or on: block. Concretely, edit .github/workflows/pr-title.yml to insert:

permissions:
  contents: read
  pull-requests: read

between the on: block (ending at line 5) and the jobs: block (line 7), or directly after name: if you prefer. No imports or other definitions are needed; GitHub Actions interprets this permissions key natively.

Suggested changeset 1
.github/workflows/pr-title.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml
--- a/.github/workflows/pr-title.yml
+++ b/.github/workflows/pr-title.yml
@@ -4,6 +4,10 @@
   pull_request:
     types: [opened, edited, synchronize, reopened]
 
+permissions:
+  contents: read
+  pull-requests: read
+
 jobs:
   pr-title:
     runs-on: ubuntu-latest
EOF
@@ -4,6 +4,10 @@
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
contents: read
pull-requests: read

jobs:
pr-title:
runs-on: ubuntu-latest
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant