From 8239beb59be15462967887e6929e6caf363637d5 Mon Sep 17 00:00:00 2001 From: Luke Alvoeiro Date: Wed, 4 Sep 2024 11:26:29 -0700 Subject: [PATCH] ci: enforce PR title follows conventional commit (#6) --- .github/workflows/pull_request_title.yaml | 48 +++++++++++++++++++++++ CHANGELOG.md | 2 + CONTRIBUTING.md | 5 +++ 3 files changed, 55 insertions(+) create mode 100644 .github/workflows/pull_request_title.yaml diff --git a/.github/workflows/pull_request_title.yaml b/.github/workflows/pull_request_title.yaml new file mode 100644 index 0000000..8a32172 --- /dev/null +++ b/.github/workflows/pull_request_title.yaml @@ -0,0 +1,48 @@ +name: 'Lint PR' + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened + +permissions: + pull-requests: write + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + id: lint_pr_title + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + requireScope: false + + - uses: marocchino/sticky-pull-request-comment@v2 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. + if: always() && (steps.lint_pr_title.outputs.error_message != null) + with: + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits specification](https://gist.github.com/Zekfad/f51cb06ac76e2457f11c80ed705c95a3#file-conventional-commits-md) and it looks like your proposed title needs to be adjusted. + + Details: + + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-title-lint-error + delete: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 687e047..1b72b62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Enforcing Conventional Commits in PR titles to maintain consistency and clarity. ## [0.8.4] - 2024-09-02 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b860794..39fa06a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,12 @@ uv run pytest tests -m integration # or `just integration` ``` +## Pull Requests + +When opening a pull request, please ensure that your PR title adheres to the [Conventional Commits specification](https://www.conventionalcommits.org/). +This helps us maintain a consistent and meaningful changelog. [uv]: https://docs.astral.sh/uv/ [ruff]: https://docs.astral.sh/ruff/ [just]: https://github.com/casey/just +