Skip to content

Commit 2ae16e9

Browse files
authored
Merge pull request #2 from okp4/feat/binary-size
📏 Report binary size on PR
2 parents 8708a63 + 784e3ba commit 2ae16e9

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.github/workflows/lint.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,61 @@ jobs:
157157
run: |
158158
cargo make lint-toml
159159
160+
report-wasm-size:
161+
runs-on: ubuntu-20.04
162+
steps:
163+
- name: Check out repository
164+
uses: actions/checkout@v3
165+
166+
- name: Cache cargo registry
167+
uses: actions/cache@v3
168+
with:
169+
path: |
170+
~/.cargo/registry
171+
~/.cargo/git
172+
~/.cargo/bin
173+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
174+
restore-keys: |
175+
${{ runner.os }}-cargo-
176+
177+
- name: Setup rust
178+
uses: actions-rs/toolchain@v1
179+
with:
180+
toolchain: nightly
181+
default: true
182+
override: true
183+
184+
- name: Install cargo make
185+
uses: davidB/rust-cargo-make@v1
186+
187+
- name: Prepare size limit
188+
run: |
189+
cat << EOF > package.json
190+
{
191+
"name": "contracts",
192+
"version": "1.0.0",
193+
"scripts": {
194+
"build": "cargo make wasm"
195+
},
196+
"devDependencies": {
197+
"@size-limit/preset-app": "^7.0.8"
198+
},
199+
"size-limit": [
200+
{
201+
"path": "target/wasm32-unknown-unknown/release/cw_template.wasm",
202+
"running": false,
203+
"brotli": false,
204+
"gzip": false
205+
}
206+
]
207+
}
208+
EOF
209+
210+
- name: Report wasm size limit
211+
uses: andresz1/size-limit-action@v1
212+
with:
213+
github_token: ${{ secrets.OKP4_TOKEN }}
214+
160215
lint-branch-name:
161216
runs-on: ubuntu-20.04
162217
if: github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')

.size-limit.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"path": "target/wasm32-unknown-unknown/release/cw_template.wasm",
4+
"running": false,
5+
"brotli": false,
6+
"gzip": false
7+
}
8+
]

Makefile.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ rustup target add wasm32-unknown-unknown
8787
args = ["build", "--release", "--target", "wasm32-unknown-unknown"]
8888
command = "cargo"
8989
dependencies = ["install_wasm"]
90+
env = { RUSTFLAGS = "-C link-arg=-s" }
9091

9192
[tasks.check_contracts]
9293
dependencies = ["wasm"]
9394
script = '''
94-
cargo install --debug --version 1.0.0 --features iterator --example check_contract -- cosmwasm-vm
95+
if [[ ! -e ~/.cargo/bin/check_contract ]]; then cargo install --debug --version 1.0.0 --features iterator --force --example check_contract -- cosmwasm-vm ; fi
9596
for W in ./target/wasm32-unknown-unknown/release/*.wasm
9697
do
9798
echo -n "Checking `basename $W`... "

0 commit comments

Comments
 (0)