Skip to content

Commit

Permalink
ci: enforce PR title follows conventional commit (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Alvoeiro authored and lily-de committed Oct 7, 2024
1 parent eb04c4c commit 1466334
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/pull_request_title.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/goose/toolkit/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions tests/toolkit/test_developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


0 comments on commit 1466334

Please sign in to comment.