|
29 | 29 | - Contains required 'authors' field with at least one author |
30 | 30 | - Each author has a 'name' field (non-empty string) |
31 | 31 | - Contains either 'links' or 'issues' field (or both) |
32 | | -- If 'issues' is present, it must be an integer not exceeding 17000 |
| 32 | +- If 'issues' is present, it must be a list of integers not exceeding 17000 |
| 33 | +- If 'links' is present, each entry must be a mapping with 'name' and 'url' fields (not a plain string) |
| 34 | +- Comment block is removed |
33 | 35 | """ |
34 | 36 |
|
35 | 37 | import sys |
@@ -113,12 +115,38 @@ def validate_changelog_yaml(file_path): |
113 | 115 |
|
114 | 116 | # Validate 'issues' field if present |
115 | 117 | if 'issues' in data: |
116 | | - if not isinstance(data['issues'], int): |
117 | | - print(f"::error file={file_path}::Field 'issues' must be an integer") |
| 118 | + if not isinstance(data['issues'], list): |
| 119 | + print(f"::error file={file_path}::Field 'issues' must be a list of integers") |
118 | 120 | return False |
119 | | - if data['issues'] > 17000: |
120 | | - 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'.") |
| 121 | + for i, issue in enumerate(data['issues']): |
| 122 | + if not isinstance(issue, int): |
| 123 | + print(f"::error file={file_path}::Field 'issues' entry {i} must be an integer") |
| 124 | + return False |
| 125 | + if issue > 17000: |
| 126 | + print(f"::error file={file_path}::Field 'issues' value {issue} points to a non-existing github PR. Did you intend to reference a JIRA issue, please use 'links'.") |
| 127 | + return False |
| 128 | + |
| 129 | + # Validate 'links' field if present |
| 130 | + if 'links' in data: |
| 131 | + if not isinstance(data['links'], list): |
| 132 | + print(f"::error file={file_path}::Field 'links' must be a list") |
121 | 133 | return False |
| 134 | + for i, link in enumerate(data['links']): |
| 135 | + if not isinstance(link, dict): |
| 136 | + print(f"::error file={file_path}::Link {i} must be a mapping with 'name' and 'url' fields, not a plain string") |
| 137 | + return False |
| 138 | + if 'name' not in link or not link['name']: |
| 139 | + print(f"::error file={file_path}::Link {i} missing or empty 'name' field") |
| 140 | + return False |
| 141 | + if not isinstance(link['name'], str) or not link['name'].strip(): |
| 142 | + print(f"::error file={file_path}::Link {i} 'name' must be a non-empty string") |
| 143 | + return False |
| 144 | + if 'url' not in link or not link['url']: |
| 145 | + print(f"::error file={file_path}::Link {i} missing or empty 'url' field") |
| 146 | + return False |
| 147 | + if not isinstance(link['url'], str) or not link['url'].strip(): |
| 148 | + print(f"::error file={file_path}::Link {i} 'url' must be a non-empty string") |
| 149 | + return False |
122 | 150 |
|
123 | 151 | # All validations passed |
124 | 152 | print(f"✓ {file_path} is valid") |
|
0 commit comments