From c631e1b8577fc2d260736744e104c826a9d2e423 Mon Sep 17 00:00:00 2001 From: Gregorio Juliana Date: Mon, 15 Jan 2024 19:12:00 +0100 Subject: [PATCH] chore: forced specific version of wasm-pack everywhere (#4044) This was affecting `aztec-packages` and several other people when building locally, so added I it to the `noir_wasm` build process specifically. --- .github/scripts/noir-wasm-build.sh | 1 - .github/workflows/test-js-packages.yml | 5 ----- compiler/wasm/package.json | 5 +++-- compiler/wasm/{ => scripts}/build-fixtures.sh | 0 compiler/wasm/scripts/command-check.sh | 6 ++++++ compiler/wasm/scripts/install_wasm-pack.sh | 12 ++++++++++++ compiler/wasm/wasm-opt-check.sh | 1 - 7 files changed, 21 insertions(+), 9 deletions(-) rename compiler/wasm/{ => scripts}/build-fixtures.sh (100%) create mode 100755 compiler/wasm/scripts/command-check.sh create mode 100755 compiler/wasm/scripts/install_wasm-pack.sh delete mode 100755 compiler/wasm/wasm-opt-check.sh diff --git a/.github/scripts/noir-wasm-build.sh b/.github/scripts/noir-wasm-build.sh index ccd49863f77..7c7e86e8c03 100755 --- a/.github/scripts/noir-wasm-build.sh +++ b/.github/scripts/noir-wasm-build.sh @@ -3,5 +3,4 @@ set -eu .github/scripts/noirc-abi-build.sh -.github/scripts/install_wasm-bindgen.sh yarn workspace @noir-lang/noir_wasm build diff --git a/.github/workflows/test-js-packages.yml b/.github/workflows/test-js-packages.yml index 7f8c5df3139..addc9ce3d83 100644 --- a/.github/workflows/test-js-packages.yml +++ b/.github/workflows/test-js-packages.yml @@ -70,11 +70,6 @@ jobs: name: noirc_abi_wasm path: ./tooling/noirc_abi_wasm - - name: Install wasm-pack - uses: taiki-e/install-action@v2 - with: - tool: wasm-pack@0.12.1 - - name: Install Yarn dependencies uses: ./.github/actions/setup diff --git a/compiler/wasm/package.json b/compiler/wasm/package.json index 4a71d8aa77d..a8abf26a7e2 100644 --- a/compiler/wasm/package.json +++ b/compiler/wasm/package.json @@ -29,9 +29,10 @@ "url": "https://github.com/noir-lang/noir/issues" }, "scripts": { - "build": "WASM_OPT=$(bash -c ./wasm-opt-check.sh) webpack", + "install:wasm_pack": "./scripts/install_wasm-pack.sh", + "build": "yarn install:wasm_pack && WASM_OPT=$(./scripts/command-check.sh wasm-opt) webpack", "test": "yarn test:build_fixtures && yarn test:node && yarn test:browser", - "test:build_fixtures": "./build-fixtures.sh", + "test:build_fixtures": "./scripts/build-fixtures.sh", "test:browser": "web-test-runner", "test:node": "NODE_NO_WARNINGS=1 mocha --config ./.mocharc.json", "clean": "rm -rf ./build ./target ./dist public/fixtures/simple/target public/fixtures/with-deps/target", diff --git a/compiler/wasm/build-fixtures.sh b/compiler/wasm/scripts/build-fixtures.sh similarity index 100% rename from compiler/wasm/build-fixtures.sh rename to compiler/wasm/scripts/build-fixtures.sh diff --git a/compiler/wasm/scripts/command-check.sh b/compiler/wasm/scripts/command-check.sh new file mode 100755 index 00000000000..51d342a8bd0 --- /dev/null +++ b/compiler/wasm/scripts/command-check.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -eu + +cd $(dirname "$0")/.. + +command -v $1 >/dev/null 2>&1 && echo "true" || { echo >&2 "$1 is not installed" && echo "false"; } \ No newline at end of file diff --git a/compiler/wasm/scripts/install_wasm-pack.sh b/compiler/wasm/scripts/install_wasm-pack.sh new file mode 100755 index 00000000000..28721e62fe2 --- /dev/null +++ b/compiler/wasm/scripts/install_wasm-pack.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eu + +cd $(dirname "$0")/.. + +# Install wasm-pack +CARGO_BINSTALL_CHECK=$(./scripts/command-check.sh cargo-binstall) +if [ $CARGO_BINSTALL_CHECK != "true" ]; then + curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +fi + +cargo-binstall wasm-pack@0.12.1 -y \ No newline at end of file diff --git a/compiler/wasm/wasm-opt-check.sh b/compiler/wasm/wasm-opt-check.sh deleted file mode 100755 index 8612b48d3f1..00000000000 --- a/compiler/wasm/wasm-opt-check.sh +++ /dev/null @@ -1 +0,0 @@ -command -v wasm-opt >/dev/null 2>&1 && echo "true" || { echo >&2 "wasm-opt is not installed, building in dev mode" && echo "false"; exit 1; } \ No newline at end of file