Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle size delta #937

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,49 @@ jobs:
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
files: lcov.info
# Lint shell scripts
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run shellcheck
uses: ludeeus/[email protected]
# Show WASM bundle size summary as a message in the pull request
bundle-size:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Checking out
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: ./.github/actions/rust-cargo-run
with:
command: version
github_token: ${{ secrets.GITHUB_TOKEN }}
save_cache: true
- name: Generate bundle delta summary
id: bundle-summary
run: |
echo 'bundle-summary<<EOF' >> $GITHUB_ENV
make bundle-size | tail -n3 >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# Find a relevant comment from GH bot to update if there is one
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-regex: "^### WASM bundle summary"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### WASM bundle summary 📦
```
${{ env.bundle-summary }}
```
edit-mode: replace
36 changes: 36 additions & 0 deletions .github/workflows/update-bundle-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update WASM bundle size

on:
push:
branches:
- master

# Updates the `bundle-size` on the master branch, pushes a commit from the Github
# bot (doesn't trigger the CI thanks to the magic message)
jobs:
bundle-size:
runs-on: ubuntu-latest
steps:
- name: Checking out
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Install Rust toolchain
uses: ./.github/actions/rust-cargo-run
with:
command: version
github_token: ${{ secrets.GITHUB_TOKEN }}
save_cache: true
- 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 add bundle-size
git commit -m "[skip ci] update bundle-size" || true
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ set-version: check-clean deps-release check
publish:
cargo workspaces publish --from-git

# Create a bundle in a deterministic location
# Update the bundle size file, print the summary
bundle-size: bundle
@bash scripts/update-bundle-size.sh $@ output/builtin-actors.car

bundle:
cargo run -- -o output/builtin-actors.car

Expand All @@ -61,7 +64,8 @@ bundle-testing:
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:
Expand Down
1 change: 1 addition & 0 deletions bundle-size
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6030519
12 changes: 6 additions & 6 deletions scripts/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ release_tag="${GITHUB_REF:10}"

# prepare artifacts
pushd output
mv $release_input $release_target
shasum -a 256 $release_target > $release_target_hash
mv $release_input "$release_target"
shasum -a 256 "$release_target" > "$release_target_hash"
popd

# prepare release
ORG="filecoin-project"
REPO="builtin-actors"

# see if the release already exists by tag
__release_response=`
__release_response=$(
curl \
--header "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$ORG/$REPO/releases/tags/$release_tag"
`
__release_id=`echo $__release_response | jq '.id'`
)
__release_id=$(echo "$__release_response" | jq '.id')
if [ "$__release_id" = "null" ]; then
echo "release $release_tag does not exist"
exit 1
fi

__release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1`
__release_upload_url=$(echo "$__release_response" | jq -r '.upload_url' | cut -d'{' -f1)

echo "uploading $release_target"
curl \
Expand Down
34 changes: 34 additions & 0 deletions scripts/update-bundle-size.sh
Original file line number Diff line number Diff line change
@@ -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 <bundle-size-path> <bundle-path>"
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 byte(s)"