From f4be4bc440d834b0ce9a6b07a665774fd01574de Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Tue, 19 Jul 2022 16:43:18 +0200 Subject: [PATCH 1/7] ci: optimize wasm size release build --- Makefile.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.toml b/Makefile.toml index 6ca25f72..55b91cd4 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -87,6 +87,7 @@ rustup target add wasm32-unknown-unknown args = ["build", "--release", "--target", "wasm32-unknown-unknown"] command = "cargo" dependencies = ["install_wasm"] +env = { RUSTFLAGS = "-C link-arg=-s" } [tasks.check_contracts] dependencies = ["wasm"] From 0686b982a6c9c95d10436a1dd79e7b89269ed42d Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Tue, 19 Jul 2022 16:48:25 +0200 Subject: [PATCH 2/7] ci: add size limit github action --- .github/workflows/build.yml | 32 ++++++++++++++++++++++++++++++++ .size-limit.json | 8 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 .size-limit.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba2fdccc..ea74bc83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,3 +43,35 @@ jobs: - name: Build wasm run: cargo make wasm + + - name: Prepare size limit + run: | + cat << EOF > package.json + { + "name": "contracts", + "version": "1.0.0", + "description": "[![version](https://img.shields.io/github/v/release/okp4/contracts?style=for-the-badge)](https://github.com/okp4/contracts/releases) [![build](https://img.shields.io/github/workflow/status/okp4/contracts/Build?label=build&style=for-the-badge)](https://github.com/okp4/contracts/actions/workflows/build.yml) [![lint](https://img.shields.io/github/workflow/status/okp4/contracts/Lint?label=lint&style=for-the-badge)](https://github.com/okp4/contracts/actions/workflows/lint.yml) [![test](https://img.shields.io/github/workflow/status/okp4/contracts/Test?label=test&style=for-the-badge)](https://github.com/okp4/contracts/actions/workflows/test.yml) [![conventional commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=for-the-badge)](https://opensource.org/licenses/BSD-3-Clause)", + "main": "index.js", + "scripts": { + "build": "cargo make wasm", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/okp4/contracts.git" + }, + "author": "", + "bugs": { + "url": "https://github.com/okp4/contracts/issues" + }, + "homepage": "https://github.com/okp4/contracts#readme", + "devDependencies": { + "@size-limit/preset-app": "^7.0.8" + } + } + EOF + + - name: Report wasm size limit + uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.size-limit.json b/.size-limit.json new file mode 100644 index 00000000..177eb17f --- /dev/null +++ b/.size-limit.json @@ -0,0 +1,8 @@ +[ + { + "path": "target/wasm32-unknown-unknown/release/cw_template.wasm", + "running": false, + "brotli": false, + "gzip": false + } +] From 753545b6fdb284c6f508313db88e332ceac36e35 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Wed, 20 Jul 2022 10:59:40 +0200 Subject: [PATCH 3/7] ci: include size-limit configuration into package.json --- .github/workflows/build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea74bc83..c5dc6e49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,8 +67,16 @@ jobs: "homepage": "https://github.com/okp4/contracts#readme", "devDependencies": { "@size-limit/preset-app": "^7.0.8" - } - } + }, + "size-limit": [ + { + "path": "target/wasm32-unknown-unknown/release/cw_template.wasm", + "running": false, + "brotli": false, + "gzip": false + } + ] + } EOF - name: Report wasm size limit From a0a7abcf0fcf29d99a335b21d7546e7777dc3ebd Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Wed, 20 Jul 2022 14:51:39 +0200 Subject: [PATCH 4/7] ci: fix check contract step --- Makefile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 55b91cd4..6df83db7 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -92,7 +92,7 @@ env = { RUSTFLAGS = "-C link-arg=-s" } [tasks.check_contracts] dependencies = ["wasm"] script = ''' -cargo install --debug --version 1.0.0 --features iterator --example check_contract -- cosmwasm-vm +if [[ ! -e ~/.cargo/bin/check_contract ]]; then cargo install --debug --version 1.0.0 --features iterator --force --example check_contract -- cosmwasm-vm ; fi for W in ./target/wasm32-unknown-unknown/release/*.wasm do echo -n "Checking `basename $W`... " From e005a95edd98fd3886ad7e9f1b4ab99338fc2cd4 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Wed, 20 Jul 2022 16:18:06 +0200 Subject: [PATCH 5/7] ci: remove unsued attribute on Package.json --- .github/workflows/build.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5dc6e49..91f29957 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,21 +50,9 @@ jobs: { "name": "contracts", "version": "1.0.0", - "description": "[![version](https://img.shields.io/github/v/release/okp4/contracts?style=for-the-badge)](https://github.com/okp4/contracts/releases) [![build](https://img.shields.io/github/workflow/status/okp4/contracts/Build?label=build&style=for-the-badge)](https://github.com/okp4/contracts/actions/workflows/build.yml) [![lint](https://img.shields.io/github/workflow/status/okp4/contracts/Lint?label=lint&style=for-the-badge)](https://github.com/okp4/contracts/actions/workflows/lint.yml) [![test](https://img.shields.io/github/workflow/status/okp4/contracts/Test?label=test&style=for-the-badge)](https://github.com/okp4/contracts/actions/workflows/test.yml) [![conventional commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=for-the-badge)](https://opensource.org/licenses/BSD-3-Clause)", - "main": "index.js", "scripts": { - "build": "cargo make wasm", - "test": "echo \"Error: no test specified\" && exit 1" + "build": "cargo make wasm" }, - "repository": { - "type": "git", - "url": "git+https://github.com/okp4/contracts.git" - }, - "author": "", - "bugs": { - "url": "https://github.com/okp4/contracts/issues" - }, - "homepage": "https://github.com/okp4/contracts#readme", "devDependencies": { "@size-limit/preset-app": "^7.0.8" }, From 8590aa437b03a5551e382d917c850285bd1896b8 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Thu, 21 Jul 2022 15:11:33 +0200 Subject: [PATCH 6/7] ci: use the bot-anik github token --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91f29957..01eec0aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,4 +70,4 @@ jobs: - name: Report wasm size limit uses: andresz1/size-limit-action@v1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.OKP4_TOKEN }} From 784e3baed3179656e25fc75da4ea1f72f484bbfc Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Thu, 21 Jul 2022 15:24:06 +0200 Subject: [PATCH 7/7] ci: move size limit from build.yml to lint.yml --- .github/workflows/build.yml | 28 ------------------- .github/workflows/lint.yml | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01eec0aa..ba2fdccc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,31 +43,3 @@ jobs: - name: Build wasm run: cargo make wasm - - - name: Prepare size limit - run: | - cat << EOF > package.json - { - "name": "contracts", - "version": "1.0.0", - "scripts": { - "build": "cargo make wasm" - }, - "devDependencies": { - "@size-limit/preset-app": "^7.0.8" - }, - "size-limit": [ - { - "path": "target/wasm32-unknown-unknown/release/cw_template.wasm", - "running": false, - "brotli": false, - "gzip": false - } - ] - } - EOF - - - name: Report wasm size limit - uses: andresz1/size-limit-action@v1 - with: - github_token: ${{ secrets.OKP4_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 68c5af84..91bba9b8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -157,6 +157,61 @@ jobs: run: | cargo make lint-toml + report-wasm-size: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ~/.cargo/bin + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + default: true + override: true + + - name: Install cargo make + uses: davidB/rust-cargo-make@v1 + + - name: Prepare size limit + run: | + cat << EOF > package.json + { + "name": "contracts", + "version": "1.0.0", + "scripts": { + "build": "cargo make wasm" + }, + "devDependencies": { + "@size-limit/preset-app": "^7.0.8" + }, + "size-limit": [ + { + "path": "target/wasm32-unknown-unknown/release/cw_template.wasm", + "running": false, + "brotli": false, + "gzip": false + } + ] + } + EOF + + - name: Report wasm size limit + uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.OKP4_TOKEN }} + lint-branch-name: runs-on: ubuntu-20.04 if: github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')