This is an automated email from the ASF dual-hosted git repository. janhoy pushed a commit to branch branch_10x in repository https://gitbox.apache.org/repos/asf/solr.git
commit 819e4930f19fbcedcf67478062cb4781c082eb39 Author: Jan Høydahl <[email protected]> AuthorDate: Wed Dec 24 20:15:55 2025 +0100 Add more checks to the changelog validator (#3978) (cherry picked from commit afb290d56aa0dde34fff54309c7d2922396aa571) --- dev-tools/scripts/validate-changelog-yaml.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/dev-tools/scripts/validate-changelog-yaml.py b/dev-tools/scripts/validate-changelog-yaml.py index fa7369ebd4c..afc768e2cb7 100644 --- a/dev-tools/scripts/validate-changelog-yaml.py +++ b/dev-tools/scripts/validate-changelog-yaml.py @@ -26,10 +26,14 @@ Usage: Checks: - File is valid YAML +- All top-level keys are valid (title, type, issues, links, important_notes, modules, authors) +- Deprecated keys (merge_requests, configurations) are not used - Contains required 'title' field (non-empty string) - Contains required 'type' field (one of: added, changed, fixed, deprecated, removed, dependency_update, security, other) - Contains required 'authors' field with at least one author - Each author has a 'name' field (non-empty string) +- Contains either 'links' or 'issues' field (or both) +- If 'issues' is present, it must be an integer not exceeding 17000 - Comment block is removed """ @@ -41,6 +45,8 @@ import yaml def validate_changelog_yaml(file_path): """Validate a changelog YAML file. Returns True if valid.""" valid_types = ['added', 'changed', 'fixed', 'deprecated', 'removed', 'dependency_update', 'security', 'other'] + valid_keys = ['title', 'type', 'issues', 'links', 'important_notes', 'modules', 'authors'] + deprecated_keys = ['merge_requests', 'configurations'] not_allowed_text = ['DELETE ALL COMMENTS UP HERE', 'Most such changes are too small'] try: @@ -53,6 +59,18 @@ def validate_changelog_yaml(file_path): print(f"::error file={file_path}::File must contain YAML mapping (key-value pairs)") return False + # Check for invalid top-level keys + for key in data.keys(): + if key not in valid_keys and key not in deprecated_keys: + print(f"::error file={file_path}::Invalid top-level key '{key}'. Valid keys are: {', '.join(valid_keys)}") + return False + + # Check for deprecated keys + for deprecated_key in deprecated_keys: + if deprecated_key in data: + print(f"::error file={file_path}::Our project does not use the '{deprecated_key}' yaml key, please remove") + return False + # Validate 'title' field if 'title' not in data or not data['title']: print(f"::error file={file_path}::Missing or empty 'title' field") @@ -89,6 +107,20 @@ def validate_changelog_yaml(file_path): print(f"::error file={file_path}::Author {i} 'name' must be a non-empty string") return False + # Validate that either 'links' or 'issues' exists (or both) + if 'links' not in data and 'issues' not in data: + print(f"::error file={file_path}::Must contain either 'links' or 'issues' key (or both)") + return False + + # Validate 'issues' field if present + if 'issues' in data: + if not isinstance(data['issues'], int): + print(f"::error file={file_path}::Field 'issues' must be an integer") + return False + if data['issues'] > 17000: + print(f"::error file={file_path}::Field 'issues' value {data['issues']} points to a non-existing github PR. Did you intend to reference a JIRA issue, please use 'links'.") + return False + # Validate that comments are removed for not_allowed in not_allowed_text: if not_allowed in raw_content:
