Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Enable try-runtime flag in CI (#6587)
Browse files Browse the repository at this point in the history
* Env gate tests

The CI should check that it compiles, but not run it.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Enable try-runtime feature in CI

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fix test

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez authored Jan 26, 2023
1 parent 7420e80 commit 38c820b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
8 changes: 6 additions & 2 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2231,14 +2231,18 @@ 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,
};
use std::env::var;

#[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();
Expand All @@ -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));
}
}
8 changes: 6 additions & 2 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2427,14 +2427,18 @@ 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,
};
use std::env::var;

#[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();
Expand All @@ -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));
}
}
8 changes: 6 additions & 2 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2099,14 +2099,18 @@ 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,
};
use std::env::var;

#[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();
Expand All @@ -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));
}
}
8 changes: 6 additions & 2 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1850,14 +1850,18 @@ 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,
};
use std::env::var;

#[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();
Expand All @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/gitlab/pipeline/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38c820b

Please sign in to comment.