From b47a26c51c86ace65fe9de446433ecff2a044fb6 Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Mon, 17 Apr 2023 14:24:57 +0800 Subject: [PATCH] CI: warn if the size of the binary increases by more than 5% --- .github/workflows/CICD.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index add337f661f..e13f1774a22 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -591,6 +591,44 @@ jobs: --arg size "$SIZE" \ --arg multisize "$SIZE_MULTI" \ '{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json + - name: Download the previous individual size result + uses: dawidd6/action-download-artifact@v2 + with: + workflow: CICD.yml + name: individual-size-result + repo: uutils/coreutils + path: dl + - name: Download the previous size result + uses: dawidd6/action-download-artifact@v2 + with: + workflow: CICD.yml + name: size-result + repo: uutils/coreutils + path: dl + - name: Check uutil release sizes + shell: bash + run: | + check() { + # Warn if the size increases by more than 5% + threshold='1.05' + ratio=$(jq -n "$2 / $3") + echo "$1: size=$2, previous_size=$3, ratio=$ratio, threshold=$threshold" + if [[ "$(jq -n "$ratio > $threshold")" == 'true' ]]; then + echo "::warning file=$4::Size of $1 increases by more than 5%" + fi + } + ## Check individual size result + while read -r name previous_size; do + size=$(cat individual-size-result.json | jq -r ".[] | .sizes | .\"$name\"") + check "\`$name\` binary" "$size" "$previous_size" 'individual-size-result.json' + done < <(cat dl/individual-size-result.json | jq -r '.[] | .sizes | to_entries[] | "\(.key) \(.value)"') + ## Check size result + size=$(cat size-result.json | jq -r '.[] | .size') + previous_size=$(cat dl/size-result.json | jq -r '.[] | .size') + check 'multiple binaries' "$size" "$previous_size" 'size-result.json' + multisize=$(cat size-result.json | jq -r '.[] | .multisize') + previous_multisize=$(cat dl/size-result.json | jq -r '.[] | .multisize') + check 'multicall binary' "$multisize" "$previous_multisize" 'size-result.json' - name: Upload the individual size result uses: actions/upload-artifact@v3 with: