From 38c820b260284e615e7184d4f38696b063cceb8a Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 26 Jan 2023 17:36:40 +0100 Subject: [PATCH] Enable `try-runtime` flag in CI (#6587) * Env gate tests The CI should check that it compiles, but not run it. Signed-off-by: Oliver Tale-Yazdi * Enable try-runtime feature in CI Signed-off-by: Oliver Tale-Yazdi * Fix test Signed-off-by: Oliver Tale-Yazdi Signed-off-by: Oliver Tale-Yazdi --- runtime/kusama/src/lib.rs | 8 ++++++-- runtime/polkadot/src/lib.rs | 8 ++++++-- runtime/rococo/src/lib.rs | 8 ++++++-- runtime/westend/src/lib.rs | 8 ++++++-- scripts/ci/gitlab/pipeline/test.yml | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index d9e25ac06afd..d45aff4517bf 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2231,7 +2231,7 @@ mod multiplier_tests { #[cfg(all(test, feature = "try-runtime"))] mod remote_tests { use super::*; - use frame_try_runtime::runtime_decl_for_TryRuntime::TryRuntime; + use frame_try_runtime::{runtime_decl_for_TryRuntime::TryRuntime, UpgradeCheckSelect}; use remote_externalities::{ Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport, }; @@ -2239,6 +2239,10 @@ mod remote_tests { #[tokio::test] async fn run_migrations() { + if var("RUN_MIGRATION_TESTS").is_err() { + return + } + sp_tracing::try_init_simple(); let transport: Transport = var("WS").unwrap_or("wss://kusama-rpc.polkadot.io:443".to_string()).into(); @@ -2259,6 +2263,6 @@ mod remote_tests { .build() .await .unwrap(); - ext.execute_with(|| Runtime::on_runtime_upgrade(true)); + ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost)); } } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index bdb6ff337cc3..dc7e28dc2943 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -2427,7 +2427,7 @@ mod multiplier_tests { #[cfg(all(test, feature = "try-runtime"))] mod remote_tests { use super::*; - use frame_try_runtime::runtime_decl_for_TryRuntime::TryRuntime; + use frame_try_runtime::{runtime_decl_for_TryRuntime::TryRuntime, UpgradeCheckSelect}; use remote_externalities::{ Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport, }; @@ -2435,6 +2435,10 @@ mod remote_tests { #[tokio::test] async fn run_migrations() { + if var("RUN_MIGRATION_TESTS").is_err() { + return + } + sp_tracing::try_init_simple(); let transport: Transport = var("WS").unwrap_or("wss://rpc.polkadot.io:443".to_string()).into(); @@ -2455,6 +2459,6 @@ mod remote_tests { .build() .await .unwrap(); - ext.execute_with(|| Runtime::on_runtime_upgrade(true)); + ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost)); } } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 9e2479110eab..c2a353a48ef0 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2099,7 +2099,7 @@ sp_api::impl_runtime_apis! { #[cfg(all(test, feature = "try-runtime"))] mod remote_tests { use super::*; - use frame_try_runtime::runtime_decl_for_TryRuntime::TryRuntime; + use frame_try_runtime::{runtime_decl_for_TryRuntime::TryRuntime, UpgradeCheckSelect}; use remote_externalities::{ Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport, }; @@ -2107,6 +2107,10 @@ mod remote_tests { #[tokio::test] async fn run_migrations() { + if var("RUN_MIGRATION_TESTS").is_err() { + return + } + sp_tracing::try_init_simple(); let transport: Transport = var("WS").unwrap_or("wss://rococo-rpc.polkadot.io:443".to_string()).into(); @@ -2127,6 +2131,6 @@ mod remote_tests { .build() .await .unwrap(); - ext.execute_with(|| Runtime::on_runtime_upgrade(true)); + ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost)); } } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index f3c74a1a0b4f..738b9611a2e3 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1850,7 +1850,7 @@ sp_api::impl_runtime_apis! { #[cfg(all(test, feature = "try-runtime"))] mod remote_tests { use super::*; - use frame_try_runtime::runtime_decl_for_TryRuntime::TryRuntime; + use frame_try_runtime::{runtime_decl_for_TryRuntime::TryRuntime, UpgradeCheckSelect}; use remote_externalities::{ Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport, }; @@ -1858,6 +1858,10 @@ mod remote_tests { #[tokio::test] async fn run_migrations() { + if var("RUN_MIGRATION_TESTS").is_err() { + return + } + sp_tracing::try_init_simple(); let transport: Transport = var("WS").unwrap_or("wss://westend-rpc.polkadot.io:443".to_string()).into(); @@ -1878,7 +1882,7 @@ mod remote_tests { .build() .await .unwrap(); - ext.execute_with(|| Runtime::on_runtime_upgrade(true)); + ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost)); } } diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 472790e970d8..ac77698f43cc 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -42,7 +42,7 @@ test-linux-stable: # but still want to have debug assertions. RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" script: - - time cargo test --workspace --profile testnet --verbose --locked --features=runtime-benchmarks,runtime-metrics + - time cargo test --workspace --profile testnet --verbose --locked --features=runtime-benchmarks,runtime-metrics,try-runtime .check-dependent-project: &check-dependent-project stage: test