diff --git a/.github/workflows/pull_request_title.yaml b/.github/workflows/pull_request_title.yaml new file mode 100644 index 00000000..8a32172a --- /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/CONTRIBUTING.md b/CONTRIBUTING.md index a81c6425..daf70867 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -124,7 +124,11 @@ And now you can run goose with this new profile to use the new toolkit! goose session start --profile demo ``` -[developer]: src/goose/toolkit/developer.py +## Conventional Commits + +This project follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for PR titles. Conventional Commits make it easier to understand the history of a project and facilitate automation around versioning and changelog generation. + +[developer]: src/goose/toolkit/developer.py [uv]: https://docs.astral.sh/uv/ [ruff]: https://docs.astral.sh/ruff/ [just]: https://github.com/casey/just diff --git a/src/goose/toolkit/developer.py b/src/goose/toolkit/developer.py index 7a735749..aa27b3a7 100644 --- a/src/goose/toolkit/developer.py +++ b/src/goose/toolkit/developer.py @@ -34,7 +34,7 @@ class Developer(Toolkit): def system(self) -> str: """Retrieve system configuration details for developer""" - hints_path = Path('.goosehints') + hints_path = Path(".goosehints") system_prompt = Message.load("prompts/developer.jinja").text if hints_path.is_file(): goosehints = hints_path.read_text() diff --git a/tests/toolkit/test_developer.py b/tests/toolkit/test_developer.py index e049ee9f..53c1c844 100644 --- a/tests/toolkit/test_developer.py +++ b/tests/toolkit/test_developer.py @@ -68,5 +68,3 @@ def test_write_file(temp_dir, developer_toolkit): content = "Hello World" developer_toolkit.write_file(test_file.as_posix(), content) assert test_file.read_text() == content - -