mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
d97953f101
* ci: Reduce chance of installing corrupt packages See: https://dev.to/hsbt/should-rubygemsbundler-have-a-cooldown-feature-40cp Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: prevent credential leakage from checkout steps Add `persist-credentials: false` to all `actions/checkout` calls across 22 workflow files. Without this, the GitHub token used for checkout is written into `.git/config` and remains accessible to all subsequent steps and any uploaded artifacts (artipacked finding). Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: prevent template injection from github context in run steps `${{ github.* }}` expressions used directly inside `run:` blocks are expanded before the shell sees them. A crafted value (e.g. a tag name containing shell metacharacters) would execute arbitrary code. Move the values into `env:` variables (e.g. GITHUB_EVENT_RELEASE_TAG_NAME, GITHUB_ACTOR) and reference them as `${VAR}` in the shell, so the runtime never interprets them as code (template-injection finding). Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: prevent injection in yq commands via release tag name `${{ github.event.release.tag_name }}` was interpolated directly into yq `cmd:` inputs. A crafted tag name could inject shell commands since the expression is expanded before the action runs. Use yq's `strenv()` with an `env:` variable instead so the value is always treated as data. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: pin all GitHub Actions to full commit SHAs Actions pinned to mutable tags (e.g. @v6, @main) can change under us if the upstream repo is compromised or tags are moved, enabling supply-chain attacks. Pinning to the full 40-char commit SHA locks the exact code that runs. Version tags are preserved as inline comments (e.g. # v6.0.2) for readability and Dependabot compatibility. Used `pinact` for standard tagged versions; remaining branch-based references (mikefarah/yq, jlumbroso/free-disk-space, project-stacker/stacker-build-push-action, aquasecurity/trivy-action) resolved manually via the GitHub API. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: slow down GitHub Actions dependency updates to biweekly Dependabot has no native biweekly interval. Combining weekly checks with a 14-day cooldown achieves the same effect: Dependabot scans every Monday but won't open a PR for a new action version until 14 days after release, giving the ecosystem time to stabilize before we adopt it. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: group all Dependabot updates into single PRs per ecosystem Without groups, Dependabot opens one PR per dependency. With `patterns: "*"`, all Go module bumps land in one PR and all GitHub Actions pin updates in another, reducing review noise. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: restore credential persistence for helm-charts push `persist-credentials: false` was too broad — the helm-charts checkout uses HELM_PUSH_TOKEN specifically so the subsequent `git push` can authenticate. Only the main repo checkout should have credentials disabled. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: use --password-stdin for oras login Passing the token via `-p` exposes it in process listings and debug logs. Piping via stdin is the standard secure pattern for CLI auth. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: pin actions to versioned release SHAs jmgilman/actions-generate-checksum: v1 branch HEAD -> v1.0.1 release mikefarah/yq: arbitrary master HEAD -> v4.52.5 release Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> --------- Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
99 lines
4.1 KiB
YAML
99 lines
4.1 KiB
YAML
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
|
with:
|
|
cache: false
|
|
check-latest: true
|
|
go-version: 1.25.x
|
|
- 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"
|
|
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zot-minimal binary size is not affected by PR" && exit 0
|
|
|
|
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
|
echo "zot minimal binary increased by $PERCENTAGE% comparing with main"; \
|
|
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
|
else \
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
|
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"
|
|
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zb binary size is not affected by PR" && exit 0
|
|
|
|
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
|
echo "zb binary increased by $PERCENTAGE% comparing with main"; \
|
|
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
|
else \
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
|
echo "zb binary decreased by $PERCENTAGE% comparing with main"; \
|
|
fi
|
|
- 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")
|
|
|
|
echo "Building zli on main branch and check size"
|
|
cd zot_main
|
|
make cli
|
|
BINSIZE_MAIN=$(stat -c%s "bin/zli-linux-amd64")
|
|
|
|
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
|
|
|
|
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
|
echo "zli binary increased by $PERCENTAGE% comparing with main"; \
|
|
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
|
else \
|
|
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
|
echo "zli binary decreased by $PERCENTAGE% comparing with main"; \
|
|
fi
|