Skip to content

Commit

Permalink
Merge pull request #111 from ministryofjustice/fix/cfr-excluded-workf…
Browse files Browse the repository at this point in the history
…lows

Add excluded workflows to df.py and cfr.py
  • Loading branch information
richgreen-moj authored May 24, 2024
2 parents 0886250 + 82808d6 commit 45d6707
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions cfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
)


Expand Down
10 changes: 7 additions & 3 deletions df.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# Initialize variables
runs = []
per_page = 100

date_format = "%Y-%m-%dT%H:%M:%SZ"

# Read ACCESS_TOKEN from environment
Expand All @@ -42,7 +41,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

Expand All @@ -60,7 +61,10 @@
# 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 workflows)
num_successful_runs += len(
[run for run in runs if run["name"] not in excluded_workflows]
)

# Compute the number of days between the earliest and latest successful runs
if num_successful_runs > 0:
Expand Down

0 comments on commit 45d6707

Please sign in to comment.