Skip to content

Commit 54c4acb

Browse files
authored
Merge 5106d7b into fa180ee
2 parents fa180ee + 5106d7b commit 54c4acb

File tree

5 files changed

+1282
-123
lines changed

5 files changed

+1282
-123
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
PR template and categories definitions for YDB project.
3+
Used by both validate_pr_description.py and cherry_pick.py to ensure consistency.
4+
"""
5+
6+
# Issue reference patterns for validation
7+
ISSUE_PATTERNS = [
8+
r"https://github.com/ydb-platform/[a-z\-]+/issues/\d+",
9+
r"https://st.yandex-team.ru/[a-zA-Z]+-\d+",
10+
r"#\d+",
11+
r"[a-zA-Z]+-\d+"
12+
]
13+
14+
# Full PR template
15+
PULL_REQUEST_TEMPLATE = """### Changelog entry <!-- a user-readable short description of the changes that goes to CHANGELOG.md and Release Notes -->
16+
17+
...
18+
19+
### Changelog category <!-- remove all except one -->
20+
21+
* New feature
22+
* Experimental feature
23+
* Improvement
24+
* Performance improvement
25+
* User Interface
26+
* Bugfix
27+
* Backward incompatible change
28+
* Documentation (changelog entry is not required)
29+
* Not for changelog (changelog entry is not required)"""
30+
31+
# Categories that require changelog entry
32+
FOR_CHANGELOG_CATEGORIES = [
33+
"New feature",
34+
"Experimental feature",
35+
"User Interface",
36+
"Improvement",
37+
"Performance improvement",
38+
"Bugfix",
39+
"Backward incompatible change"
40+
]
41+
42+
# Categories that don't require changelog entry
43+
NOT_FOR_CHANGELOG_CATEGORIES = [
44+
"Documentation (changelog entry is not required)",
45+
"Not for changelog (changelog entry is not required)"
46+
]
47+
48+
# All valid categories
49+
ALL_CATEGORIES = FOR_CHANGELOG_CATEGORIES + NOT_FOR_CHANGELOG_CATEGORIES
50+
51+
52+
def get_category_section_template() -> str:
53+
"""Get the category section template as a string (for cherry_pick.py)"""
54+
return "\n".join([f"* {cat}" for cat in ALL_CATEGORIES])
55+
56+
57+
def get_category_section_for_selected(category: str) -> str:
58+
"""Get category section with only selected category marked"""
59+
return f"* {category}"
60+

.github/actions/validate_pr_description/validate_pr_description.py

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
11
import sys
22
import re
33
from typing import Tuple
4-
5-
issue_patterns = [
6-
r"https://github.com/ydb-platform/[a-z\-]+/issues/\d+",
7-
r"https://st.yandex-team.ru/[a-zA-Z]+-\d+",
8-
r"#\d+",
9-
r"[a-zA-Z]+-\d+"
10-
]
11-
12-
pull_request_template = """
13-
### Changelog entry <!-- a user-readable short description of the changes that goes to CHANGELOG.md and Release Notes -->
14-
15-
...
16-
17-
### Changelog category <!-- remove all except one -->
18-
19-
* New feature
20-
* Experimental feature
21-
* Improvement
22-
* Performance improvement
23-
* User Interface
24-
* Bugfix
25-
* Backward incompatible change
26-
* Documentation (changelog entry is not required)
27-
* Not for changelog (changelog entry is not required)
28-
"""
4+
from pr_template import (
5+
ISSUE_PATTERNS,
6+
PULL_REQUEST_TEMPLATE,
7+
FOR_CHANGELOG_CATEGORIES,
8+
NOT_FOR_CHANGELOG_CATEGORIES,
9+
ALL_CATEGORIES
10+
)
2911

3012
def validate_pr_description(description, is_not_for_cl_valid=True) -> bool:
3113
try:
@@ -44,7 +26,7 @@ def check_pr_description(description, is_not_for_cl_valid=True) -> Tuple[bool, s
4426
if "### Changelog category" not in description and "### Changelog entry" not in description:
4527
return is_not_for_cl_valid, "Changelog category and entry sections are not found."
4628

47-
if pull_request_template.strip() in description.strip():
29+
if PULL_REQUEST_TEMPLATE.strip() in description.strip():
4830
return is_not_for_cl_valid, "Pull request template as is."
4931

5032
# Extract changelog category section
@@ -62,34 +44,18 @@ def check_pr_description(description, is_not_for_cl_valid=True) -> Tuple[bool, s
6244
return False, txt
6345

6446
category = categories[0]
65-
for_cl_categories = [
66-
"New feature",
67-
"Experimental feature",
68-
"User Interface",
69-
"Improvement",
70-
"Performance improvement",
71-
"Bugfix",
72-
"Backward incompatible change"
73-
]
74-
75-
not_for_cl_categories = [
76-
"Documentation (changelog entry is not required)",
77-
"Not for changelog (changelog entry is not required)"
78-
]
79-
80-
valid_categories = for_cl_categories + not_for_cl_categories
81-
82-
if not any(cat.startswith(category) for cat in valid_categories):
47+
48+
if not any(cat.startswith(category) for cat in ALL_CATEGORIES):
8349
txt = f"Invalid Changelog category: {category}"
8450
print(f"::warning::{txt}")
8551
return False, txt
8652

87-
if not is_not_for_cl_valid and any(cat.startswith(category) for cat in not_for_cl_categories):
53+
if not is_not_for_cl_valid and any(cat.startswith(category) for cat in NOT_FOR_CHANGELOG_CATEGORIES):
8854
txt = f"Category is not for changelog: {category}"
8955
print(f"::notice::{txt}")
9056
return False, txt
9157

92-
if not any(cat.startswith(category) for cat in not_for_cl_categories):
58+
if not any(cat.startswith(category) for cat in NOT_FOR_CHANGELOG_CATEGORIES):
9359
entry_section = re.search(r"### Changelog entry.*?\n(.*?)(\n###|$)", description, re.DOTALL)
9460
if not entry_section or len(entry_section.group(1).strip()) < 20:
9561
txt = "The changelog entry is less than 20 characters or missing."
@@ -100,7 +66,7 @@ def check_pr_description(description, is_not_for_cl_valid=True) -> Tuple[bool, s
10066
def check_issue_pattern(issue_pattern):
10167
return re.search(issue_pattern, description)
10268

103-
if not any(check_issue_pattern(issue_pattern) for issue_pattern in issue_patterns):
69+
if not any(check_issue_pattern(issue_pattern) for issue_pattern in ISSUE_PATTERNS):
10470
txt = "Bugfix requires a linked issue in the changelog entry"
10571
print(f"::warning::{txt}")
10672
return False, txt

0 commit comments

Comments
 (0)