Skip to content

fix: rust tests

fix: rust tests #637

Workflow file for this run

name: Rust CI
permissions:
contents: read
on:
push:
paths:
- "packages/erc4337-contracts/**"
- "packages/sdk-platforms/rust/**"
- ".github/workflows/ci-rust.yml"
pull_request:
paths:
- "packages/erc4337-contracts/**"
- "packages/sdk-platforms/rust/**"
- ".github/workflows/ci-rust.yml"
workflow_dispatch:
jobs:
rust-sdk-erc4337:
name: Rust 4337 SDK
runs-on: ubuntu-latest
strategy:
matrix:
config:
- debug
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.4
- name: Install Rust
run: |
rustup update stable && rustup default stable
rustup toolchain install nightly
- name: Run rustfmt
run: |
rustup component add rustfmt --toolchain nightly
cargo +nightly fmt --all -- --check
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1.4.0
- name: Install dependencies
run: forge soldeer install
working-directory: packages/erc4337-contracts
- name: Install Node.js 22 via nvm
run: |
export NVM_DIR="$HOME/.nvm"
mkdir -p "$NVM_DIR"
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
. "$NVM_DIR/nvm.sh"
nvm install 22
nvm use 22
node -v
# Expose Node.js bin dir to subsequent steps
echo "$(dirname $(nvm which 22))" >> $GITHUB_PATH
- name: Configure pnpm store dir
run: echo "PNPM_STORE_DIR=$HOME/.pnpm-store" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('packages/erc4337-contracts/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Enable corepack and activate pnpm from contracts package.json
run: |
corepack enable
corepack prepare "$(node -p "require('./package.json').packageManager")" --activate
pnpm -v
working-directory: packages/erc4337-contracts
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: packages/erc4337-contracts
- name: Build ERC-4337 contracts
run: forge build
working-directory: packages/erc4337-contracts
- name: Verify ERC-4337 contract ABIs exist
run: |
set -euo pipefail
missing=()
files=(
"out/IERC7579Account.sol/IERC7579Account.json"
"out/EntryPoint.sol/EntryPoint.json"
)
for f in "${files[@]}"; do
if [ ! -f "$f" ]; then
missing+=("$f")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
echo "Missing expected ABI JSON files:" >&2
for m in "${missing[@]}"; do echo " - $m" >&2; done
echo "\nAvailable JSON files under out/:" >&2
find out -maxdepth 2 -type f -name '*.json' | sort || true
exit 1
fi
working-directory: packages/erc4337-contracts
- name: Run clippy
run: |
rustup component add clippy --toolchain stable
rustup component add --toolchain 1.91.0-x86_64-unknown-linux-gnu clippy
cargo clippy --all-targets -- -D warnings
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Run rust tests with nextest
run: cargo nextest run --profile ci --all-features
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
rust-sdk-erc4337-wasm:
name: Rust ERC-4337 WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.4
- name: Install Rust with WASM target
run: |
rustup update stable && rustup default stable
rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1.4.0
- name: Install dependencies
run: forge soldeer install
working-directory: packages/erc4337-contracts
- name: Build ERC-4337 contracts
run: forge build
working-directory: packages/erc4337-contracts
- name: Verify ERC-4337 contract ABIs exist
run: |
set -euo pipefail
missing=()
files=(
"out/IERC7579Account.sol/IERC7579Account.json"
"out/EntryPoint.sol/EntryPoint.json"
)
for f in "${files[@]}"; do
if [ ! -f "$f" ]; then
missing+=("$f")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
echo "Missing expected ABI JSON files:" >&2
for m in "${missing[@]}"; do echo " - $m" >&2; done
echo "\nAvailable JSON files under out/:" >&2
find out -maxdepth 2 -type f -name '*.json' | sort || true
exit 1
fi
working-directory: packages/erc4337-contracts
- name: Build WASM module (web target)
run: wasm-pack build --target web
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-ffi-web
- name: Build WASM module (bundler target)
run: wasm-pack build --target bundler
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-ffi-web
- name: Build WASM module (nodejs target)
run: wasm-pack build --target nodejs
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-ffi-web
- name: Verify WASM artifacts
run: |
set -euo pipefail
missing=()
files=(
"pkg/zksync_sso_erc4337_web_ffi_bg.wasm"
"pkg/zksync_sso_erc4337_web_ffi.js"
"pkg/zksync_sso_erc4337_web_ffi.d.ts"
"pkg/package.json"
)
for f in "${files[@]}"; do
if [ ! -f "$f" ]; then
missing+=("$f")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
echo "Missing expected WASM artifacts:" >&2
for m in "${missing[@]}"; do echo " - $m" >&2; done
exit 1
fi
echo "✅ All WASM artifacts generated successfully"
# Show WASM file size
ls -lh pkg/zksync_sso_erc4337_web_ffi_bg.wasm
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-ffi-web