From e2d4e2a827b3a6a12a24a816da610bf3f8a8ebb8 Mon Sep 17 00:00:00 2001 From: Rich Green Date: Fri, 24 May 2024 13:22:14 +0100 Subject: [PATCH 1/4] add excluded workflow logic to cfr --- cfr.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cfr.py b/cfr.py index 3b414cc..dcfc77c 100644 --- a/cfr.py +++ b/cfr.py @@ -33,7 +33,9 @@ # load the repository names from a JSON file with open(args.filename, "r") as f: - repos = json.load(f)["repos"] + data = json.load(f) + repos = data['repos'] + excluded_workflows = data['excluded_workflows'] filename, file_extension = os.path.splitext(args.filename) # Initialize variables @@ -54,7 +56,7 @@ workflow_runs = get_workflow_runs(OWNER, repo, ACCESS_TOKEN, params) total_workflow_runs += len(workflow_runs) total_unsuccessful_runs += len( - [run for run in workflow_runs if run["conclusion"] != "success"] + [run for run in workflow_runs if run["conclusion"] != "success" and run["name"] not in excluded_workflows] ) From cda8db97c6c2533cae4dab75914f1f4d175a0112 Mon Sep 17 00:00:00 2001 From: Rich Green Date: Fri, 24 May 2024 14:00:56 +0100 Subject: [PATCH 2/4] add excluded runs logic to df.py --- df.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/df.py b/df.py index 5770ab7..1a56cb3 100644 --- a/df.py +++ b/df.py @@ -24,6 +24,7 @@ # Initialize variables runs = [] per_page = 100 +num_excluded_runs = 0 date_format = "%Y-%m-%dT%H:%M:%SZ" @@ -42,7 +43,9 @@ # load the repository names from a JSON file with open(args.filename, "r") as f: - repos = json.load(f)["repos"] + data = json.load(f) + repos = data['repos'] + excluded_workflows = data['excluded_workflows'] num_successful_runs = 0 @@ -60,7 +63,12 @@ # Log message if there's a problem retrieving the workflow runs print(f"Error retrieving workflow runs: {e}") -num_successful_runs = len(runs) +# Calculate number of successful runs (minus the excluded runs) +num_runs = len(runs) +num_excluded_runs += len( + [run for run in runs if run["name"] in excluded_workflows] + ) +num_successful_runs = (num_runs - num_excluded_runs) # Compute the number of days between the earliest and latest successful runs if num_successful_runs > 0: From fe3e5c2a04d6d3bde33d6bd5b8024176a18319b5 Mon Sep 17 00:00:00 2001 From: Rich Green Date: Fri, 24 May 2024 14:12:51 +0100 Subject: [PATCH 3/4] update df logic --- df.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/df.py b/df.py index 1a56cb3..8d2aeca 100644 --- a/df.py +++ b/df.py @@ -24,8 +24,6 @@ # Initialize variables runs = [] per_page = 100 -num_excluded_runs = 0 - date_format = "%Y-%m-%dT%H:%M:%SZ" # Read ACCESS_TOKEN from environment @@ -64,11 +62,9 @@ print(f"Error retrieving workflow runs: {e}") # Calculate number of successful runs (minus the excluded runs) -num_runs = len(runs) -num_excluded_runs += len( - [run for run in runs if run["name"] in excluded_workflows] +num_successful_runs += len( + [run for run in runs if run["name"] not in excluded_workflows] ) -num_successful_runs = (num_runs - num_excluded_runs) # Compute the number of days between the earliest and latest successful runs if num_successful_runs > 0: From 82808d6bcc5f20823f408f4b94c4b6a3e50a6033 Mon Sep 17 00:00:00 2001 From: Rich Green Date: Fri, 24 May 2024 14:14:04 +0100 Subject: [PATCH 4/4] update --- df.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/df.py b/df.py index 8d2aeca..8708f92 100644 --- a/df.py +++ b/df.py @@ -61,7 +61,7 @@ # Log message if there's a problem retrieving the workflow runs print(f"Error retrieving workflow runs: {e}") -# Calculate number of successful runs (minus the excluded runs) +# Calculate number of successful runs (minus the excluded workflows) num_successful_runs += len( [run for run in runs if run["name"] not in excluded_workflows] )