diff --git a/.github/workflows/lint-pr.yaml b/.github/workflows/lint-pr.yaml new file mode 100644 index 00000000..97f0b5be --- /dev/null +++ b/.github/workflows/lint-pr.yaml @@ -0,0 +1,40 @@ +name: Lint PR + +on: + pull_request: + types: + - opened + - edited + - synchronize + - reopened + - labeled + - unlabeled + +jobs: + validate-pr-title: + name: Validate PR title (Conventional Commits) + runs-on: ubuntu-latest + permissions: + statuses: write + pull-requests: read + steps: + - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + docs + style + refactor + test + chore + ci + build + perf + revert + requireScope: false + # Allow skipping this check with a label (e.g. for automated/bot PRs) + ignoreLabels: | + skip-conventional-commit-check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0122f905..dd1caea4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,28 +47,29 @@ To set up your development environment for Agentex, please refer to the [README. --- -## Best Practices for Writing Commit Messages - -- **Separate subject from body with a blank line**. -- **Limit the subject line to 50 characters**. -- **Capitalize the subject line**. -- **Do not end the subject line with a period**. -- **Use the imperative mood in the subject line** - (e.g., “Fix bug” not “Fixed bug” or “Fixes bug”). -- **Wrap the body at 72 characters**. -- **Use the body to explain what and why vs. how** (if needed). -- **Reference relevant issues/PRs** (e.g., `Fixes #123`). +## Commit and PR Title Guidelines -**Example:** -``` -Add user authentication middleware +This project enforces [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) on PR titles. A CI check will validate your PR title before it can be merged. -This middleware intercepts requests to check authentication tokens -and ensures only valid users can access protected routes. +**Format:** `type: description` or `type(scope): description` -Fixes #42 +**Allowed types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `ci`, `build`, `perf`, `revert` + +**Examples:** +``` +feat: add user authentication middleware +fix(api): handle empty request body gracefully +docs: update contributing guidelines +chore: bump dependency versions ``` +### General commit message best practices + +- **Use the imperative mood** (e.g., “Add feature” not “Added feature”). +- **Keep the subject line under 72 characters**. +- **Use the body to explain what and why vs. how** (if needed). +- **Reference relevant issues/PRs** (e.g., `Fixes #123`). + For more, see: [Chris Beams' guide to writing great commit messages](https://cbea.ms/git-commit/). ---