2023-09-13 02:28:14 -05:00
|
|
|
name: "Check binary size increase"
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
permissions: read-all
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
compare-binary-sizes:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: compare-with-main
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2023-12-12 05:44:28 -05:00
|
|
|
- uses: actions/setup-go@v5
|
2023-09-13 02:28:14 -05:00
|
|
|
with:
|
|
|
|
cache: false
|
2024-11-08 11:58:55 -05:00
|
|
|
go-version: 1.23.x
|
2023-09-13 02:28:14 -05:00
|
|
|
- name: Checkout zot (main branch)
|
|
|
|
run: |
|
|
|
|
mkdir -p $GITHUB_WORKSPACE/zot_main
|
|
|
|
git clone https://github.com/project-zot/zot zot_main/
|
|
|
|
- name: Check if zot-minimal binary increased with more than 1%
|
|
|
|
run: |
|
|
|
|
echo "Building zot-minimal and check size"
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
make binary-minimal
|
|
|
|
BINSIZE=$(stat -c%s "bin/zot-linux-amd64-minimal")
|
|
|
|
|
|
|
|
echo "Building zot-minimal on main branch and check size"
|
|
|
|
cd zot_main
|
|
|
|
make binary-minimal
|
|
|
|
BINSIZE_MAIN=$(stat -c%s "bin/zot-linux-amd64-minimal")
|
|
|
|
|
|
|
|
echo "PR binary size: $BINSIZE Bytes"
|
|
|
|
echo "main branch binary size: $BINSIZE_MAIN Bytes"
|
2023-09-15 17:17:01 -05:00
|
|
|
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zot-minimal binary size is not affected by PR" && exit 0
|
2023-09-13 02:28:14 -05:00
|
|
|
|
|
|
|
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
2023-09-28 13:59:52 -05:00
|
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
2023-09-13 02:28:14 -05:00
|
|
|
echo "zot minimal binary increased by $PERCENTAGE% comparing with main"; \
|
|
|
|
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
|
|
|
else \
|
2023-09-28 13:59:52 -05:00
|
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
2023-09-13 02:28:14 -05:00
|
|
|
echo "zot minimal binary decreased by $PERCENTAGE% comparing with main"; \
|
|
|
|
fi
|
|
|
|
- if: always()
|
|
|
|
name: Check if zb binary increased with more than 1%
|
|
|
|
run: |
|
|
|
|
echo "Building zb and check size"
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
make bench
|
|
|
|
BINSIZE=$(stat -c%s "bin/zb-linux-amd64")
|
|
|
|
|
|
|
|
echo "Building zb on main branch and check size"
|
|
|
|
cd zot_main
|
|
|
|
make bench
|
|
|
|
BINSIZE_MAIN=$(stat -c%s "bin/zb-linux-amd64")
|
|
|
|
|
|
|
|
echo "PR binary size: $BINSIZE Bytes"
|
|
|
|
echo "main branch binary size: $BINSIZE_MAIN Bytes"
|
2023-09-15 17:17:01 -05:00
|
|
|
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zb binary size is not affected by PR" && exit 0
|
2023-09-13 02:28:14 -05:00
|
|
|
|
|
|
|
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
2023-09-28 13:59:52 -05:00
|
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
2023-09-13 02:28:14 -05:00
|
|
|
echo "zb binary increased by $PERCENTAGE% comparing with main"; \
|
|
|
|
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
|
|
|
else \
|
2023-09-28 13:59:52 -05:00
|
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
2023-09-13 02:28:14 -05:00
|
|
|
echo "zb binary decreased by $PERCENTAGE% comparing with main"; \
|
|
|
|
fi
|
2023-09-15 17:17:01 -05:00
|
|
|
- if: always()
|
|
|
|
name: Check if zli binary increased with more than 1%
|
|
|
|
run: |
|
|
|
|
echo "Building zli and check size"
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
make cli
|
|
|
|
BINSIZE=$(stat -c%s "bin/zli-linux-amd64")
|
2023-09-13 02:28:14 -05:00
|
|
|
|
2023-09-15 17:17:01 -05:00
|
|
|
echo "Building zli on main branch and check size"
|
|
|
|
cd zot_main
|
|
|
|
make cli
|
|
|
|
BINSIZE_MAIN=$(stat -c%s "bin/zli-linux-amd64")
|
2023-09-13 02:28:14 -05:00
|
|
|
|
2023-09-15 17:17:01 -05:00
|
|
|
echo "PR binary size: $BINSIZE Bytes"
|
|
|
|
echo "main branch binary size: $BINSIZE_MAIN Bytes"
|
|
|
|
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zli binary size is not affected by PR" && exit 0
|
2023-09-13 02:28:14 -05:00
|
|
|
|
2023-09-15 17:17:01 -05:00
|
|
|
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
2023-09-28 13:59:52 -05:00
|
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
2023-09-15 17:17:01 -05:00
|
|
|
echo "zli binary increased by $PERCENTAGE% comparing with main"; \
|
|
|
|
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
|
|
|
else \
|
2023-09-28 13:59:52 -05:00
|
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
2023-09-15 17:17:01 -05:00
|
|
|
echo "zli binary decreased by $PERCENTAGE% comparing with main"; \
|
|
|
|
fi
|