Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions developer_support_script/check_build_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ERROR_THRESHOLD_PERCENTAGE = 50


def request_json(url: str) -> Any:
def request_json(url: str) -> dict | None:
"""
Utility function to get Json data from Jenkins.

Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(self, name: str) -> None:
self.num_evaluate_builds = self._get_num_evaluate_builds()
self.num_aborted_builds = self._get_num_aborted_builds()

def add_job(self, job):
def add_job(self, job: "JobData") -> None:
"""
add another job's results to here so we can get a summary across jobs
"""
Expand Down Expand Up @@ -113,7 +113,8 @@ def _get_num_aborted_builds(self) -> int:

for build in self.builds["ABORTED"]:
data = request_json(
f"https://epics-jenkins.isis.rl.ac.uk/job/{self.name}/{build['number']}/api/json?tree=actions[causes[*]]"
f"https://epics-jenkins.isis.rl.ac.uk/job/{self.name}/"
f"{build['number']}/api/json?tree=actions[causes[*]]"
)
for action in data["actions"]:
if (
Expand Down Expand Up @@ -153,7 +154,8 @@ def _get_test_reports(self) -> list[Any]:

def _get_failed_tests(self) -> Counter:
"""
Gets all the failed tests. The name is generated by using the the class name and the test name.
Gets all the failed tests. The name is generated by using
the class name and the test name.

Returns:
Counter: Key is test case name, value is number of failures.
Expand All @@ -170,7 +172,8 @@ def _get_failed_tests(self) -> Counter:

def print_results(self) -> None:
"""
Prints the percentage of aborted builds for the job, the percentage of failures with no test report, and the percentage failure of each failing test.
Prints the percentage of aborted builds for the job, the percentage of
failures with no test report, and the percentage failure of each failing test.
"""
if not self.buildable:
print("WARNING: build is currently disabled")
Expand All @@ -179,13 +182,13 @@ def print_results(self) -> None:
# Aborted builds.
valid_builds = self.num_evaluate_builds + self.no_test_report_failures
all_builds = valid_builds + self.num_aborted_builds
percentage_aborted_builds = (self.num_aborted_builds / all_builds) * 100 if all_builds > 0 else 0
percentage_aborted_builds = (
(self.num_aborted_builds / all_builds) * 100 if all_builds > 0 else 0
)
level = calculate_level(
percentage_aborted_builds, ERROR_THRESHOLD_PERCENTAGE, WARNING_THRESHOLD_PERCENTAGE
)
print(
f"{level}: Aborted builds [{percentage_aborted_builds:.0f}%]"
)
print(f"{level}: Aborted builds [{percentage_aborted_builds:.0f}%]")

# Failures with no test report
# valid_builds will only be 0 if self.no_test_report_failures is also 0
Expand All @@ -200,7 +203,8 @@ def print_results(self) -> None:
WARNING_THRESHOLD_PERCENTAGE,
)
print(
f"{level}: Failed builds with no Test Report [{percentage_no_test_report_failures:.0f}%]"
f"{level}: Failed builds with no Test Report "
f"[{percentage_no_test_report_failures:.0f}%]"
)

# Tests.
Expand All @@ -212,12 +216,10 @@ def print_results(self) -> None:
level = calculate_level(
percentage_test_failure, ERROR_THRESHOLD_PERCENTAGE, WARNING_THRESHOLD_PERCENTAGE
)
print(
f"{level}: [{percentage_test_failure:.0f}%] {name}"
)
print(f"{level}: [{percentage_test_failure:.0f}%] {name}")


def process_jobs(jobs, summary_name):
def process_jobs(jobs: list(str), summary_name: str) -> None:
first = True
job_summary = None
for job in jobs:
Expand All @@ -242,7 +244,12 @@ def process_jobs(jobs, summary_name):
"System_Tests_win32",
"System_Tests_galilold",
"System_Tests_Win11",
"System_Tests_Win11_Win11",
]
SQUISH_JOBS = [
"System_Tests_Squish",
"System_Tests_Squish_Win11",
"System_Tests_Squish_Win11_Win11",
]
SQUISH_JOBS = ["System_Tests_Squish", "System_Tests_Squish_Win11"]
process_jobs(EPICS_JOBS, "EPICS")
process_jobs(SQUISH_JOBS, "SQUISH")
Loading