refactor: Reduce binary size of zot-minimal; Added CI check for binary size (#1758)

Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
Alexei Dodon
2023-09-06 19:58:00 +03:00
committed by GitHub
parent 75a76005b4
commit f5b63963be
18 changed files with 134 additions and 83 deletions
+1 -7
View File
@@ -12,10 +12,6 @@ permissions: read-all
jobs:
branch-cov:
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux]
arch: [amd64]
name: coverage
steps:
- uses: actions/checkout@v4
@@ -42,6 +38,4 @@ jobs:
gobco -test '-tags=sync,search,scrub,metrics,containers_image_openpgp' $i;
gobco -test '-tags=minimal,containers_image_openpgp' $i;
done
env:
OS: ${{ matrix.os }}
ARCH: ${{ matrix.arch }}
+2 -2
View File
@@ -113,10 +113,10 @@ jobs:
echo "Building for $OS:$ARCH"
cd $GITHUB_WORKSPACE
if [[ $OS == "linux" && $ARCH == "amd64" ]]; then
make OS=$OS ARCH=$ARCH
make
sudo env "PATH=$PATH" make privileged-test
else
make OS=$OS ARCH=$ARCH binary binary-minimal binary-debug cli bench exporter-minimal
make binary binary-minimal binary-debug cli bench exporter-minimal
fi
env:
S3MOCK_ENDPOINT: localhost:4566
-1
View File
@@ -4,7 +4,6 @@ on:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
+2 -9
View File
@@ -12,10 +12,6 @@ permissions: read-all
jobs:
tls-check:
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux]
arch: [amd64]
name: TLS check
steps:
- uses: actions/checkout@v4
@@ -36,8 +32,8 @@ jobs:
continue-on-error: true
run: |
cd $GITHUB_WORKSPACE
make OS=$OS ARCH=$ARCH binary
bin/zot-$OS-$ARCH serve examples/config-tls.json &
make binary
bin/zot-linux-amd64 serve examples/config-tls.json &
sleep 5
curl -kv --tls-max 1.0 -0 https://localhost:8080/v2/
if [[ "$?" -eq 0 ]]; then echo "TLSv1.0 detected"; exit 1; fi
@@ -45,6 +41,3 @@ jobs:
if [[ "$?" -eq 0 ]]; then echo "TLSv1.1 detected"; exit 1; fi
curl -kv --tls-max 1.2 -0 https://localhost:8080/v2/
if [[ "$?" -ne 0 ]]; then echo "TLSv1.2 missing"; exit 1; fi
env:
OS: ${{ matrix.os }}
ARCH: ${{ matrix.arch }}
+40
View File
@@ -0,0 +1,40 @@
name: "zot minimal binary size"
on:
pull_request:
branches: [main]
permissions: read-all
jobs:
zot-minimal-size:
runs-on: ubuntu-latest
name: compare-binary-size
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.20.x
- 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"
mkdir -p zot_main
git clone https://github.com/project-zot/zot zot_main/
cd zot_main
make binary-minimal
BINSIZE_MAIN=$(stat -c%s "bin/zot-linux-amd64-minimal")
cd $GITHUB_WORKSPACE && rm -rf zot_main
[[ $BINSIZE -gt $BINSIZE_MAIN ]] || exit 0
echo "PR changes increased size of zot-minimal binary"
echo "PR binary size: $BINSIZE Bytes"
echo "main branch binary size: $BINSIZE_MAIN Bytes"
PERCENTACE=$(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)
if ((`bc <<< "$PERCENTACE>=1.0"`)); then echo "zot minimal binary increased by $PERCENTACE% comparing with main"; exit 1; fi