mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 20:07:55 +08:00
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:
@@ -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 }}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,6 @@ on:
|
||||
tags:
|
||||
- v*
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
permissions:
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user