diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2586f19f2..a732ba6b8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,8 +88,8 @@ jobs: - name: 'Install the dependencies' run: 'pnpm install' - - name: Checking code format ciphernode - run: pnpm ciphernode:lint + - name: Checking code format rust + run: pnpm rust:lint - name: Run Unit Tests run: 'cargo test --lib && cargo test --doc' @@ -131,8 +131,8 @@ jobs: - name: 'Install the dependencies' run: 'pnpm install' - - name: Checking code format ciphernode - run: pnpm ciphernode:lint + - name: Checking code format rust + run: pnpm rust:lint - name: Run Integration Tests run: 'cargo test --test integration -- --nocapture && cargo test --test integration_legacy -- --nocapture' diff --git a/README.md b/README.md index 4a0a3f6642..ee3337e8c1 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,57 @@ pnpm i # Build the project pnpm build -# Run tests -pnpm test - # Clean build artifacts pnpm clean ``` +### Testing + +**⚠️ Important:** Always run tests through pnpm scripts, not directly via `cargo test` or other build tools. The pnpm scripts ensure necessary setup steps are executed (e.g., building required binaries, setting up test environments) that may be skipped when running tests directly. + +#### Test Scripts + +The monorepo provides several test scripts for different components: + +- **`pnpm test`** - Runs all tests across the entire monorepo: + + - EVM/Smart contract tests (`evm:test`) + - Rust crate tests (`rust:test`) + - SDK tests (`sdk:test`) + - Noir circuit tests (`noir:test`) + +- **`pnpm rust:test`** - Runs all Rust crate tests in the `crates/` directory. This script runs tests for all crates in the workspace, not just ciphernode-related crates. + +- **`pnpm evm:test`** - Runs tests for the EVM smart contracts in `packages/enclave-contracts`. + +- **`pnpm sdk:test`** - Runs tests for the TypeScript SDK in `packages/enclave-sdk`. + +- **`pnpm noir:test`** - Runs tests for Noir circuits in the `circuits/` directory using `nargo test`. + +- **`pnpm test:integration`** - Runs integration tests from `tests/integration/`. These tests may require prebuilt binaries and can be run with `--no-prebuild` if binaries are already available. + +#### Running Individual Test Suites + +```bash +# Run only Rust crate tests +pnpm rust:test + +# Run only EVM/smart contract tests +pnpm evm:test + +# Run only SDK tests +pnpm sdk:test + +# Run only Noir circuit tests +pnpm noir:test + +# Run only integration tests +pnpm test:integration + +# Run integration tests without prebuild step (if binaries already exist) +pnpm test:integration --no-prebuild +``` + ### Contributors diff --git a/package.json b/package.json index bc97b5eb4f..779c430b38 100644 --- a/package.json +++ b/package.json @@ -11,24 +11,26 @@ "scripts": { "bump:versions": "tsx scripts/bump-versions.ts", "clean": "tsx scripts/clean.ts", - "compile": "pnpm evm:build && pnpm sdk:build && pnpm react:build && pnpm ciphernode:build", - "lint": "pnpm evm:lint && pnpm ciphernode:lint && ./scripts/lint-circuits.sh", + "compile": "pnpm build:ts && pnpm rust:build", + "lint": "pnpm evm:lint && pnpm rust:lint && pnpm noir:lint", "format": "prettier --write \"**/*.{js,json,md,mdx,ts,tsx,yml,yaml,css}\"", "format:check": "prettier --check \"**/*.{js,json,md,mdx,ts,tsx,yml,yaml,css}\"", "check:license": "./scripts/check-license-headers.sh", "check:size": "./scripts/check-size.sh", "check:pnpm": "./scripts/check-pnpm.sh", - "test": "pnpm evm:test && pnpm ciphernode:test && pnpm sdk:test && ./scripts/test-circuits.sh", + "test": "pnpm evm:test && pnpm rust:test && pnpm sdk:test && pnpm noir:test", "test:integration": "cd ./tests/integration && ./test.sh", "coverage": "pnpm evm:coverage", "prepare": "husky", "enclave": "cd crates && ./scripts/launch.sh", - "ciphernode:lint": "cargo fmt -- --check", + "rust:lint": "cargo fmt -- --check", "ciphernode:add": "cd packages/enclave-contracts && pnpm ciphernode:admin-add", "ciphernode:remove": "cd packages/enclave-contracts && pnpm ciphernode:remove", - "ciphernode:test": "cd crates && ./scripts/test.sh", - "ciphernode:build": "cargo build --locked --release", - "preciphernode:build": "pnpm evm:build", + "rust:test": "cd crates && ./scripts/test.sh", + "noir:test": "./scripts/test-circuits.sh", + "noir:lint": "./scripts/lint-circuits.sh", + "rust:build": "cargo build --locked --release", + "prerust:build": "pnpm evm:build", "committee:new": "cd packages/enclave-contracts && pnpm committee:new", "committee:publish": "cd packages/enclave-contracts && pnpm hardhat committee:publish", "e3:activate": "cd packages/enclave-contracts && pnpm e3:activate", @@ -53,8 +55,7 @@ "npm:release": "pnpm build && pnpm config:release && pnpm evm:release && pnpm wasm:release && pnpm sdk:release && pnpm react:release", "support:build": "cd crates/support && ./scripts/build.sh", "build": "pnpm compile", - "wasm:build": "cd ./crates/wasm && pnpm build", - "release": "pnpm build && changeset publish", + "wasm:build": "cd crates/wasm && pnpm build", "build:ts": "pnpm evm:build && pnpm sdk:build && pnpm react:build" }, "packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808", diff --git a/packages/enclave-sdk/package.json b/packages/enclave-sdk/package.json index bd79c6ff7c..a3c7aa4945 100644 --- a/packages/enclave-sdk/package.json +++ b/packages/enclave-sdk/package.json @@ -20,7 +20,7 @@ "access": "public" }, "scripts": { - "prebuild": "cd ../enclave-contracts && pnpm build && cd ../../crates/wasm && pnpm build", + "prebuild": "pnpm -C ../enclave-contracts build && pnpm -C ../../ wasm:build", "build": "tsup", "dev": "tsup --watch", "clean": "rm -rf dist",