[libcxx-commits] [libcxx] [llvm] [llvm][CI] Add metrics collection for libc++ premerge testing. (PR #152801)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 21 09:08:32 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r HEAD~1...HEAD .ci/metrics/metrics.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- metrics.py	2025-08-21 15:54:49.000000 +0000
+++ metrics.py	2025-08-21 16:07:59.259118 +0000
@@ -98,11 +98,12 @@
     aggregate_status: int
     workflow_id: int
 
 
 def create_and_append_libcxx_aggregates(
-    workflow_metrics: list[JobMetrics]) -> list[JobMetrics,AggregateMetric]:
+    workflow_metrics: list[JobMetrics],
+) -> list[JobMetrics, AggregateMetric]:
     """
     Find libc++ JobMetric entries and create aggregate metrics for them.
 
     Sort the libc++ JobMetric entries by workflow id, and for each workflow
     id group them by stages.  Create an aggreate metric for each stage for each
@@ -124,11 +125,11 @@
             continue
         # Only want libc++ jobs.
         if job.workflow_name != "Build and Test libc++":
             continue
         if job.workflow_id not in aggregate_data.keys():
-            aggregate_data[job.workflow_id] = [ job ]
+            aggregate_data[job.workflow_id] = [job]
         else:
             aggregate_data[job.workflow_id].append(job)
 
     # Go through each aggregate_data list (workflow id) and find all the
     # needed data
@@ -137,29 +138,29 @@
         stage1_jobs = list()
         stage2_jobs = list()
         stage3_jobs = list()
         # sort jobs into stage1, stage2, & stage3.
         for job in job_list:
-            if job.job_name.find('stage1') > 0:
+            if job.job_name.find("stage1") > 0:
                 stage1_jobs.append(job)
-            elif job.job_name.find('stage2') > 0:
+            elif job.job_name.find("stage2") > 0:
                 stage2_jobs.append(job)
-            elif job.job_name.find('stage3') > 0:
+            elif job.job_name.find("stage3") > 0:
                 stage3_jobs.append(job)
 
-        for job_list in [ stage1_jobs, stage2_jobs, stage3_jobs]:
+        for job_list in [stage1_jobs, stage2_jobs, stage3_jobs]:
             if len(job_list) < 1:
-                  # No jobs in that stage this time around.
-                  continue
+                # No jobs in that stage this time around.
+                continue
 
             # Get the aggregate name.
             ag_name = "github_libcxx_premerge_checks_"
-            if job_list[0].job_name.find('stage1') > 0:
+            if job_list[0].job_name.find("stage1") > 0:
                 ag_name = ag_name + "stage1_aggregate"
-            elif job_list[0].job_name.find('stage2') > 0:
+            elif job_list[0].job_name.find("stage2") > 0:
                 ag_name = ag_name + "stage2_aggregate"
-            elif job_list[0].job_name.find('stage3') > 0:
+            elif job_list[0].job_name.find("stage3") > 0:
                 ag_name = ag_name + "stage3_aggregate"
             else:
                 ag_name = ag_name + "unknown_aggregate"
 
             # Initialize the rest of the aggregate values
@@ -191,15 +192,15 @@
             # Compute aggregate queue time (in seconds, not ns)
             ag_queue_time = (latest_start - earliest_create) / 1000000000
             # Append the aggregate metrics to the workflow metrics list.
             workflow_metrics.append(
                 AggregateMetric(
-                    ag_name, ag_queue_time, ag_run_time, ag_status,
-                    ag_workflow_id
+                    ag_name, ag_queue_time, ag_run_time, ag_status, ag_workflow_id
                 )
             )
     return
+
 
 def clean_up_libcxx_job_name(old_name: str) -> str:
     """
     Convert libcxx job names to generically legal strings.
 
@@ -208,21 +209,21 @@
     (Remove parentheses; replace commas, hyphens and spaces with
     underscores; replace '+' with 'x'.
     """
     # Names should have exactly one set of parentheses, so break on that. If
     # they don't have any parentheses, then don't update them at all.
-    if old_name.find('(') == -1:
+    if old_name.find("(") == -1:
         return old_name
-    stage, remainder = old_name.split('(')
+    stage, remainder = old_name.split("(")
     stage = stage.strip()
-    if remainder[-1] == ')':
+    if remainder[-1] == ")":
         remainder = remainder[:-1]
-    remainder = remainder.replace('-', '_')
-    remainder = remainder.replace(',', '_')
-    remainder = remainder.replace(' ', '_')
-    remainder = remainder.replace('+', 'x')
-    new_name = stage + '_' + remainder
+    remainder = remainder.replace("-", "_")
+    remainder = remainder.replace(",", "_")
+    remainder = remainder.replace(" ", "_")
+    remainder = remainder.replace("+", "x")
+    new_name = stage + "_" + remainder
     return new_name
 
 def github_get_metrics(
     github_repo: github.Repository, last_workflows_seen_as_completed: set[int]
 ) -> tuple[list[JobMetrics], int]:
@@ -283,17 +284,19 @@
         # If we reach a workflow older than X, stop.
         if workflow_age_mn > GITHUB_WORKFLOW_MAX_CREATED_AGE_HOURS * 60:
             break
 
         # This workflow is not interesting to us.
-        if (task.name not in GITHUB_WORKFLOW_TO_TRACK
-            and task.name != "Build and Test libc++"):
+        if (
+            task.name not in GITHUB_WORKFLOW_TO_TRACK
+            and task.name != "Build and Test libc++"
+        ):
             continue
 
         libcxx_testing = False
         if task.name == "Build and Test libc++":
-          libcxx_testing = True
+            libcxx_testing = True
 
         if task.status == "completed":
             workflow_seen_as_completed.add(task.id)
 
         # This workflow has already been seen completed in the previous run.
@@ -303,12 +306,11 @@
         name_prefix = GITHUB_WORKFLOW_TO_TRACK[task.name]
         for job in task.jobs():
             if libcxx_testing:
                 # We're not running macos or windows libc++ tests on our
                 # infrastructure.
-                if (job.name.find("macos") != -1 or
-                    job.name.find("windows") != -1):
+                if job.name.find("macos") != -1 or job.name.find("windows") != -1:
                     continue
             # This job is not interesting to us.
             elif job.name not in GITHUB_JOB_TO_TRACK[name_prefix]:
                 continue
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/152801


More information about the libcxx-commits mailing list