Skip to content

Commit c1dd91d

Browse files
gabriele-0201pepyakin
authored andcommitted
xtask: require all binaries to be in the path
1 parent e4746a4 commit c1dd91d

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

xtask/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,13 @@ fn init_logging() -> anyhow::Result<()> {
5151
.try_init()?;
5252
Ok(())
5353
}
54+
55+
fn check_binary(binary: &'static str, error_msg: &'static str) -> anyhow::Result<()> {
56+
if let Err(_) = duct::cmd!("sh", "-c", format!("command -v {}", binary))
57+
.stdout_null()
58+
.run()
59+
{
60+
anyhow::bail!(error_msg);
61+
}
62+
Ok(())
63+
}

xtask/src/shim.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{cli::test::ShimParams, logging::create_with_logs};
1+
use crate::{check_binary, cli::test::ShimParams, logging::create_with_logs};
22
use duct::cmd;
33
use tracing::info;
44

@@ -7,19 +7,25 @@ pub struct Shim(duct::Handle);
77
impl Shim {
88
// Try launching the shim, it requires an up an running ikura-node
99
pub fn try_new(params: ShimParams) -> anyhow::Result<Self> {
10+
check_binary(
11+
"ikura-shim",
12+
"'ikura-node' is not found in PATH. \n \
13+
cd to 'ikura/shim' and run 'cargo build --release' and add the result into your PATH.",
14+
)?;
15+
1016
tracing::info!("Shim logs redirected to {}", params.log_path);
1117
let with_logs = create_with_logs(params.log_path);
1218

1319
// Wait for the shim to be connected, which indicates that the network is ready
1420
with_logs(
1521
"Wait for the network to be ready",
16-
cmd!("ikura-shim", "query", "block", "--wait", "1",).dir("target/release/"),
22+
cmd!("ikura-shim", "query", "block", "--wait", "1"),
1723
)
1824
.run()?;
1925

2026
let shim_handle = with_logs(
2127
"Launching Shim",
22-
cmd!("ikura-shim", "serve", "--submit-dev-alice").dir("target/release/"),
28+
cmd!("ikura-shim", "serve", "--submit-dev-alice"),
2329
)
2430
.start()?;
2531

xtask/src/sovereign.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{cli::test::SovereignParams, logging::create_with_logs};
1+
use crate::{check_binary, cli::test::SovereignParams, logging::create_with_logs};
22
use anyhow::bail;
33
use duct::cmd;
44
use tracing::info;
@@ -18,6 +18,12 @@ impl Sovereign {
1818
.stdout_null()
1919
.run()?;
2020

21+
check_binary(
22+
"sov-demo-rollup",
23+
"'sov-demo-rollup' is not found in PATH. \n \
24+
cd to 'demo/sovereign/demo-rollup' and run 'cargo build --release' and add the result into your PATH."
25+
)?;
26+
2127
info!("Sovereign logs redirected to {}", params.log_path);
2228
let with_logs = create_with_logs(params.log_path.clone());
2329

@@ -27,7 +33,7 @@ impl Sovereign {
2733
"Launching sovereign rollup",
2834
cmd!(
2935
"sh", "-c",
30-
"cd demo/sovereign/demo-rollup && ./../target/release/sov-demo-rollup"
36+
"cd demo/sovereign/demo-rollup && sov-demo-rollup"
3137
),
3238
).start()?;
3339

@@ -39,16 +45,21 @@ impl Sovereign {
3945

4046
// All the networks must be up (relaychain and ikura-node), including the sovereign rollup."
4147
pub fn test_sovereign_rollup(&self) -> anyhow::Result<()> {
48+
check_binary(
49+
"sov-cli",
50+
"'sov-cli' is not found in PATH. \n \
51+
cd to 'demo/sovereign/demo-rollup' and run 'cargo build --release' and add the result into your PATH."
52+
)?;
53+
4254
info!("Running sovereign rollup test");
4355

4456
//TODO: https://github.com/thrumdev/blobs/issues/227
45-
let cli = "../target/release/sov-cli";
4657
let test_data_path = "../test-data/";
4758
let run_cli_cmd =
4859
|description: &str, args: &str| -> std::io::Result<std::process::Output> {
4960
let args = [
5061
"-c",
51-
&format!("cd demo/sovereign/demo-rollup/ && ./{} {}", cli, args),
62+
&format!("cd demo/sovereign/demo-rollup/ && sov-cli {}", args),
5263
];
5364

5465
(self.with_logs)(description, duct::cmd("sh", args)).run()

xtask/src/zombienet.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{cli::test::ZombienetParams, logging::create_with_logs};
1+
use crate::{check_binary, cli::test::ZombienetParams, logging::create_with_logs};
22
use duct::cmd;
33
use tracing::info;
44

@@ -15,15 +15,6 @@ impl Zombienet {
1515
cmd!("rm", "-r", "zombienet").unchecked().run()?;
1616

1717
info!("Checking binaries availability");
18-
let check_binary = |binary: &'static str, error_msg: &'static str| -> anyhow::Result<()> {
19-
if let Err(_) = cmd!("sh", "-c", format!("command -v {}", binary))
20-
.stdout_null()
21-
.run()
22-
{
23-
anyhow::bail!(error_msg);
24-
}
25-
Ok(())
26-
};
2718

2819
check_binary(
2920
"zombienet",

0 commit comments

Comments
 (0)