Skip to content

test: make test contracts workspace members for shared compilation#174

Open
r-near wants to merge 5 commits intomasterfrom
test/workspace-contracts
Open

test: make test contracts workspace members for shared compilation#174
r-near wants to merge 5 commits intomasterfrom
test/workspace-contracts

Conversation

@r-near
Copy link
Copy Markdown
Contributor

@r-near r-near commented Mar 26, 2026

Summary

  • Makes all 8 test contracts workspace members instead of standalone projects, so they share the workspace's target/ directory and wasm32 dependency compilation cache
  • Previously, each cargo_near_build call recompiled near-sdk and all transitive deps from scratch in its own target dir (~20 times per full test run)
  • Now deps compile once for wasm32, and subsequent contract builds only compile the contract lib itself

Stacked on #172 (WarpBuild CI migration)

Changes

  • Add all test contracts to [workspace.members] in root Cargo.toml
  • Use workspace.dependencies for near-sdk and near-plugins in contract Cargo.tomls
  • Move [profile.release] wasm optimization settings to workspace root
  • Pin channel = "1.86.0" in root rust-toolchain (replaces 8 per-contract files)
  • Update CI to --exclude wasm-only contract packages from host-target commands (cargo test, cargo clippy)
  • Apply edition 2024 formatting to contract source files (import ordering)

Test plan

  • cargo test -p near-plugins-derive --test ownable passes locally
  • cargo test -p near-plugins-derive --test pausable passes locally
  • cargo fmt --all -- --check passes
  • Second contract test completes in seconds (shared dep cache working)
  • Full CI passes on this branch

Closes #173

Copilot AI review requested due to automatic review settings March 26, 2026 20:33
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the integration-test WASM contracts under near-plugins-derive/tests/contracts/* to be workspace members, enabling shared compilation artifacts (target/) and reducing redundant dependency rebuilds during the test suite.

Changes:

  • Adds all test contracts as root workspace members and switches them to workspace.dependencies / inherited edition.
  • Consolidates WASM release optimization settings at the workspace root and centralizes the Rust toolchain pin in the repo root.
  • Updates CI to exclude WASM-only contract packages from host-target cargo test / cargo clippy runs.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rust-toolchain Pins the repo toolchain to Rust 1.86.0 and keeps wasm32 target/components.
Cargo.toml Adds test contracts to workspace members, defines workspace.dependencies, and moves release profile settings to workspace root.
.github/workflows/test.yml Excludes WASM-only contract crates from host-target cargo test and cargo clippy; installs wasm target in CI.
near-plugins-derive/tests/contracts/access_controllable/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/access_controllable/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/access_controllable/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/ownable/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/ownable/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/ownable/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/pausable/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/pausable/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/pausable/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/pausable_new/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/pausable_new/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/pausable_new/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/pausable_old/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/pausable_old/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/pausable_old/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/upgradable/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/upgradable/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/upgradable/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/upgradable_2/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/upgradable_2/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.
near-plugins-derive/tests/contracts/upgradable_state_migration/src/lib.rs Rustfmt/edition-2024 import reordering.
near-plugins-derive/tests/contracts/upgradable_state_migration/Cargo.toml Switches to edition.workspace and uses workspace dependencies for near-sdk / near-plugins.
near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain Removes per-contract toolchain file in favor of repo root toolchain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@r-near r-near marked this pull request as draft March 26, 2026 20:50
Base automatically changed from ci/warpbuild-runners to master March 26, 2026 20:50
r-near added 3 commits March 26, 2026 14:01
Previously, each of the 8 test contracts was a standalone project with its
own target directory, causing near-sdk and all dependencies to be recompiled
from scratch for each contract (~20 cargo_near_build calls per test run).

By making them workspace members, all contracts share the workspace's target
directory, so wasm32 dependencies only compile once. This reduces test CI
time significantly.

Changes:
- Add all test contracts as workspace members in root Cargo.toml
- Use workspace.dependencies for near-sdk and near-plugins in contracts
- Move release profile (wasm optimization settings) to workspace root
- Pin toolchain to 1.86.0 in root rust-toolchain (replaces per-contract files)
- Delete per-contract rust-toolchain files (now inherited from workspace)
- Update CI to exclude wasm-only contracts from host-target commands
- Apply edition 2024 formatting to contract source files

Closes #173
Add default-members to only include library crates, so plain cargo
commands (test, clippy) automatically skip wasm-only contract packages
without needing verbose --exclude flags.
@r-near r-near force-pushed the test/workspace-contracts branch from 858aebf to 2f4fd9b Compare March 26, 2026 21:01
r-near added 2 commits March 26, 2026 14:17
nextest runs each test as a separate process, which may improve
throughput for sandbox-based integration tests. Also adds flaky
test detection with retries in CI.
@r-near r-near marked this pull request as ready for review March 26, 2026 22:06
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: avoid redundant recompilation of test contracts

2 participants