diff --git a/newModuleTagger/find_prs.py b/newModuleTagger/find_prs.py index 4cfa2e1..fa80362 100755 --- a/newModuleTagger/find_prs.py +++ b/newModuleTagger/find_prs.py @@ -136,6 +136,31 @@ def color_backport_label(title: str) -> str: else: return title +def warnings_for_pr(pr: dict[str, any]) -> list[str]: + warnings = [] + + has_new_module = any( + file['changeType'] == 'ADDED' and file['path'].startswith('nixos/modules/') and file['path'].endswith('.nix') + for file in pr['files'] + ) + module_list_touched = any(file['path'] == 'nixos/modules/module-list.nix' for file in pr['files']) + if has_new_module and not module_list_touched: + warnings.append('New module added, but nixos/modules/module-list.nix was not changed') + + has_new_test = any( + file['changeType'] == 'ADDED' and file['path'].startswith('nixos/tests/') and file['path'].endswith('.nix') + for file in pr['files'] + ) + all_tests_touched = any(file['path'] == 'nixos/tests/all-tests.nix' for file in pr['files']) + if has_new_test and not all_tests_touched: + warnings.append('New test added, but nixos/tests/all-tests.nix was not changed') + + release_notes_touched = any(file['path'].startswith('nixos/doc/manual/release-notes') for file in pr['files']) + if has_new_module and not release_notes_touched: + warnings.append('New module added, but nothing in nixos/doc/manual/release-notes was changed') + + return warnings + def print_pr(pr: dict[str, any]): tqdm.write(f'[{STATUS_COLORS.get(pr["state"], pr["state"])}|\033[1m{pr["number"]}\033[0m] {pr["author"]} - {color_backport_label(pr["title"])}') tqdm.write("\033[1;34m" + pr["url"] + "\033[0m") @@ -144,6 +169,11 @@ def print_pr(pr: dict[str, any]): for file in pr["files"]: tqdm.write(f' [{CHANGE_TYPE_COLORS.get(file['changeType'], file['changeType'])}] {color_file_path(file['path'], file['changeType'])}') tqdm.write("") + warnings = warnings_for_pr(pr) + for warning in warnings: + tqdm.write(f'\033[1;31m!!! {warning} !!!\033[0m') + if warnings: + tqdm.write("") if any([ file['path'].startswith("nixos/tests/") and file['changeType'] == 'ADDED' for file in pr['files'] ]):