You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use std::path::{Path, PathBuf};
  2. use xshell::{cmd, Shell};
  3. fn main() -> eyre::Result<()> {
  4. // create a new shell in this folder
  5. let sh = prepare_shell()?;
  6. // build the `dora` binary (you can skip this if you use `cargo install dora-cli`)
  7. let dora = prepare_dora_optimized(&sh)?;
  8. // build the dataflow using `dora build`
  9. cmd!(sh, "{dora} build dataflow.yml").run()?;
  10. // start up the dora daemon and coordinator
  11. cmd!(sh, "{dora} up").run()?;
  12. // start running the dataflow.yml
  13. cmd!(sh, "{dora} start dataflow.yml --attach").run()?;
  14. // stop the dora daemon and coordinator again
  15. cmd!(sh, "{dora} destroy").run()?;
  16. Ok(())
  17. }
  18. /// Prepares a shell and set the working directory to the parent folder of this file.
  19. ///
  20. /// You can use your system shell instead (e.g. `bash`);
  21. fn prepare_shell() -> Result<Shell, eyre::Error> {
  22. let sh = Shell::new()?;
  23. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  24. sh.change_dir(root.join(file!()).parent().unwrap());
  25. Ok(sh)
  26. }
  27. /// Build the `dora` command-line executable from this repo.
  28. ///
  29. /// You can skip this step and run `cargo install dora-cli --locked` instead.
  30. fn prepare_dora_optimized(sh: &Shell) -> eyre::Result<PathBuf> {
  31. cmd!(sh, "cargo build --package dora-cli --release").run()?;
  32. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  33. let dora = root.join("target").join("release").join("dora");
  34. Ok(dora)
  35. }