Skip to content

xtask: remove node binary from path #234

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions xtask/src/cli.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,10 @@ pub mod test {
use clap::Args;
#[derive(Debug, Args)]
pub struct Params {
/// If the test is executed in CI
#[clap(long, default_value = "false")]
pub ci: bool,

#[clap(flatten)]
pub build: BuildParams,

30 changes: 30 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ fn main() -> anyhow::Result<()> {
}

fn test(params: test::Params) -> anyhow::Result<()> {
set_path(params.ci)?;

build::build(params.build)?;

// the variables must be kept alive and not dropped
@@ -39,6 +41,34 @@ fn test(params: test::Params) -> anyhow::Result<()> {
Ok(())
}

fn set_path(ci: bool) -> anyhow::Result<()> {
let path = std::env::var("PATH").unwrap_or_else(|_| "".to_string());
let new_path = if ci {
// To ensure persistent storage between runs,
// all cargo binaries are compiled in the following folder in ci
format!("/cargo_target/release/:{}", path)
} else {
// adding target/release/ and demo/sovereign/target/release to path
// so that zombienet will find sugondat-node as command
// and the test can be shared between local testing and ci
#[rustfmt::skip]
let project_dir = duct::cmd!(
"sh", "-c",
"cargo locate-project | jq -r '.root' | grep -oE '^.*/'"
)
.stdout_capture()
.run()?;
let project_dir = std::str::from_utf8(&project_dir.stdout)?.trim();

format!(
"{}target/release/:{}demo/sovereign/target/release:{}",
project_dir, project_dir, path
)
};
std::env::set_var("PATH", new_path);
Ok(())
}

fn init_logging() -> anyhow::Result<()> {
use tracing_subscriber::fmt;
use tracing_subscriber::prelude::*;
4 changes: 2 additions & 2 deletions xtask/src/shim.rs
Original file line number Diff line number Diff line change
@@ -13,13 +13,13 @@ impl Shim {
// Wait for the shim to be connected, which indicates that the network is ready
with_logs(
"Wait for the network to be ready",
cmd!("sugondat-shim", "query", "block", "--wait", "1",).dir("target/release/"),
cmd!("sugondat-shim", "query", "block", "--wait", "1"),
)
.run()?;

let shim_handle = with_logs(
"Launching Shim",
cmd!("sugondat-shim", "serve", "--submit-dev-alice").dir("target/release/"),
cmd!("sugondat-shim", "serve", "--submit-dev-alice"),
)
.start()?;

9 changes: 3 additions & 6 deletions xtask/src/sovereign.rs
Original file line number Diff line number Diff line change
@@ -22,14 +22,11 @@ impl Sovereign {
let with_logs = create_with_logs(params.log_path.clone());

//TODO: https://github.com/thrumdev/blobs/issues/227
#[rustfmt::skip]
let sovereign_handle = with_logs(
"Launching sovereign rollup",
cmd!(
"sh", "-c",
"cd demo/sovereign/demo-rollup && ./../target/release/sov-demo-rollup"
),
).start()?;
cmd!("sov-demo-rollup").dir("demo/sovereign/demo-rollup/"),
)
.start()?;

Ok(Self {
process: sovereign_handle,
6 changes: 0 additions & 6 deletions xtask/src/zombienet.rs
Original file line number Diff line number Diff line change
@@ -37,12 +37,6 @@ impl Zombienet {
To obtain, refer to https://github.com/paritytech/polkadot-sdk/tree/master/polkadot#polkadot"
)?;

check_binary(
"sugondat-node",
"'sugondat-node' is not found in PATH. \n \
cd to 'sugondat/chain' and run 'cargo build --release' and add the result into your PATH."
)?;

tracing::info!("Zombienet logs redirected to {}", params.log_path);
let with_logs = create_with_logs(params.log_path);