Skip to content

Commit 84ffa92

Browse files
committed
bundle size delta
1 parent 12e5fce commit 84ffa92

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,39 @@ jobs:
115115
uses: actions/checkout@v3
116116
- name: Run shellcheck
117117
uses: ludeeus/[email protected]
118+
bundle-size:
119+
runs-on: ubuntu-latest
120+
steps:
121+
- name: Checking out
122+
uses: actions/checkout@v3
123+
- name: Install Rust toolchain
124+
uses: ./.github/actions/rust-cargo-run
125+
with:
126+
command: version
127+
github_token: ${{ secrets.GITHUB_TOKEN }}
128+
save_cache: true
129+
- name: Show bundle delta summary
130+
id: bundle-summary
131+
run: |
132+
echo 'bundle-summary<<EOF' >> $GITHUB_ENV
133+
make bundle-size | tail -n3 >> $GITHUB_ENV
134+
echo 'EOF' >> $GITHUB_ENV
135+
136+
- name: Find Comment
137+
uses: peter-evans/find-comment@v2
138+
id: fc
139+
with:
140+
issue-number: ${{ github.event.pull_request.number }}
141+
comment-author: 'github-actions[bot]'
142+
body-regex: "^### WASM bundle summary"
143+
- name: Create or update comment
144+
uses: peter-evans/create-or-update-comment@v2
145+
with:
146+
comment-id: ${{ steps.fc.outputs.comment-id }}
147+
issue-number: ${{ github.event.pull_request.number }}
148+
body: |
149+
### WASM bundle summary 📦
150+
```
151+
${{ env.bundle-summary }}
152+
```
153+
edit-mode: replace
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Update WASM bundle size
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
# Check if the bundle size was committed and is up-to-date
9+
jobs:
10+
bundle-size:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checking out
14+
uses: actions/checkout@v3
15+
with:
16+
ref: ${{ github.head_ref }}
17+
fetch-depth: 0
18+
- name: Install Rust toolchain
19+
uses: ./.github/actions/rust-cargo-run
20+
with:
21+
command: version
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
save_cache: true
24+
- name: Update bundle size
25+
run: |
26+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
27+
git config --local user.name "github-actions[bot]"
28+
make bundle-size
29+
git add bundle-size
30+
git commit -m "[skip ci] update bundle-size" || true
31+
- name: Push changes
32+
uses: ad-m/github-push-action@master
33+
with:
34+
github_token: ${{ secrets.GITHUB_TOKEN }}
35+
branch: ${{ github.head_ref }}

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ publish:
4242

4343
# Create a bundle in a deterministic location
4444
bundle: deps-build
45-
cargo run -- -o output/builtin-actors.car
45+
cargo run --locked -- -o output/builtin-actors.car
46+
47+
# Update the bundle size file
48+
bundle-size: bundle
49+
@bash scripts/update-bundle-size.sh $@ output/builtin-actors.car
4650

4751
# Create all canonical network bundles
4852
all-bundles: bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-testing
@@ -66,7 +70,8 @@ bundle-testing: deps-build
6670
BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car
6771
BUILD_FIL_NETWORK=testing-fake-proofs cargo run -- -o output/builtin-actors-testing-fake-proofs.car
6872

69-
.PHONY: all-bundles bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing
73+
74+
.PHONY: all-bundles bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-size
7075

7176
# Check if the working tree is clean.
7277
check-clean:

bundle-size

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6030520

scripts/update-bundle-size.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# Checks and updates bundle size file, printing delta between the previous and current bundle size.
3+
4+
# Check if the user provided both arguments
5+
if [ $# -ne 2 ]; then
6+
echo "Usage: ./update-bundle-size.sh <bundle-size-path> <bundle-path>"
7+
exit 1
8+
fi
9+
10+
# Check if paths exist
11+
if [[ ! -f $1 || ! -f $2 ]]; then
12+
echo "Invalid arguments. Please check that the files exist."
13+
exit 1
14+
fi
15+
16+
bundle_size_path=$1
17+
bundle_path=$2
18+
19+
# Grab the current bundle size
20+
size_old=$(head -n 1 "$bundle_size_path")
21+
22+
# Update bundle size
23+
wc -c < "$bundle_path" > "$bundle_size_path"
24+
25+
# Grab the new bundle size
26+
size_new=$(head -n 1 "$bundle_size_path")
27+
28+
# Calculate the difference
29+
diff=$((size_new - size_old))
30+
31+
# Print stats
32+
echo "Old bundle size: $size_old"
33+
echo "New bundle size: $size_new"
34+
echo "Delta: $diff bytes"

0 commit comments

Comments
 (0)