3333 - name : CI
3434 run : |
3535 ./ci.sh
36+ # Check binary-size, stolen from https://github.com/tweedegolf/sequential-storage/blob/master/.github/workflows/ci.yaml
37+ binary-size :
38+ runs-on : ubuntu-latest
39+ permissions :
40+ actions : read
41+ pull-requests : write
42+ steps :
43+ - uses : dtolnay/rust-toolchain@nightly
44+ - uses : actions/cache@v3
45+ id : cache-cargo
46+ with :
47+ path : |
48+ ~/.cargo/bin/
49+ ~/.cargo/registry/index/
50+ ~/.cargo/registry/cache/
51+ ~/.cargo/git/db/
52+ ./example/nrf-sdc/target/
53+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
54+
55+ - run : rustup target add thumbv7em-none-eabihf
56+ - run : rustup component add rust-src llvm-tools
57+ - if : steps.cache-cargo.outputs.cache-hit != 'true'
58+ run : cargo install cargo-binutils
59+
60+ - name : Check out the repo with the full git history
61+ uses : actions/checkout@v3
62+ with :
63+ fetch-depth : ' 0'
64+ - name : Build new binary
65+ working-directory : ./example/nrf-sdc
66+ run : |
67+ echo 'RESULT<<EOF' >> $GITHUB_OUTPUT
68+ cargo size --release --features nrf52840 --bin ble_bas_peripheral >> $GITHUB_OUTPUT
69+ echo 'EOF' >> $GITHUB_OUTPUT
70+ id : new-size
71+ - name : Save binary
72+ run : |
73+ mv ./example/nrf-sdc/target/thumbv7em-none-eabihf/release/example ./example/nrf-sdc/target/thumbv7em-none-eabihf/release/original.elf
74+ - name : If it's a PR checkout the base commit
75+ if : ${{ github.event.pull_request }}
76+ run : git checkout ${{ github.event.pull_request.base.sha }}
77+ - name : Rebuild with the base commit
78+ if : ${{ github.event.pull_request }}
79+ working-directory : ./example/nrf-sdc
80+ run : cargo build --release --features nrf52840 --bin ble_bas_peripheral
81+ - name : Run Bloaty to compare both output files
82+ if : ${{ github.event.pull_request }}
83+ id : bloaty-comparison
84+ uses : carlosperate/bloaty-action@v1
85+ with :
86+ bloaty-args : ./example/nrf-sdc/target/thumbv7em-none-eabihf/release/original.elf -- ./example/nrf-sdc/target/thumbv7em-none-eabihf/release/example
87+ output-to-summary : true
88+ - name : Add a PR comment with the bloaty diff
89+ if : ${{ github.event.pull_request }}
90+ continue-on-error : true
91+ uses : actions/github-script@v7
92+ with :
93+ script : |
94+ github.rest.issues.createComment({
95+ issue_number: context.issue.number,
96+ owner: context.repo.owner,
97+ repo: context.repo.repo,
98+ body: `## PR build size\n \`\`\`\n${{ join(steps.new-size.outputs.*, '\n') }}\n\`\`\`\n ### Diff\n\`\`\`\n${{ steps.bloaty-comparison.outputs.bloaty-output-encoded }}\`\`\`\n`
99+ })
0 commit comments