From c9bf6fd5f30d65a39d57208e9e8e7f74f000d9fc Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Wed, 27 Mar 2024 17:02:46 -0700 Subject: [PATCH] partial: a few changes Back in [0] we removed the wasm crate from the monorepo, so that the web team could own it and iterate more quickly. We also purged associated testing, however, so we missed some breakage around the release of v0.70.0. This check attempts to restore some visibility into the potential of breaking APIs relevant to web work. [0] https://github.com/penumbra-zone/penumbra/issues/3819 --- .github/workflows/rust.yml | 3 + deployments/scripts/check-wasm-compat.sh | 73 +++++++++++++----------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b8077bb7d9..646d7aa973 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,6 +12,8 @@ jobs: - name: Install rust toolchain uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown - name: Install nextest uses: taiki-e/install-action@nextest @@ -25,6 +27,7 @@ jobs: # The `-D warnings` option causes an error on warnings; # we must duplicate the rustflags from `.cargo/config.toml`. RUSTFLAGS: "-D warnings --cfg tokio_unstable" + - name: Check wasm compatibility run: ./deployments/scripts/check-wasm-compat.sh diff --git a/deployments/scripts/check-wasm-compat.sh b/deployments/scripts/check-wasm-compat.sh index 9b6b2cdaf7..4de3e6169e 100755 --- a/deployments/scripts/check-wasm-compat.sh +++ b/deployments/scripts/check-wasm-compat.sh @@ -1,41 +1,46 @@ #!/usr/bin/env bash +# CI script for checking that the Penumbra monorepo does not accidentally +# break compatibility with downstream web APIs, via the WASM crate. +# Historically, this breakage has taken the form of inadvertently introducing +# dependencies on std, e.g. via `mio`. +set -euo pipefail -set -e + +# List of packages taken from web repo's wasm Cargo.toml: +# +# ❯ rg ^penumbra packages/wasm/crate/Cargo.toml --no-line-number | cut -f1 -d' ' | sort +# +# should be periodically updated in order to keep parity. packages=( - "penumbra-asset" - "penumbra-tct" - "penumbra-community-pool" - "penumbra-compact-block" - "penumbra-dex" - "penumbra-distributions" - "penumbra-fee" - "penumbra-funding" - "penumbra-governance" - "penumbra-ibc" - "penumbra-sct" - "penumbra-shielded-pool" - "penumbra-stake" - "penumbra-keys" - "penumbra-transaction" - "penumbra-txhash" - # Note: we can't include those ones because they rely on `getrandom` - # but there's a `js` feature... - # "penumbra-num" - # "penumbra-proto" - # "decaf377-fmd" - # "decaf377-frost" - # "decaf377-ka" - # "penumbra-proof-params" + penumbra-asset + penumbra-compact-block + penumbra-dex + penumbra-fee + penumbra-governance + penumbra-ibc + penumbra-keys + penumbra-sct + penumbra-shielded-pool + penumbra-stake + penumbra-tct + penumbra-transaction + + # Some aren't ready with no default features, due to js/getrandom: + # penumbra-num + # penumbra-proof-params + # penumbra-proto + # decaf377-fmd + # decaf377-frost + # decaf377-ka ) -for package in "${packages[@]}"; do - echo "Building package: $package" - cargo check --release --target wasm32-unknown-unknown --package "$package" --no-default-features - if [ $? -ne 0 ]; then - echo "Compile error encountered while building package $package" - exit 1 - fi - echo "Package $package built successfully" - echo "------------------------" +# We intentionally loop over the packages one by one to make error-reporting clearer. +# Ostensibly this would be slow, but in CI with a warm cache it's quick. +for p in ${packages[@]} ; do + echo "Checking package for wasm compat: $p ..." + if ! cargo check --quiet --release --target wasm32-unknown-unknown --no-default-features --package "$p" ; then + >&2 echo "ERROR: package appears not to be wasm-compatible: '$p'" + exit 1 + fi done