Skip to content

fail if compiled size of breakout example in release increase by more than 0.5% #20289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/validation-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,86 @@ jobs:
exit $CODE
- name: Build with patches
run: cargo build

compile-for-size-on-base:
if: ${{ github.event_name == 'merge_group' }}
runs-on: macos-latest
timeout-minutes: 30
outputs:
size: ${{ steps.size.outputs.SIZE }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.merge_group.base_ref }}
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache/restore@v4
with:
# key won't match, will rely on restore-keys
key: ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
# See .github/workflows/validation-jobs.yml for how keys are generated
restore-keys: |
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-stable--
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- name: Build
run: cargo build --release --example breakout
- name: Get bin size
id: size
run: |
size=$(du -k target/release/examples/breakout | cut -f1)
echo "SIZE=$size" >> "$GITHUB_OUTPUT"

compile-for-size-on-head:
if: ${{ github.event_name == 'merge_group' }}
runs-on: macos-latest
timeout-minutes: 30
outputs:
size: ${{ steps.size.outputs.SIZE }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.merge_group.head_ref }}
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache/restore@v4
with:
# key won't match, will rely on restore-keys
key: ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
# See .github/workflows/validation-jobs.yml for how keys are generated
restore-keys: |
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-stable--
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- name: Build
run: cargo build --release --example breakout
- name: Get bin size
id: size
run: |
size=$(du -k target/release/examples/breakout | cut -f1)
echo "SIZE=$size" >> "$GITHUB_OUTPUT"

compare-compiled-size:
if: ${{ github.event_name == 'merge_group' }}
runs-on: macos-latest
timeout-minutes: 30
needs: ["compile-for-size-on-base", "compile-for-size-on-head"]
steps:
- name: Compare
run: |
before=${{ needs.compile-for-size-on-base.outputs.size }}
after=${{ needs.compile-for-size-on-head.outputs.size }}

echo "Before: $before"
echo "After: $after"

# Allowing a 0.5% increase
[ $after -lt $(( before * 1005 / 1000 )) ] || exit 1
Loading