diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17b3e994..ac0e8257 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,12 +110,15 @@ jobs: save-if: ${{ github.ref == 'refs/heads/main' }} # general examples + - run: cargo install just --locked + - name: "Rust Dataflow example" + timeout-minutes: 30 + working-directory: examples/rust-dataflow + run: just run + - name: "Build examples" timeout-minutes: 30 run: cargo build --examples - - name: "Rust Dataflow example" - timeout-minutes: 30 - run: cargo run --example rust-dataflow - name: "Multiple Daemons example" timeout-minutes: 30 run: cargo run --example multiple-daemons diff --git a/Cargo.toml b/Cargo.toml index 0852cb85..16208f2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,10 +101,6 @@ tokio-stream = "0.1.11" name = "c-dataflow" path = "examples/c-dataflow/run.rs" -[[example]] -name = "rust-dataflow" -path = "examples/rust-dataflow/run.rs" - [[example]] name = "rust-ros2-dataflow" path = "examples/rust-ros2-dataflow/run.rs" diff --git a/examples/rust-dataflow/.gitignore b/examples/rust-dataflow/.gitignore new file mode 100644 index 00000000..1fcb1529 --- /dev/null +++ b/examples/rust-dataflow/.gitignore @@ -0,0 +1 @@ +out diff --git a/examples/rust-dataflow/README.md b/examples/rust-dataflow/README.md new file mode 100644 index 00000000..fad6b6c0 --- /dev/null +++ b/examples/rust-dataflow/README.md @@ -0,0 +1,6 @@ +# Rust Dataflow Example + +This example uses the [`just`](https://github.com/casey/just) tool for building and running the dataflow: + +- Build: `just build` +- Run: `just run` diff --git a/examples/rust-dataflow/justfile b/examples/rust-dataflow/justfile new file mode 100644 index 00000000..68a353c7 --- /dev/null +++ b/examples/rust-dataflow/justfile @@ -0,0 +1,12 @@ +# you can use the installed `dora` command instead of this `cargo run` command +dora := "cargo run -p dora-cli --" + +# build dora and the example nodes/operators +build: + {{ dora }} build dataflow.yml + +# build and run the dataflow example +run: build + # The `--run-dataflow` argument is mostly meant for testing. It's recommended + # to instead run `dora daemon` in one terminal and `dora start dataflow.yml` in another + RUST_LOG=debug {{ dora }} daemon --run-dataflow dataflow.yml diff --git a/examples/rust-dataflow/run.rs b/examples/rust-dataflow/run.rs deleted file mode 100644 index f5e035a5..00000000 --- a/examples/rust-dataflow/run.rs +++ /dev/null @@ -1,46 +0,0 @@ -use dora_tracing::set_up_tracing; -use eyre::{bail, Context}; -use std::path::Path; - -#[tokio::main] -async fn main() -> eyre::Result<()> { - set_up_tracing("rust-dataflow-runner").wrap_err("failed to set up tracing subscriber")?; - - let root = Path::new(env!("CARGO_MANIFEST_DIR")); - std::env::set_current_dir(root.join(file!()).parent().unwrap()) - .wrap_err("failed to set working dir")?; - - let dataflow = Path::new("dataflow.yml"); - build_dataflow(dataflow).await?; - - run_dataflow(dataflow).await?; - - Ok(()) -} - -async fn build_dataflow(dataflow: &Path) -> eyre::Result<()> { - let cargo = std::env::var("CARGO").unwrap(); - let mut cmd = tokio::process::Command::new(&cargo); - cmd.arg("run"); - cmd.arg("--package").arg("dora-cli"); - cmd.arg("--").arg("build").arg(dataflow); - if !cmd.status().await?.success() { - bail!("failed to build dataflow"); - }; - Ok(()) -} - -async fn run_dataflow(dataflow: &Path) -> eyre::Result<()> { - let cargo = std::env::var("CARGO").unwrap(); - let mut cmd = tokio::process::Command::new(&cargo); - cmd.arg("run"); - cmd.arg("--package").arg("dora-cli"); - cmd.arg("--") - .arg("daemon") - .arg("--run-dataflow") - .arg(dataflow); - if !cmd.status().await?.success() { - bail!("failed to run dataflow"); - }; - Ok(()) -}