[llvm] [CI] Upstream metrics script and container definition (PR #117461)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 04:49:13 PST 2024
================
@@ -0,0 +1,180 @@
+import requests
+import time
+import os
+from dataclasses import dataclass
+
+from github import Github
+from github import Auth
+
+GRAFANA_URL = (
+ "https://influx-prod-13-prod-us-east-0.grafana.net/api/v1/push/influx/write"
+)
+GITHUB_PROJECT = "llvm/llvm-project"
+WORKFLOWS_TO_TRACK = ["Check code formatting"]
+
+
+ at dataclass
+class JobMetrics:
+ job_name: str
+ queue_time: int
+ run_time: int
+ status: int
+ created_at_ns: int
+ workflow_id: int
+
+
+def get_metrics(github_repo, workflows_to_track):
+ """Gets the metrics for specified Github workflows.
+
+ This function takes in a list of workflows to track, and optionally the
+ workflow ID of the last tracked invocation. It grabs the relevant data
+ from Github, returning it to the caller.
+
+ Args:
+ github_repo: A github repo object to use to query the relevant information.
+ workflows_to_track: A dictionary mapping workflow names to the last
+ invocation ID where metrics have been collected, or None to collect the
+ last five results.
+
+ Returns:
+ Returns a list of JobMetrics objects, containing the relevant metrics about
+ the workflow.
+ """
+ workflow_runs = iter(github_repo.get_workflow_runs())
+
+ workflow_metrics = []
+
+ workflows_to_include = {}
+ for workflow_to_track in workflows_to_track:
+ workflows_to_include[workflow_to_track] = True
+ workflows_left_to_include = len(workflows_to_track)
+
+ while True:
----------------
Keenuts wrote:
```suggestion
while len(workflows_to_include) > 0:
```
https://github.com/llvm/llvm-project/pull/117461
More information about the llvm-commits
mailing list