Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: optimize out retriggering 2nd stage of build + of wasmopt stag…
…e in tests context (#292) reason for this pr is that [LazyLock initialization block](https://github.com/NEAR-DevHub/neardevhub-contract/blob/083fdde69d147f43bd320094db1b3a8acf64c841/tests/test_env/mod.rs#L20-L27) doesn't work to ensure tested contracts are built only once for `cargo nextest run` as **cargo-nextest** uses a process-per-test runner, and for usual `cargo test` workflows it may not be convenient/possible to unite all tests into a single test module, thus contracts' build will run at least once per each test module. This pr minimizes time spent on contracts' rebuilding after initial build, so that LazyLock init block isn't that much needed any more, but it depends on separating target folders of different contracts being tested similar to dj8yfo/neardevhub-contract@cbbf0ee to avoid partially rebuilding contracts starting with `near-sdk-macros` crate, if it's shared in common release profile when different contracts are in a workspace. --- this results in ```bash • Building contract │ Finished `release` profile [optimized] target(s) in 0.08s • Running an optimize for size post-step with wasm-opt... /home/user/Documents/code/near/neardevhub-contract/target/wasm32-unknown-unknown/release/devhub.wasm -> /tmp/optimized-s2bmSK.wasm • done ✓ Contract successfully built! (in CARGO_NEAR_BUILD_ENVIRONMENT=host) - Binary: /home/user/Documents/code/near/neardevhub-contract/target/near/devhub.wasm - SHA-256 checksum hex : 1f568ea4c5eabf9c947a201f3adf38a4e47056658aa512fdfc722f17de9d3aa3 - SHA-256 checksum bs58: 37LC32jmZFmZN8KesPipwUn4ZyhW4994coXqSWMdnDQv - ABI: /home/user/Documents/code/near/neardevhub-contract/target/near/devhub_abi.json - Embedded ABI: /home/user/Documents/code/near/neardevhub-contract/target/near/devhub_abi.zst Finished cargo near build in 5s Here is the console command if you ever need to re-run it again: cargo near build non-reproducible-wasm ``` instead of ```bash • Building contract │ Compiling near-sdk-macros v5.5.0 │ Compiling near-sdk v5.5.0 │ Compiling devhub_common v0.1.0 (/home/user/Documents/code/near/neardevhub-contract/d evhub_common) │ Compiling near-contract-standards v5.5.0 │ Compiling devhub v0.2.0 (/home/user/Documents/code/near/neardevhub-contract) │ Finished `release` profile [optimized] target(s) in 15.52s • Running an optimize for size post-step with wasm-opt... /home/user/Documents/code/near/neardevhub-contract/target/wasm32-unknown-unknown/release/d evhub.wasm -> /tmp/optimized-FbzCfP.wasm • done ✓ Contract successfully built! (in CARGO_NEAR_BUILD_ENVIRONMENT=host) - Binary: /home/user/Documents/code/near/neardevhub-contract/target/ne ar/devhub.wasm - SHA-256 checksum hex : 1f568ea4c5eabf9c947a201f3adf38a4e47056658aa512fdfc722f17de9d3aa3 - SHA-256 checksum bs58: 37LC32jmZFmZN8KesPipwUn4ZyhW4994coXqSWMdnDQv - ABI: /home/user/Documents/code/near/neardevhub-contract/target/ne ar/devhub_abi.json - Embedded ABI: /home/user/Documents/code/near/neardevhub-contract/target/ne ar/devhub_abi.zst Finished cargo near build in 20s ``` on rebuilds. and wasm-opt stage skipping was handled in e746699 . No file locks were added, it would still waste some cpu, if multiple builders enter the wasm-opt stage around the same time, but it does save on time and locks are perceived as unneeded complexity at this time. --- vaguely related to Near-One/omni-bridge#184 --------- Co-authored-by: dj8yf0μl <[email protected]> Co-authored-by: Vlad Frolov <[email protected]>
- Loading branch information