Skip to content

Commit 4742370

Browse files
kpschoedelpull[bot]
authored andcommitted
[Size reports] Script improvements (3/3) (#12993)
#### Problem Recent memory size investigations suggest some improvements: - Scripts use PR==0 to distinguish pull requests from master commits (push events), but it would be useful to record the associated PR along with commits. - Sometimes push events run on pull requests, and those are not currently distinguishable from master push events. - Sorting by build timestamp is inaccurate, since CI runs may finish in a different order than the commits. #### Change overview This is the third of three steps. The first step (#12886) added `event` and `ref` handling, and the second (#12947) added the `event` to artifact names. This step adds the PR number for pushes to master, extracted from the commit message. #### Testing Manually checked offline, but final confirmation requires live CI.
1 parent 56b38a7 commit 4742370

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/tools/memory/gh_sizes_environment.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@
5959
parent = github['event']['before']
6060
timestamp = dateutil.parser.isoparse(
6161
github['event']['head_commit']['timestamp']).timestamp()
62-
pr = 0
62+
63+
# Try to find the PR being committed by scraping the commit message.
64+
m = re.search(r'\(#(\d+)\)', github['event']['head_commit']['message'])
65+
if m:
66+
pr = m.group(1)
67+
else:
68+
pr = 0
6369

6470
# Environment variables for subsequent workflow steps are set by
6571
# writing to the file named by `$GITHUB_ENV`.

0 commit comments

Comments
 (0)