Skip to content

Commit

Permalink
fix(check-nightly): multiple daily runs don't overwrite each other (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: Bradley Dice <[email protected]>
  • Loading branch information
gforsyth and bdice authored Feb 5, 2025
1 parent 3761b9d commit c472617
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions check_nightly_success/check-nightly-success/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# ruff: noqa: INP001

import argparse
import itertools
import os
import re
import sys
from collections import defaultdict
from datetime import datetime

import requests
Expand Down Expand Up @@ -52,7 +52,24 @@ def main(
now = datetime.now(tz=tz)

latest_success = {}
for branch, branch_runs in itertools.groupby(runs, key=lambda r: r["head_branch"]):
# Rather frustratingly, the workflow runs returned from the GitHub API can
# have alternating ordering of `head_branch`
# e.g.
# run[0]['head_branch'] == "branch-25.02"
# run[1]['head_branch'] == "branch-25.04"
# run[2]['head_branch'] == "branch-25.02"
#
# In this situation, the behavior of `itertools.groupby` (previously used
# here) is to only group _consecutive_ runs, so the results of the
# subsequent branch match (i.e. the second group of `branch-25.02` runs)
# will overwrite the results of the first one, potentially overwriting a
# previous success. The snippet below unifies the groups so it's more like a
# SQL groupby and there is no chance of overwriting.
branch_dict = defaultdict(list)
for run in runs:
branch_dict[run["head_branch"]].append(run)

for branch, branch_runs in branch_dict.items():
# only consider RAPIDS release branches, which have versions like
# '25.02' (RAPIDS) or '0.42' (ucxx, ucx-py)
if not re.match("branch-[0-9]{1,2}.[0-9]{2}", branch):
Expand Down

0 comments on commit c472617

Please sign in to comment.