Skip to content

Commit d9e5bb4

Browse files
committed
ci: produce per-binary size comment artifact in make.yml
Replace the inline shell loop that walked individual-size-result.json with a call to util/compare_size_results.py and write its output, plus the PR number, into a size-comment/ directory uploaded as an artifact. The aggregate `multiple binaries` and `multicall binary` checks remain inline since they are simple scalar comparisons. The new artifact is consumed by the SizeComment workflow to post a PR comment, mirroring the GnuTests / GnuComment pipeline.
1 parent 9dfc729 commit d9e5bb4

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

.github/workflows/make.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,33 @@ jobs:
214214
name: size-result
215215
repo: uutils/coreutils
216216
path: dl
217-
- name: Check uutil release sizes
217+
- name: Compare individual binary sizes VS reference
218218
shell: bash
219219
run: |
220+
## Produce a per-binary size comparison and a PR comment body.
221+
## The comment body is consumed by the SizeComment workflow, which
222+
## mirrors GnuComment for the GNU testsuite results.
223+
COMMENT_DIR="size-comment"
224+
mkdir -p "${COMMENT_DIR}"
225+
# `github.event.number` is empty on non-PR events; the downstream
226+
# workflow only posts comments when triggered for a pull request.
227+
echo "${{ github.event.number }}" > "${COMMENT_DIR}/NR"
228+
COMMENT_LOG="${COMMENT_DIR}/result.txt"
229+
230+
if test -f dl/individual-size-result.json; then
231+
python3 util/compare_size_results.py \
232+
individual-size-result.json \
233+
dl/individual-size-result.json \
234+
--output "${COMMENT_LOG}"
235+
else
236+
echo "::warning ::Skipping individual size comparison; no reference is available."
237+
fi
238+
- name: Check uutil release multi-binary sizes
239+
shell: bash
240+
run: |
241+
## The aggregate `multiple binaries` and `multicall binary` totals
242+
## are still checked inline; they are simple scalar comparisons and
243+
## do not feed into the per-binary PR comment.
220244
check() {
221245
# Warn if the size increases by more than 5%
222246
threshold='1.05'
@@ -232,18 +256,19 @@ jobs:
232256
echo "::warning file=$4::Size of $1 increases by more than 5%"
233257
fi
234258
}
235-
## Check individual size result
236-
while read -r name previous_size; do
237-
size=$(cat individual-size-result.json | jq -r ".[] | .sizes | .\"$name\"")
238-
check "\`$name\` binary" "$size" "$previous_size" 'individual-size-result.json'
239-
done < <(cat dl/individual-size-result.json | jq -r '.[] | .sizes | to_entries[] | "\(.key) \(.value)"')
240259
## Check size result
241260
size=$(cat size-result.json | jq -r '.[] | .size')
242261
previous_size=$(cat dl/size-result.json | jq -r '.[] | .size')
243262
check 'multiple binaries' "$size" "$previous_size" 'size-result.json'
244263
multisize=$(cat size-result.json | jq -r '.[] | .multisize')
245264
previous_multisize=$(cat dl/size-result.json | jq -r '.[] | .multisize')
246265
check 'multicall binary' "$multisize" "$previous_multisize" 'size-result.json'
266+
- name: Upload size comparison comment (for SizeComment workflow)
267+
if: success() || failure() # run regardless of prior step success/failure
268+
uses: actions/upload-artifact@v7
269+
with:
270+
name: size-comment
271+
path: size-comment/
247272
- name: Upload the individual size result
248273
uses: actions/upload-artifact@v7
249274
with:

0 commit comments

Comments
 (0)