diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 471b821..e4d830a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,25 +25,35 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - - name: Setup node ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: Install Rust uses: dtolnay/rust-toolchain@v1 with: toolchain: nightly + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: "packages/wasm-miniscript" + cache-on-failure: true + + - name: Setup node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Install wasm-pack run: | rustup component add rustfmt - cargo install wasm-pack + cargo install wasm-pack --version 0.13.1 + cargo install wasm-opt --version 0.116.1 - name: Build Info run: | echo "node $(node --version)" echo "npm $(npm --version)" + echo "rustc $(rustc --version)" + echo "wasm-pack $(wasm-pack --version)" + echo "wasm-opt $(wasm-opt --version)" git --version echo "base ref $GITHUB_BASE_REF" echo "head ref $GITHUB_HEAD_REF" diff --git a/packages/wasm-miniscript/Makefile b/packages/wasm-miniscript/Makefile index 8653926..412bc41 100644 --- a/packages/wasm-miniscript/Makefile +++ b/packages/wasm-miniscript/Makefile @@ -1,4 +1,5 @@ WASM_PACK = wasm-pack +WASM_OPT = wasm-opt WASM_PACK_FLAGS = --no-pack --weak-refs ifdef WASM_PACK_DEV @@ -6,7 +7,12 @@ ifdef WASM_PACK_DEV endif define WASM_PACK_COMMAND - $(WASM_PACK) build --out-dir $(1) $(WASM_PACK_FLAGS) --target $(2) + $(WASM_PACK) build --no-opt --out-dir $(1) $(WASM_PACK_FLAGS) --target $(2) +endef + +# run wasm-opt separately so we can pass `--enable-bulk-memory` +define WASM_OPT_COMMAND + $(WASM_OPT) --enable-bulk-memory -Oz $(1)/*.wasm -o $(1)/*.wasm endef define REMOVE_GITIGNORE @@ -22,6 +28,7 @@ endef define BUILD rm -rf $(1) $(call WASM_PACK_COMMAND,$(1),$(2)) + $(call WASM_OPT_COMMAND,$(1)) $(call REMOVE_GITIGNORE,$(1)) $(call SHOW_WASM_SIZE,$(1)) endef