|
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) |
33 | 34 | - Comment block is removed |
34 | 35 | """ |
35 | 36 |
|
@@ -116,12 +117,38 @@ def validate_changelog_yaml(file_path): |
116 | 117 |
|
117 | 118 | # Validate 'issues' field if present |
118 | 119 | if 'issues' in data: |
119 | | - if not isinstance(data['issues'], int): |
120 | | - print(f"::error file={file_path}::Field 'issues' must be an integer") |
| 120 | + if not isinstance(data['issues'], list): |
| 121 | + print(f"::error file={file_path}::Field 'issues' must be a list of integers") |
121 | 122 | return False |
122 | | - if data['issues'] > 17000: |
123 | | - 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'.") |
| 123 | + for i, issue in enumerate(data['issues']): |
| 124 | + if not isinstance(issue, int): |
| 125 | + print(f"::error file={file_path}::Field 'issues' entry {i} must be an integer") |
| 126 | + return False |
| 127 | + if issue > 17000: |
| 128 | + 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'.") |
| 129 | + return False |
| 130 | + |
| 131 | + # Validate 'links' field if present |
| 132 | + if 'links' in data: |
| 133 | + if not isinstance(data['links'], list): |
| 134 | + print(f"::error file={file_path}::Field 'links' must be a list") |
124 | 135 | return False |
| 136 | + for i, link in enumerate(data['links']): |
| 137 | + if not isinstance(link, dict): |
| 138 | + print(f"::error file={file_path}::Link {i} must be a mapping with 'name' and 'url' fields, not a plain string") |
| 139 | + return False |
| 140 | + if 'name' not in link or not link['name']: |
| 141 | + print(f"::error file={file_path}::Link {i} missing or empty 'name' field") |
| 142 | + return False |
| 143 | + if not isinstance(link['name'], str) or not link['name'].strip(): |
| 144 | + print(f"::error file={file_path}::Link {i} 'name' must be a non-empty string") |
| 145 | + return False |
| 146 | + if 'url' not in link or not link['url']: |
| 147 | + print(f"::error file={file_path}::Link {i} missing or empty 'url' field") |
| 148 | + return False |
| 149 | + if not isinstance(link['url'], str) or not link['url'].strip(): |
| 150 | + print(f"::error file={file_path}::Link {i} 'url' must be a non-empty string") |
| 151 | + return False |
125 | 152 |
|
126 | 153 | # Validate that comments are removed |
127 | 154 | for not_allowed in not_allowed_text: |
|
0 commit comments