Skip to content

Commit e1dc1be

Browse files
authored
feat(pr-rules): update pr rules (#68)
update pr rules
1 parent 4c549f4 commit e1dc1be

File tree

4 files changed

+53
-169
lines changed

4 files changed

+53
-169
lines changed

.github/pull_request_template.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
# Describe this PR
22

3-
# Checklist for PR
4-
## Must Do
5-
- [ ] Write a good PR title and description, i.e. `feat(agent): add pdf tool via mcp`, `perf: make llm client async` and `fix(utils): load custom config via importlib` etc. CI job `check-pr-title` enforces [Angular commit message format](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#commit-message-format) to PR title.
6-
- [ ] Run `make precommit` locally. CI job `lint` enforce ruff default format/lint rules on all new codes.
7-
- [ ] Run `make pytest`. Check test summary (located at `report.html`) and coverage report (located at `htmlcov/index.html`) on new codes.
3+
<!-- Please provide a clear and concise description of what this PR does -->
4+
5+
## What changed?
6+
<!-- Describe the changes made in this PR -->
7+
8+
## Why?
9+
<!-- Explain the motivation behind these changes -->
810

9-
## Nice To Have
11+
## Related issues
12+
<!-- Link any related issues using #issue_number -->
1013

11-
- [ ] (Optional) Write/update tests under `/tests` for `feat` and `test` PR.
12-
- [ ] (Optional) Write/update docs under `/docs` for `docs` and `ci` PR.
1314

15+
# Checklist for PR
16+
17+
- [ ] Write a descriptive PR title following the [Angular commit message format](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#commit-message-format): `<type>(<scope>): <subject>`
18+
- **Examples:** `feat(agent): add pdf tool via mcp`, `perf: make llm client async`, `fix(utils): load custom config via importlib`
19+
- **Valid types:** `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `revert`
20+
- The `check-pr-title` CI job will validate your title format
21+
- **Bad title examples and why they fail:**
22+
- `Update README` ❌ Missing type and colon
23+
- `feat add new feature` ❌ Missing colon after type
24+
- `Feature: add new tool` ❌ Invalid type (should be `feat`)
25+
- `feat(Agent): add tool` ❌ Scope should be lowercase
26+
- `feat(): add tool` ❌ Empty scope not allowed
27+
- `feat(my_scope): add tool` ❌ Underscores not allowed in scope
28+
- `feat(my space): add tool` ❌ Space not allowed in scope
29+
- `feat(scope):add tool` ❌ Missing space after colon
30+
- `feat(scope): ` ❌ Empty subject
1431

32+
- [ ] Run lint and format locally:
33+
- `uv tool run [email protected] check --fix .`
34+
- `uv tool run [email protected] format .`
35+
- CI job `lint` enforces ruff default format/lint rules on all new codes.

.github/scripts/check_pr_title.py

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,25 @@
99
import string
1010
import sys
1111

12-
# we follow angular convention:
13-
# https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#type
1412
VALID_TYPES = {
15-
"revert", # Revert a previous commit
16-
"build", # Changes that affect build system or dependencies
17-
"ci", # Changes to CI configuration files and scripts
18-
"docs", # Documentation only changes
19-
"feat", # A new feature
20-
"fix", # A bug fix
21-
"perf", # Performance improvements
22-
"refactor", # Code changes that neither fix bugs nor add features
23-
"style", # Code style changes (formatting, etc)
24-
"test", # Adding or fixing tests
13+
"revert",
14+
"build",
15+
"ci",
16+
"docs",
17+
"feat",
18+
"fix",
19+
"perf",
20+
"refactor",
21+
"style",
22+
"test",
2523
}
2624

27-
# this helps user debug messages
28-
# see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-job-summary
29-
MARKDOWN_SUMMARY = string.Template(
30-
"""
31-
### Result
25+
MARKDOWN_TEMPLATE = string.Template(
26+
"""### Result
3227
3328
| PR title | expected format | status | message |
3429
|---|---|---|---|
3530
| `${title}` | `<type>(<scope>): <subject>` | `${status}` | `${message}` |
36-
37-
38-
### Useful Links
39-
- how to write a good PR. link coming!
40-
- [why we do `check-pr-title`](https://github.com/MiroMindAsia/OpenDeepResearch-GAIA/blob/main/docs/contribute.md#why-use-check-pr-title-error)
41-
- [how to fix `check-pr-title` error](https://github.com/MiroMindAsia/OpenDeepResearch-GAIA/blob/main/docs/contribute.md#how-to-fix-check-pr-title-error)
4231
"""
4332
)
4433

@@ -51,18 +40,13 @@ class CheckResult:
5140

5241
def to_markdown(self) -> str:
5342
emoji = "PASSED ✅" if self.status else "FAILED ❌"
54-
return MARKDOWN_SUMMARY.substitute(
55-
title=self.title,
56-
status=emoji,
57-
message=self.message,
43+
return MARKDOWN_TEMPLATE.substitute(
44+
title=self.title, status=emoji, message=self.message
5845
).strip()
5946

6047

6148
def check_pr_title(title: str) -> CheckResult:
62-
"""
63-
Validate if PR title follows the format: <type>(<scope>): <subject>
64-
"""
65-
# Split patterns for detailed error checking
49+
"""Validate PR title follows format: <type>(<scope>): <subject>"""
6650
type_pattern = rf"^({'|'.join(sorted(VALID_TYPES))})"
6751
scope_pattern = r"\([a-z0-9-]+\)"
6852
subject_pattern = r": .+"
@@ -73,7 +57,7 @@ def check_pr_title(title: str) -> CheckResult:
7357
return CheckResult(
7458
title=title,
7559
status=False,
76-
message="<type> must be one of: " + ", ".join(sorted(VALID_TYPES)),
60+
message=f"<type> must be one of: {', '.join(sorted(VALID_TYPES))}",
7761
)
7862

7963
remaining = title[type_match.end() :]
@@ -97,37 +81,28 @@ def check_pr_title(title: str) -> CheckResult:
9781
message="<subject> must start with ': ' and contain a description",
9882
)
9983

100-
return CheckResult(
101-
title=title,
102-
status=True,
103-
message="Valid PR title format",
104-
)
84+
return CheckResult(title=title, status=True, message="Valid PR title format")
10585

10686

10787
def main() -> None:
10888
parser = argparse.ArgumentParser(
10989
description="Validate PR title following Angular commit convention"
11090
)
11191
parser.add_argument(
112-
"title",
113-
type=str,
114-
help="PR title to validate (format: <type>(<scope>): <subject>)",
92+
"title", help="PR title to validate (format: <type>(<scope>): <subject>)"
11593
)
11694

11795
args = parser.parse_args()
11896
result = check_pr_title(args.title)
11997

120-
step_summary_path = os.environ.get("GITHUB_STEP_SUMMARY", None)
121-
# print(f"GITHUB_STEP_SUMMARY: {step_summary_path}")
122-
# print("github step summary is:", result.to_markdown())
123-
if step_summary_path is not None:
124-
with open(step_summary_path, "a") as f:
125-
f.write(result.to_markdown())
98+
print(result)
12699

127-
if not result.status:
128-
sys.exit(1)
100+
# Write to GitHub step summary if available
101+
if step_summary := os.environ.get("GITHUB_STEP_SUMMARY"):
102+
with open(step_summary, "a") as f:
103+
f.write(result.to_markdown())
129104

130-
sys.exit(0)
105+
sys.exit(0 if result.status else 1)
131106

132107

133108
if __name__ == "__main__":

.github/workflows/run-pytest.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

justfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)