Skip to content

Commit aa591d4

Browse files
handle special case in health report (Azure#39203)
1 parent 00f1da5 commit aa591d4

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

scripts/repo_health_status_report/output_health_report.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,24 @@ class LibraryStatus(typing.TypedDict, total=False):
160160

161161
PipelineResultsUnion = typing.Union[CIPipelineResult, TestsPipelineResult, TestsWeeklyPipelineResult]
162162

163+
164+
# This script makes the engineering systems assumption that a pipeline exists per service directory.
165+
# Here we have a special exception where communication creates separate pipelines for each package.
166+
# Hardcoding pipeline IDs for now, but if this becomes a common scenario, we should
167+
# consider updating the health report data schema to support this
168+
communication_mapping = {
169+
"azure-communication-chat": {"ci": {"id": "2047", "link": ""}, "tests": {"id": "2723", "link": ""}, "tests_weekly": {"id": "3721", "link": ""}},
170+
"azure-communication-phonenumbers": {"ci": {"id": "2047", "link": ""}, "tests": {"id": "2722", "link": ""}, "tests_weekly": {"id": "3732", "link": ""}},
171+
"azure-communication-email": {"ci": {"id": "2047", "link": ""}, "tests": {"id": "5257", "link": ""}, "tests_weekly": {"id": "5258", "link": ""}},
172+
"azure-communication-messages": {"ci": {"id": "2047", "link": ""}},
173+
"azure-communication-sms": {"ci": {"id": "2047", "link": ""}, "tests": {"id": "2724", "link": ""}, "tests_weekly": {"id": "3736", "link": ""}},
174+
"azure-communication-callautomation": {"ci": {"id": "2047", "link": ""}},
175+
"azure-communication-identity": {"ci": {"id": "2047", "link": ""}, "tests": {"id": "2725", "link": ""}, "tests_weekly": {"id": "3725", "link": ""}},
176+
"azure-communication-rooms": {"ci": {"id": "2047", "link": ""}, "tests": {"id": "4716", "link": ""}, "tests_weekly": {"id": "5131", "link": ""}},
177+
"azure-communication-jobrouter": {"ci": {"id": "2047", "link": ""}},
178+
}
179+
180+
163181
SDK_TEAM_OWNED = [
164182
"azure-ai-documentintelligence",
165183
"azure-ai-formrecognizer",
@@ -389,6 +407,7 @@ def get_ci_result(service: str, pipeline_id: int | None, pipelines: dict[Service
389407
if not pipeline_id:
390408
print(f"No CI result for {service}")
391409
record_all_pipeline("ci", pipelines[service], "UNKNOWN")
410+
pipelines[service]["ci"]["link"] = ""
392411
return
393412

394413
build_response = httpx.get(get_build_url(pipeline_id), headers=AUTH_HEADERS)
@@ -431,6 +450,7 @@ def get_tests_result(service: str, pipeline_id: int | None, pipelines: dict[Serv
431450
if not pipeline_id:
432451
print(f"No live tests result for {service}")
433452
record_all_pipeline("tests", pipelines[service], "UNKNOWN")
453+
pipelines[service]["tests"]["link"] = ""
434454
return
435455

436456
build_response = httpx.get(get_build_url(pipeline_id), headers=AUTH_HEADERS)
@@ -467,6 +487,7 @@ def get_tests_weekly_result(service: str, pipeline_id: int | None, pipelines: di
467487
if not pipeline_id:
468488
print(f"No tests_weekly result for {service}")
469489
record_all_pipeline("tests_weekly", pipelines[service], "UNKNOWN")
490+
pipelines[service]["tests_weekly"]["link"] = ""
470491
return
471492

472493
build_response = httpx.get(get_build_url(pipeline_id), headers=AUTH_HEADERS)
@@ -894,6 +915,37 @@ def write_to_html(libraries: dict[ServiceDirectory, dict[LibraryName, LibrarySta
894915
file.write(html_with_css)
895916

896917

918+
def handle_special_case(service_directory: str, special_case_mapping: dict[str, typing.Any]) -> None:
919+
"""This script makes the engineering systems assumption that a pipeline exists per service directory.
920+
For special exceptions where a pipeline was created per library, we need to handle things separately for now.
921+
"""
922+
for library, pipeline_map in special_case_mapping.items():
923+
record_all_pipeline("ci", pipelines[service_directory], "UNKNOWN")
924+
record_all_pipeline("tests", pipelines[service_directory], "UNKNOWN")
925+
record_all_pipeline("tests_weekly", pipelines[service_directory], "UNKNOWN")
926+
get_ci_result(service_directory, pipeline_map.get("ci", {}).get("id"), pipelines)
927+
get_tests_result(service_directory, pipeline_map.get("tests", {}).get("id"), pipelines)
928+
get_tests_weekly_result(service_directory, pipeline_map.get("tests_weekly", {}).get("id"), pipelines)
929+
930+
details = libraries[service_directory][library]
931+
if not is_check_enabled(str(details["path"]), "ci_enabled"):
932+
details["status"] = "BLOCKED"
933+
record_all_library(details, "DISABLED")
934+
continue
935+
report_check_result("mypy", pipelines[service_directory], details)
936+
report_check_result("pylint", pipelines[service_directory], details)
937+
report_check_result("pyright", pipelines[service_directory], details)
938+
report_check_result("sphinx", pipelines[service_directory], details)
939+
details["type_check_samples"] = (
940+
"ENABLED" if is_check_enabled(str(details["path"]), "type_check_samples") else "DISABLED"
941+
)
942+
report_samples_result("samples", pipelines[service_directory], details)
943+
details["sdk_owned"] = details["path"].name in SDK_TEAM_OWNED
944+
report_test_result("tests", pipelines[service_directory], details)
945+
report_test_result("ci", pipelines[service_directory], details)
946+
report_overall_status(details)
947+
948+
897949
if __name__ == "__main__":
898950
parser = argparse.ArgumentParser(description="Report the health status for the Python SDK repo.")
899951

@@ -924,7 +976,9 @@ def write_to_html(libraries: dict[ServiceDirectory, dict[LibraryName, LibrarySta
924976
get_tests_weekly_result(service, pipeline_ids.get("tests_weekly", {}).get("id"), pipelines)
925977

926978
report_status(libraries, pipelines)
979+
handle_special_case(service_directory="communication", special_case_mapping=communication_mapping)
927980
report_sla_and_total_issues(libraries)
981+
928982
if args.format == "csv":
929983
write_to_csv(libraries)
930984
elif args.format == "md":

0 commit comments

Comments
 (0)