newModuleTagger: custom handling for prometheus exporters

This commit is contained in:
2026-07-30 13:50:58 +09:00
parent b27a6c1e4d
commit 12b4106ac4
+15 -4
View File
@@ -5,10 +5,13 @@ from tqdm import tqdm
from pathlib import Path
import subprocess
import json
import time
PAGINATION_STEP=3
PAGES=800
MAX_RETRIES=8
RETRY_BACKOFF_SECONDS=3
GRAPHQL_QUERY = """
@@ -136,6 +139,9 @@ def color_backport_label(title: str) -> str:
else:
return title
PROMETHEUS_EXPORTERS_DIR = 'nixos/modules/services/monitoring/prometheus/exporters/'
PROMETHEUS_EXPORTERS_FILE = 'nixos/modules/services/monitoring/prometheus/exporters.nix'
def warnings_for_pr(pr: dict[str, any]) -> list[str]:
warnings = []
@@ -143,8 +149,14 @@ def warnings_for_pr(pr: dict[str, any]) -> list[str]:
file['changeType'] == 'ADDED' and file['path'].startswith('nixos/modules/') and file['path'].endswith('.nix')
for file in pr['files']
)
is_prometheus_exporter = (
any(file['path'].startswith(PROMETHEUS_EXPORTERS_DIR) for file in pr['files'])
or any(file['path'] == PROMETHEUS_EXPORTERS_FILE 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:
if has_new_module and not module_list_touched and not is_prometheus_exporter:
warnings.append('New module added, but nixos/modules/module-list.nix was not changed')
has_new_test = any(
@@ -152,7 +164,7 @@ def warnings_for_pr(pr: dict[str, any]) -> list[str]:
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:
if has_new_test and not all_tests_touched and not is_prometheus_exporter:
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'])
@@ -162,7 +174,7 @@ def warnings_for_pr(pr: dict[str, any]) -> list[str]:
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(f'[{STATUS_COLORS.get(pr["state"], pr["state"])}|\033[1m{pr["number"]}\033[0m] {pr["author"]} - {pr["createdAt"][:10]} - {color_backport_label(pr["title"])}')
tqdm.write("\033[1;34m" + pr["url"] + "\033[0m")
tqdm.write("")
tqdm.write('Files:')
@@ -187,4 +199,3 @@ def print_pr(pr: dict[str, any]):
if __name__ == "__main__":
find_prs_without_new_module_tag()