Skip to content

Commit 1466334

Browse files
Luke Alvoeirolily-de
Luke Alvoeiro
authored andcommitted
ci: enforce PR title follows conventional commit (#14)
1 parent eb04c4c commit 1466334

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Lint PR'
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
- reopened
10+
11+
permissions:
12+
pull-requests: write
13+
14+
jobs:
15+
main:
16+
name: Validate PR title
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: amannn/action-semantic-pull-request@v5
20+
id: lint_pr_title
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
with:
24+
requireScope: false
25+
26+
- uses: marocchino/sticky-pull-request-comment@v2
27+
# When the previous steps fails, the workflow would stop. By adding this
28+
# condition you can continue the execution with the populated error message.
29+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
30+
with:
31+
header: pr-title-lint-error
32+
message: |
33+
Hey there and thank you for opening this pull request! 👋🏼
34+
35+
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.
36+
37+
Details:
38+
39+
```
40+
${{ steps.lint_pr_title.outputs.error_message }}
41+
```
42+
43+
# Delete a previous comment when the issue has been resolved
44+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
45+
uses: marocchino/sticky-pull-request-comment@v2
46+
with:
47+
header: pr-title-lint-error
48+
delete: true

CONTRIBUTING.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ And now you can run goose with this new profile to use the new toolkit!
124124
goose session start --profile demo
125125
```
126126

127-
[developer]: src/goose/toolkit/developer.py
127+
## Conventional Commits
128+
129+
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.
130+
131+
[developer]: src/goose/toolkit/developer.py
128132
[uv]: https://docs.astral.sh/uv/
129133
[ruff]: https://docs.astral.sh/ruff/
130134
[just]: https://github.com/casey/just

src/goose/toolkit/developer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Developer(Toolkit):
3434

3535
def system(self) -> str:
3636
"""Retrieve system configuration details for developer"""
37-
hints_path = Path('.goosehints')
37+
hints_path = Path(".goosehints")
3838
system_prompt = Message.load("prompts/developer.jinja").text
3939
if hints_path.is_file():
4040
goosehints = hints_path.read_text()

tests/toolkit/test_developer.py

-2
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,3 @@ def test_write_file(temp_dir, developer_toolkit):
6868
content = "Hello World"
6969
developer_toolkit.write_file(test_file.as_posix(), content)
7070
assert test_file.read_text() == content
71-
72-

0 commit comments

Comments
 (0)