Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put integration tests behind feature flag #515

Merged
merged 27 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
03f5f74
subxt: Add integration-tests feature flag
lexnv Apr 22, 2022
45b84eb
subxt: Guard integration tests under feature flag
lexnv Apr 22, 2022
fbdfdf6
test-runtime: Place build.rs under feature flag
lexnv Apr 22, 2022
c9ad19b
subxt: Pass `integration-tests` feature to `test-runtime`
lexnv Apr 22, 2022
8e5f38b
CI: Use `integration-tests` feature to run all tests
lexnv Apr 22, 2022
3087ada
Merge remote-tracking branch 'origin/master' into 351_test_feature
lexnv Apr 28, 2022
057f075
subxt: Rely on `#[cfg(feature = "integration-tests")]` for integration
lexnv Apr 28, 2022
e596c68
subxt/metadata: Manually construct test metadata
lexnv Apr 28, 2022
c192f17
artifacts: Move scale binary blob to dedicated folder
lexnv Apr 28, 2022
680bc05
examples: Update path to metadata blob
lexnv Apr 28, 2022
3a1a692
metadata: Rely on artifact metadata blob for benches
lexnv Apr 28, 2022
2461c3b
metadata: Remove `test-runtime` dependency
lexnv Apr 28, 2022
3d9b9ab
examples: Modify runtime path for `custom_type_derives`
lexnv Apr 28, 2022
06c587c
Merge remote-tracking branch 'origin/master' into 351_test_feature
lexnv Apr 28, 2022
1e0522d
subxt: Remove tests folder
lexnv Apr 28, 2022
e73c763
test-runtime: Remove `integration-tests` feature flag
lexnv Apr 28, 2022
e309328
integration-tests: Add an integration test crate for subxt
lexnv Apr 28, 2022
77818e0
subxt: Remove `test-runtime` dependency
lexnv Apr 28, 2022
8c1c681
subxt: Add comment for feature flags
lexnv Apr 28, 2022
cd91831
integration-tests: Trim dependencies
lexnv Apr 28, 2022
bc0f719
integration-tests: Move dependencies under dev
lexnv Apr 28, 2022
bce0562
Revert "CI: Use `integration-tests` feature to run all tests"
lexnv Apr 28, 2022
a989404
integration-tests: Remove integration folder
lexnv Apr 29, 2022
755a871
subxt: Fix feature flag and test comment
lexnv Apr 29, 2022
1890dc1
subxt: Extra feature flag comment
lexnv Apr 29, 2022
5e49b4e
Merge remote-tracking branch 'origin/master' into 351_test_feature
lexnv Apr 29, 2022
e857e7e
integration-tests: Move tests content under src
lexnv Apr 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --all-targets --workspace
args: --features integration-tests --all-targets --workspace

# If the previous step fails, create a new Github issue
# to nofity us about it.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --all-targets --workspace
args: --features integration-tests --all-targets --workspace

clippy:
name: Cargo clippy
Expand Down Expand Up @@ -158,4 +158,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
args: --features integration-tests --all-targets -- -D warnings
3 changes: 3 additions & 0 deletions subxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ homepage = "https://www.parity.io/"
description = "Submit extrinsics (transactions) to a substrate node via RPC"
keywords = ["parity", "substrate", "blockchain"]

[features]
integration-tests = ["test-runtime/integration-tests"]

[dependencies]
async-trait = "0.1.49"
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
Expand Down
7 changes: 7 additions & 0 deletions subxt/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@
// along with subxt. If not, see <http://www.gnu.org/licenses/>.

mod codegen;
#[cfg(feature = "integration-tests")]
lexnv marked this conversation as resolved.
Show resolved Hide resolved
mod utils;

#[cfg(test)]
#[cfg(feature = "integration-tests")]
mod client;
#[cfg(test)]
#[cfg(feature = "integration-tests")]
mod events;
#[cfg(test)]
#[cfg(feature = "integration-tests")]
mod frame;
#[cfg(test)]
#[cfg(feature = "integration-tests")]
mod storage;

#[cfg(feature = "integration-tests")]
use test_runtime::node_runtime;
#[cfg(feature = "integration-tests")]
use utils::*;
3 changes: 3 additions & 0 deletions test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "test-runtime"
version = "0.20.0"
edition = "2021"

[features]
integration-tests = []

[dependencies]
subxt = { path = "../subxt" }
sp-runtime = "6.0.0"
Expand Down
7 changes: 7 additions & 0 deletions test-runtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@ use subxt::rpc::{
};

static SUBSTRATE_BIN_ENV_VAR: &str = "SUBSTRATE_NODE_PATH";
static INTEGRATION_FEATURE_FLAG: &str = "CARGO_FEATURE_INTEGRATION_TESTS";

#[tokio::main]
async fn main() {
run().await;
}

async fn run() {
// The build script must run only in test context, as having `integration-tests` feature
// flag enabled.
if env::var_os(INTEGRATION_FEATURE_FLAG).is_none() {
return
}

// Select substrate binary to run based on env var.
let substrate_bin =
env::var(SUBSTRATE_BIN_ENV_VAR).unwrap_or_else(|_| "substrate".to_owned());
Expand Down
2 changes: 2 additions & 0 deletions test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#![allow(clippy::too_many_arguments)]

/// The SCALE encoded metadata obtained from a local run of a substrate node.
#[cfg(feature = "integration-tests")]
pub static METADATA: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/metadata.scale"));

#[cfg(feature = "integration-tests")]
include!(concat!(env!("OUT_DIR"), "/runtime.rs"));