Skip to content

Commit

Permalink
Refactor to use bloaty
Browse files Browse the repository at this point in the history
  • Loading branch information
diondokter committed Apr 8, 2024
1 parent 4ccc7a0 commit 2f70562
Showing 1 changed file with 32 additions and 38 deletions.
70 changes: 32 additions & 38 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,48 +53,42 @@ jobs:
actions: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- run: rustup target add thumbv7em-none-eabihf
- run: rustup component add llvm-tools rust-src
- run: rustup component add rust-src

- name: Install cargo binutils
uses: taiki-e/cache-cargo-install-action@v1
- name: Check out the repo with the full git history
uses: actions/checkout@v3
with:
tool: cargo-binutils

- name: Calculate binary size
fetch-depth: '0'
- name: Build new binary
working-directory: ./example
run: |
mkdir ../binsizes
cargo size --release -- -A > ../binsizes/binsize_new.txt
- name: Rename binsize artifact
if: github.ref_name == 'master'
run: mv ./binsizes/binsize_new.txt ./binsizes/binsize_master.txt

- name: Store binsize artifact
if: github.ref_name == 'master'
uses: actions/upload-artifact@v4
with:
name: master-binsize
path: ./binsizes/*
overwrite: true

- name: Retrieve master binsize artifact
if: github.ref_name != 'master'
uses: actions/download-artifact@v4
run: cargo build --release
- name: Save binary
run: mv ./example/target/thumbv7em-none-eabihf/release/example ../original.elf
- name: If it's a PR checkout the base commit
if: ${{ github.event.pull_request }}
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Rebuild with the base commit
if: ${{ github.event.pull_request }}
working-directory: ./example
run: cargo build --release
- name: Run Bloaty to compare both output files
if: ${{ github.event.pull_request }}
id: bloaty-comparison
uses: carlosperate/bloaty-action@v1
with:
name: master-binsize
path: ./binsizes
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: "8599189897"

- name: Run diff
if: github.ref_name != 'master'
uses: LouisBrunner/[email protected]
bloaty-args: ../original.elf -- ./example/target/thumbv7em-none-eabihf/release/example
output-to-summary: true
- name: Add a PR comment with the bloaty diff
if: ${{ github.event.pull_request }}
continue-on-error: true
uses: actions/github-script@v6
with:
old: ./binsizes/binsize_master.txt
new: ./binsizes/binsize_new.txt
token: ${{ secrets.GITHUB_TOKEN }}
notify_issue: true
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## PR build size diff\n```\n${{ steps.bloaty-comparison.outputs.bloaty-output-encoded }}```\n'
})

0 comments on commit 2f70562

Please sign in to comment.