Skip to content

Commit f1dbe7e

Browse files
authored
Merge pull request #2707 from cms-sw/merge-prs-cache
collect merged details for easy access via IB dashboard
2 parents d1ffd75 + 9e5cf6b commit f1dbe7e

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

github_utils.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ def cache_invalid_pr(pr_id, cache):
293293
cache["dirty"] = True
294294

295295

296+
def get_pr_data(repo_name, pr_number, cmsprs):
297+
pr_md5 = md5((pr_number + "\n").encode()).hexdigest()
298+
pr_cache = join(cmsprs, repo_name, pr_md5[0:2], pr_md5[2:] + ".json")
299+
print("Checking cached file: " + pr_cache)
300+
if exists(pr_cache):
301+
with open(pr_cache) as ref:
302+
return json.load(ref)
303+
print(" Pull request cache %s for %s#%s not found." % (pr_cache, repo_name, pr_number))
304+
return {}
305+
306+
296307
def fill_notes_description(notes, repo_name, cmsprs, cache={}):
297308
new_notes = {}
298309
for log_line in notes.splitlines():
@@ -310,14 +321,10 @@ def fill_notes_description(notes, repo_name, cmsprs, cache={}):
310321
continue
311322
print("Checking ", pr_number, author, parent_hash)
312323
try:
313-
pr_md5 = md5((pr_number + "\n").encode()).hexdigest()
314-
pr_cache = join(cmsprs, repo_name, pr_md5[0:2], pr_md5[2:] + ".json")
315-
print("Checking cached file: " + pr_cache)
316-
if not exists(pr_cache):
317-
print(" Cache does not exists: ", pr_cache)
324+
pr = get_pr_data(repo_name, pr_number, cmsprs)
325+
if not pr:
318326
cache_invalid_pr(pr_hash_id, cache)
319327
continue
320-
pr = json.load(open(pr_cache))
321328
if not "auther_sha" in pr:
322329
print(" Invalid/Indirect PR", pr)
323330
cache_invalid_pr(pr_hash_id, cache)

report-summary-merged-prs.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pprint import pformat
1717

1818
from cmsutils import get_config_map_properties
19-
from github_utils import get_merge_prs
19+
from github_utils import get_merge_prs, get_pr_data
2020
from cms_static import GH_CMSSW_REPO, GH_CMSSW_ORGANIZATION
2121
from releases import CMSSW_DEVEL_BRANCH
2222
from socket import setdefaulttimeout
@@ -2043,6 +2043,31 @@ class PossibleUnitTestResults(object):
20432043
structure = identify_release_groups(results)
20442044
fix_results(results)
20452045

2046+
merged_pr_cache = {}
2047+
for rx in results:
2048+
for res in rx["comparisons"]:
2049+
if not res.get("release_queue", False):
2050+
continue
2051+
rel_que = "_".join(res.get("release_queue").split("_")[:3])
2052+
if not rel_que in merged_pr_cache:
2053+
merged_pr_cache[rel_que] = {"cmsdist": {}, "cmssw": {}}
2054+
prs = res.get("merged_prs", [])
2055+
for pr in prs:
2056+
merged_pr_cache[rel_que]["cmssw"][pr["number"]] = get_pr_data(
2057+
"cms-sw/cmssw", pr["number"], CMS_PRS
2058+
)
2059+
prs = res.get("cmsdist_merged_prs", {})
2060+
for arch in prs:
2061+
for pr in prs[arch]:
2062+
merged_pr_cache[rel_que]["cmsdist"][pr["number"]] = get_pr_data(
2063+
"cms-sw/cmsdist", pr["number"], CMS_PRS
2064+
)
2065+
2066+
for rel_que in merged_pr_cache:
2067+
out_json = open("prs/%s.json" % rel_que, "w")
2068+
json.dump(merged_pr_cache[rel_que], out_json, sort_keys=True, indent=4)
2069+
out_json.close()
2070+
20462071
prod_archs = get_production_archs(get_config_map_properties())
20472072
prod_ib_index = {}
20482073
for rx in results:

0 commit comments

Comments
 (0)