-
Notifications
You must be signed in to change notification settings - Fork 0
Fature/99 super chapters #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
de66dc7
8895bc2
b5b068c
d9291bc
d0250fd
8679c2a
30754f3
203a8cf
b93b0db
abfb0ff
20cf902
cd6cadc
bafb0eb
583978f
69d5b2d
4666b0d
2514d44
f72bcc5
2da077c
8382e55
85774a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,14 +22,15 @@ | |||||
| import os | ||||||
| import sys | ||||||
| import re | ||||||
|
|
||||||
| from typing import Any | ||||||
| import yaml | ||||||
|
|
||||||
| from release_notes_generator.utils.constants import ( | ||||||
| GITHUB_REPOSITORY, | ||||||
| GITHUB_TOKEN, | ||||||
| TAG_NAME, | ||||||
| CHAPTERS, | ||||||
| SUPER_CHAPTERS, | ||||||
| PUBLISHED_AT, | ||||||
| VERBOSE, | ||||||
| WARNINGS, | ||||||
|
|
@@ -59,7 +60,7 @@ | |||||
| ) | ||||||
| from release_notes_generator.utils.enums import DuplicityScopeEnum | ||||||
| from release_notes_generator.utils.gh_action import get_action_input | ||||||
| from release_notes_generator.utils.utils import normalize_version_tag | ||||||
| from release_notes_generator.utils.utils import normalize_labels, normalize_version_tag | ||||||
|
|
||||||
| logger = logging.getLogger(__name__) | ||||||
|
|
||||||
|
|
@@ -141,7 +142,7 @@ def get_from_tag_name() -> str: | |||||
| Get the from-tag name from the action inputs. | ||||||
| """ | ||||||
| raw = get_action_input(FROM_TAG_NAME, default="") | ||||||
| return normalize_version_tag(raw) # type: ignore[arg-type] | ||||||
| return normalize_version_tag(raw) | ||||||
|
|
||||||
| @staticmethod | ||||||
| def is_from_tag_name_defined() -> bool: | ||||||
|
|
@@ -166,11 +167,64 @@ def get_chapters() -> list[dict[str, str]]: | |||||
| logger.error("Error: 'chapters' input is not a valid YAML list.") | ||||||
| return [] | ||||||
| except yaml.YAMLError as exc: | ||||||
| logger.error("Error parsing 'chapters' input: {%s}", exc) | ||||||
| logger.error("Error parsing 'chapters' input: %s", exc) | ||||||
| return [] | ||||||
|
|
||||||
| return chapters | ||||||
|
|
||||||
| @staticmethod | ||||||
| def get_super_chapters() -> list[dict[str, Any]]: | ||||||
| """ | ||||||
| Get list of validated super-chapter definitions from the action inputs. | ||||||
|
|
||||||
| Each returned entry is guaranteed to have: | ||||||
| - 'title': str | ||||||
| - 'labels': list[str] (non-empty, normalized) | ||||||
|
|
||||||
| Invalid entries (non-dict, missing title, missing/empty labels) are skipped | ||||||
| with a warning log. | ||||||
| """ | ||||||
| # Get the 'super-chapters' input from environment variables | ||||||
| super_chapters_input: str = get_action_input(SUPER_CHAPTERS, default="") | ||||||
|
|
||||||
| # Parse the received string back to YAML array input. | ||||||
| try: | ||||||
| raw_list = yaml.safe_load(super_chapters_input) | ||||||
| if raw_list is None: | ||||||
| return [] | ||||||
| if not isinstance(raw_list, list): | ||||||
| logger.error("Error: 'super-chapters' input is not a valid YAML list.") | ||||||
| return [] | ||||||
| except yaml.YAMLError as exc: | ||||||
| logger.error("Error parsing 'super-chapters' input: %s", exc) | ||||||
| return [] | ||||||
|
|
||||||
| result: list[dict[str, Any]] = [] | ||||||
| for entry in raw_list: | ||||||
| if not isinstance(entry, dict): | ||||||
| logger.warning("Skipping super-chapter definition with invalid type %s: %s", type(entry), entry) | ||||||
| continue | ||||||
| if "title" not in entry: | ||||||
| logger.warning("Skipping super-chapter without title key: %s", entry) | ||||||
| continue | ||||||
| title = entry["title"] | ||||||
| if not isinstance(title, str) or not title.strip(): | ||||||
| logger.warning("Skipping super-chapter with invalid title value: %r", title) | ||||||
| continue | ||||||
|
|
||||||
| raw_labels = entry.get("labels", entry.get("label")) | ||||||
| if raw_labels is None: | ||||||
| logger.warning("Super-chapter '%s' has no 'label' or 'labels' key; skipping", title) | ||||||
| continue | ||||||
| normalized = normalize_labels(raw_labels) | ||||||
| if not normalized: | ||||||
| logger.warning("Super-chapter '%s' labels definition empty after normalization; skipping", title) | ||||||
| continue | ||||||
|
|
||||||
| result.append({"title": title, "labels": normalized}) | ||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| logger.debug("Validated super-chapter '%s' with labels: %s", title, normalized) | ||||||
| return result | ||||||
|
|
||||||
miroslavpojer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| @staticmethod | ||||||
| def get_hierarchy() -> bool: | ||||||
| """ | ||||||
|
|
@@ -351,8 +405,7 @@ def get_print_empty_chapters() -> bool: | |||||
| """ | ||||||
| Get the print empty chapters parameter value from the action inputs. | ||||||
| """ | ||||||
| return get_action_input(PRINT_EMPTY_CHAPTERS, "true").lower() == "true" # type: ignore[union-attr] | ||||||
| # mypy: string is returned as default | ||||||
| return get_action_input(PRINT_EMPTY_CHAPTERS, "true").lower() == "true" | ||||||
|
|
||||||
| @staticmethod | ||||||
| def validate_input(input_value, expected_type: type, error_message: str, error_buffer: list) -> bool: | ||||||
|
|
@@ -540,6 +593,8 @@ def validate_inputs() -> None: | |||||
| logger.debug("CodeRabbit summary ignore groups: %s", coderabbit_summary_ignore_groups) | ||||||
| logger.debug("Hidden service chapters: %s", ActionInputs.get_hidden_service_chapters()) | ||||||
| logger.debug("Service chapter order: %s", ActionInputs.get_service_chapter_order()) | ||||||
| super_chapters = ActionInputs.get_super_chapters() | ||||||
| logger.debug("Super chapters: %s", super_chapters) | ||||||
|
Comment on lines
+596
to
+597
|
||||||
| super_chapters = ActionInputs.get_super_chapters() | |
| logger.debug("Super chapters: %s", super_chapters) |
Uh oh!
There was an error while loading. Please reload this page.