osmosis-labs / test-tube

Test tube for cosmos-sdk chains integration test, written in Rust!
Apache License 2.0
53 stars 31 forks source link

Avoid recompiling osmos-test-tube everytime #49

Closed Kayanski closed 6 months ago

Kayanski commented 7 months ago

This PR aims at avoiding osmosis-test-tube recompilation even when go files are not changed.

Origin of the issue

Within cw-orchestrator, we use osmosis-test-tube to provide this very nice execution environment to our users. However, when using osmosis-test-tube, it gets recompiled every time we run the cargo build command. In some cases a lot of our dependencies are rendered stale because of osmosis-test-tube. The iterating development process is very lengthy due to this issue.

Reproducing the issue

  1. Clone https://github.com/AbstractSDK/cw-orchestrator
  2. Run cargo test
  3. Run cargo test a second time. You see that it gets compiled again with osmosis-test-tube as the first dependency being compiled

Investigations

When using CARGO_LOG=cargo::core::compiler::fingerprint=info cargo test (see this official rust rebuild guide to understand why), we get this line :

   0.163529743s  INFO cargo::core::compiler::fingerprint: stale: changed "/path/to/project/target/debug/build/osmosis-test-tube-ee82f39bd1b688b4/out/libosmosistesttube.h"
   0.163545353s  INFO cargo::core::compiler::fingerprint:           (vs) "/path/to/project/target/debug/build/osmosis-test-tube-ee82f39bd1b688b4/output"
   0.163549743s  INFO cargo::core::compiler::fingerprint:                FileTime { seconds: 1706181437, nanos: 970357582 } < FileTime { seconds: 1706181476, nanos: 206700553 }

This indicates that the build procedure is not detected correctly by the cargo dependency machine. I think that the build.rs execution actually finishes before the compilation (and creation of the .h file and thus is not detected correctly.

Proposed solution

We propose to introduce an new env variable (OSMOSIS_TUBE_DEV) that can trigger compilation if set.

The compilation will only take place if :

That way, all users don't have the recompiling issues. If they want to touch the underlying library, they should set this flag to be able to build every time they do a change.