Browse Source

Add a `rust-dataflow-git` example and run it on CI

tags/v0.3.12-rc0
Philipp Oppermann 9 months ago
parent
commit
1eae50adb3
Failed to extract signature
5 changed files with 95 additions and 0 deletions
  1. +3
    -0
      .github/workflows/ci.yml
  2. +4
    -0
      Cargo.toml
  3. +7
    -0
      examples/rust-dataflow-git/README.md
  4. +29
    -0
      examples/rust-dataflow-git/dataflow.yml
  5. +52
    -0
      examples/rust-dataflow-git/run.rs

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

@@ -118,6 +118,9 @@ jobs:
- name: "Rust Dataflow example" - name: "Rust Dataflow example"
timeout-minutes: 30 timeout-minutes: 30
run: cargo run --example rust-dataflow run: cargo run --example rust-dataflow
- name: "Rust Git Dataflow example"
timeout-minutes: 30
run: cargo run --example rust-dataflow-git
- name: "Multiple Daemons example" - name: "Multiple Daemons example"
timeout-minutes: 30 timeout-minutes: 30
run: cargo run --example multiple-daemons run: cargo run --example multiple-daemons


+ 4
- 0
Cargo.toml View File

@@ -132,6 +132,10 @@ path = "examples/vlm/run.rs"
name = "rust-dataflow" name = "rust-dataflow"
path = "examples/rust-dataflow/run.rs" path = "examples/rust-dataflow/run.rs"


[[example]]
name = "rust-dataflow-git"
path = "examples/rust-dataflow-git/run.rs"

[[example]] [[example]]
name = "rust-ros2-dataflow" name = "rust-ros2-dataflow"
path = "examples/rust-ros2-dataflow/run.rs" path = "examples/rust-ros2-dataflow/run.rs"


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

@@ -0,0 +1,7 @@
# Git-based Rust example

To get started:

```bash
cargo run --example rust-dataflow-git
```

+ 29
- 0
examples/rust-dataflow-git/dataflow.yml View File

@@ -0,0 +1,29 @@
nodes:
- id: rust-node
git: https://github.com/dora-rs/dora.git
rev: e31b2a34 # pinned commit, update this when changing the message crate
build: cargo build -p rust-dataflow-example-node
path: target/debug/rust-dataflow-example-node
inputs:
tick: dora/timer/millis/10
outputs:
- random

- id: rust-status-node
git: https://github.com/dora-rs/dora.git
rev: e31b2a34 # pinned commit, update this when changing the message crate
build: cargo build -p rust-dataflow-example-status-node
path: target/debug/rust-dataflow-example-status-node
inputs:
tick: dora/timer/millis/100
random: rust-node/random
outputs:
- status

- id: rust-sink
git: https://github.com/dora-rs/dora.git
rev: e31b2a34 # pinned commit, update this when changing the message crate
build: cargo build -p rust-dataflow-example-sink
path: target/debug/rust-dataflow-example-sink
inputs:
message: rust-status-node/status

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

@@ -0,0 +1,52 @@
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 args: Vec<String> = std::env::args().collect();
let dataflow = if args.len() > 1 {
Path::new(&args[1])
} else {
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