[CI] Add workflow to guard against increases in the binary size #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Binaries bundle size | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }} | |
cancel-in-progress: true | |
# See https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions | |
permissions: | |
contents: read | |
jobs: | |
build-and-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
with: | |
submodules: true | |
- name: Fetch git tags | |
run: | | |
git fetch --prune --unshallow --tags | |
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version: 1.23.x | |
- name: Setup Node.js version | |
uses: ./.github/actions/setup-node.js | |
- name: Install tools | |
run: make install-ci | |
- name: Build jaeger binary | |
run: | | |
export GOOS=linux | |
export GOARCH=amd64 | |
make build-jaeger | |
- name: Calculate bundle size | |
run: | | |
TOTAL_SIZE=$(du -sb ./cmd/jaeger/jaeger-linux-amd64 | cut -f1) | |
echo "$TOTAL_SIZE" > ./new_bundle_size.txt | |
echo "Total bundle size: $TOTAL_SIZE bytes" | |
- name: Restore previous bundle size | |
id: cache-bundle-size | |
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 #v4.2.0 | |
with: | |
path: ./bundle_size.txt | |
key: bundle-size-jaeger-linux-amd64 | |
- name: Compare bundle sizes | |
run: | | |
if [ -f ./bundle_size.txt ]; then | |
OLD_BUNDLE_SIZE=$(cat ./bundle_size.txt) | |
NEW_BUNDLE_SIZE=$(cat ./new_bundle_size.txt) | |
echo "Previous bundle size: $OLD_BUNDLE_SIZE bytes" | |
echo "New bundle size: $NEW_BUNDLE_SIZE bytes" | |
SIZE_CHANGE=$(( $NEW_BUNDLE_SIZE - $OLD_BUNDLE_SIZE )) | |
PERCENTAGE_CHANGE=$(( SIZE_CHANGE * 100 / $OLD_BUNDLE_SIZE )) | |
echo "Size change: $PERCENTAGE_CHANGE%" | |
if [ $PERCENTAGE_CHANGE -gt 2 ]; then | |
echo "❌ Bundle size increased by more than 2% ($PERCENTAGE_CHANGE%)" | |
exit 1 | |
else | |
echo "✅ Bundle size change is within acceptable range ($PERCENTAGE_CHANGE%)" | |
fi | |
else | |
echo "No previous bundle size found. This will be the baseline." | |
fi | |
- name: Remove previous *_bundle_*.txt | |
run: | | |
rm -rf ./bundle_size.txt | |
mv ./new_bundle_size.txt ./bundle_size.txt | |
- name: Save new bundle size | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 #v4.2.0 | |
with: | |
path: ./bundle_size.txt | |
key: bundle-size-jaeger-${{ matrix.os }}-${{ matrix.arch }} |