Workflow for cargo bloat (#462)
* adds cargo bloat workflow * uses notice instead * warning for bigger sizes, ignore equal sizes * DO NOT MERGE, TEST COMMIT * reverted test commit
This commit is contained in:
46
.github/workflows/bloat_formatter.sh
vendored
Executable file
46
.github/workflows/bloat_formatter.sh
vendored
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright 2022 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
# New output file is $1
|
||||||
|
# Old output file is $2
|
||||||
|
TMP=comment.md
|
||||||
|
WARNING="Note: numbers above are a result of guesswork. They are not 100% correct and never will be."
|
||||||
|
NEW_SIZE=$(cat "$1" | sed -nr 's/.*100.0% (.*)KiB .text.*/\1/p')
|
||||||
|
OLD_SIZE=$(cat "$2" | sed -nr 's/.*100.0% (.*)KiB .text.*/\1/p')
|
||||||
|
|
||||||
|
echo "
|
||||||
|
OLD $OLD_SIZE kiB
|
||||||
|
NEW $NEW_SIZE kiB" > "$TMP"
|
||||||
|
|
||||||
|
echo "
|
||||||
|
Output of cargo bloat
|
||||||
|
======================
|
||||||
|
" >> "$TMP"
|
||||||
|
|
||||||
|
echo "Including PR" >> "$TMP"
|
||||||
|
cat "$1" >> "$TMP"
|
||||||
|
echo "Base branch" >> "$TMP"
|
||||||
|
cat "$2" >> "$TMP"
|
||||||
|
|
||||||
|
COMMENT="$(cat $TMP | sed "s/$WARNING//g" | sed 's/%/%25/g' | sed -z 's/\n/%0A/g')"
|
||||||
|
# No output for equality is intentional.
|
||||||
|
if (( $(echo "$NEW_SIZE > $OLD_SIZE" | bc -l) )); then
|
||||||
|
echo "::warning file=.github/workflows/cargo_bloat.yml,title=Binary size::$COMMENT"
|
||||||
|
fi
|
||||||
|
if (( $(echo "$NEW_SIZE < $OLD_SIZE" | bc -l) )); then
|
||||||
|
echo "::notice file=.github/workflows/cargo_bloat.yml,title=Binary size::$COMMENT"
|
||||||
|
fi
|
||||||
47
.github/workflows/cargo_bloat.yml
vendored
Normal file
47
.github/workflows/cargo_bloat.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
name: Binary size report
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cargo_bloat:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Setup
|
||||||
|
- uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.7
|
||||||
|
- name: Install Python dependencies
|
||||||
|
run: python -m pip install --upgrade pip setuptools wheel
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: install
|
||||||
|
args: cargo-bloat
|
||||||
|
|
||||||
|
# First run: PR
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
run: rustup show
|
||||||
|
- name: Set up OpenSK
|
||||||
|
run: ./setup.sh
|
||||||
|
- name: Run bloat on the PR
|
||||||
|
run: RUSTFLAGS="-C link-arg=-icf=all -C force-frame-pointers=no" cargo bloat --release --target=thumbv7em-none-eabi --features=with_ctap1,vendor_hid --crates >> .github/workflows/bloat_output_new.txt
|
||||||
|
|
||||||
|
# Second run: PR
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
ref: ${{ github.base_ref }}
|
||||||
|
path: OpenSK_base
|
||||||
|
- name: Install old Rust toolchain
|
||||||
|
working-directory: ./OpenSK_base
|
||||||
|
run: rustup show
|
||||||
|
- name: Set up OpenSK
|
||||||
|
working-directory: ./OpenSK_base
|
||||||
|
run: ./setup.sh
|
||||||
|
- name: Run bloat on base
|
||||||
|
working-directory: ./OpenSK_base
|
||||||
|
run: RUSTFLAGS="-C link-arg=-icf=all -C force-frame-pointers=no" cargo bloat --release --target=thumbv7em-none-eabi --features=with_ctap1,vendor_hid --crates >> "$GITHUB_WORKSPACE/.github/workflows/bloat_output_old.txt"
|
||||||
|
|
||||||
|
- name: Run output formatter to echo workflow command
|
||||||
|
run: ./.github/workflows/bloat_formatter.sh bloat_output_new.txt bloat_output_old.txt bloat_comment.md
|
||||||
Reference in New Issue
Block a user