diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b03597148f..dd3cc02e31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,6 +107,27 @@ jobs: uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: files: lcov.info + # Check if the bundle size was committed and is up-to-date + bundle-size: + runs-on: ubuntu-latest + steps: + - name: Checking out + uses: actions/checkout@v2 + - name: Install Rust toolchain + uses: ./.github/actions/rust-cargo-run + with: + command: version + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Update bundle size + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + make bundle-size + git commit -a -m "update bundle-size" + - name: Push changes + uses: ad-m/github-push-action@master + with: + branch: ${{ github.head_ref }} # Lint shell scripts shellcheck: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index db5a24dee7..5db4a94b42 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,11 @@ publish: # Create a bundle in a deterministic location bundle: deps-build - cargo run -- -o output/builtin-actors.car + cargo run --locked -- -o output/builtin-actors.car + +# Update the bundle size file +bundle-size: bundle + @bash scripts/update-bundle-size.sh $@ output/builtin-actors.car # Create all canonical network bundles all-bundles: bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-testing @@ -66,7 +70,8 @@ bundle-testing: deps-build BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car BUILD_FIL_NETWORK=testing-fake-proofs cargo run -- -o output/builtin-actors-testing-fake-proofs.car -.PHONY: all-bundles bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing + +.PHONY: all-bundles bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-size # Check if the working tree is clean. check-clean: diff --git a/bundle-size b/bundle-size new file mode 100644 index 0000000000..3d6b9e019e --- /dev/null +++ b/bundle-size @@ -0,0 +1 @@ +6033975 diff --git a/scripts/update-bundle-size.sh b/scripts/update-bundle-size.sh new file mode 100644 index 0000000000..1adb52cc1d --- /dev/null +++ b/scripts/update-bundle-size.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Checks and updates bundle size file, printing delta between the previous and current bundle size. + +# Check if the user provided both arguments +if [ $# -ne 2 ]; then + echo "Usage: ./update-bundle-size.sh " + exit 1 +fi + +# Check if paths exist +if [[ ! -f $1 || ! -f $2 ]]; then + echo "Invalid arguments. Please check that the files exist." + exit 1 +fi + +bundle_size_path=$1 +bundle_path=$2 + +# Grab the current bundle size +size_old=$(head -n 1 "$bundle_size_path") + +# Update bundle size +wc -c < "$bundle_path" > "$bundle_size_path" + +# Grab the new bundle size +size_new=$(head -n 1 "$bundle_size_path") + +# Calculate the difference +diff=$((size_new - size_old)) + +# Print stats +echo "Old bundle size: $size_old" +echo "New bundle size: $size_new" +echo "Delta: $diff bytes"