Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jul 4, 2023
1 parent 916846c commit ae3fcec
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions .github/workflows/check-binary-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,37 @@ jobs:
test:
name: Check binary size
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Print info
run: |
echo "Current SHA: ${{ github.sha }}"
echo "Base SHA: ${{ github.event.pull_request.base.sha }}"
- name: Clone Rustc
run: git clone https://github.com/rust-lang/rust --depth=1
- name: Create hello world crate
run: cargo new --bin /tmp/crate
- name: Build reference binary
run: |
cd rust
cp src/bootstrap/defaults/config.library.toml config.toml
cd library/backtrace
git fetch
git checkout ${{ github.event.pull_request.base.sha }}
cd ../..
python3 x.py build library --stage 0
./build/x86_64-unknown-linux-gnu/stage0/bin/rustc -O /tmp/crate/src/main.rs -o binary-reference
- name: Build current binary
run: |
cd library/backtrace
git checkout ${{ github.sha }}
cd ../..
python3 x.py build library --stage 0
./build/x86_64-unknown-linux-gnu/stage0/bin/rustc -O /tmp/crate/src/main.rs -o binary-updated
- name: Display binary size
run: |
ls -lha binary-*
- uses: actions/github-script@v6
env:
SIZE_REFERENCE: 1
SIZE_UPDATED: 10
with:
script: |
let reference = process.env.SIZE_REFERENCE;
let updated = process.env.SIZE_UPDATED;
let diff = updated - reference;
let diff_str = "";
if (diff > 0) {
diff_str = `+${diff}B`;
} else {
diff_str = `${diff}B`;
}
if (diff != 0) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Below is the size of a hello-world Rust program linked with libstd using backtrace.
Original binary size: **${reference}B**
Updated binary size: **${updated}B**
Difference: **${diff_str}**`
})
}

0 comments on commit ae3fcec

Please sign in to comment.