-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12e5fce
commit 84ffa92
Showing
5 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,3 +115,39 @@ jobs: | |
uses: actions/checkout@v3 | ||
- name: Run shellcheck | ||
uses: ludeeus/[email protected] | ||
bundle-size: | ||
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: Show bundle delta summary | ||
id: bundle-summary | ||
run: | | ||
echo 'bundle-summary<<EOF' >> $GITHUB_ENV | ||
make bundle-size | tail -n3 >> $GITHUB_ENV | ||
echo 'EOF' >> $GITHUB_ENV | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Update WASM bundle size | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
# Check if the bundle size was committed and is up-to-date | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6030520 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 bytes" |