Browse Source

Use `just` tool to run rust-dataflow example

just
Philipp Oppermann 1 year ago
parent
commit
26c39eaefb
Failed to extract signature
6 changed files with 25 additions and 53 deletions
  1. +6
    -3
      .github/workflows/ci.yml
  2. +0
    -4
      Cargo.toml
  3. +1
    -0
      examples/rust-dataflow/.gitignore
  4. +6
    -0
      examples/rust-dataflow/README.md
  5. +12
    -0
      examples/rust-dataflow/justfile
  6. +0
    -46
      examples/rust-dataflow/run.rs

+ 6
- 3
.github/workflows/ci.yml View File

@@ -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


+ 0
- 4
Cargo.toml View File

@@ -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"


+ 1
- 0
examples/rust-dataflow/.gitignore View File

@@ -0,0 +1 @@
out

+ 6
- 0
examples/rust-dataflow/README.md View File

@@ -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`

+ 12
- 0
examples/rust-dataflow/justfile View File

@@ -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

+ 0
- 46
examples/rust-dataflow/run.rs View File

@@ -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(())
}

Loading…
Cancel
Save