12 releases

0.1.8 Mar 16, 2024
0.1.7 Mar 15, 2024
0.1.4 Feb 20, 2024
0.1.3 Oct 1, 2023
0.1.0 Aug 23, 2023

#332 in Network programming

Download history 1/week @ 2023-12-25 7/week @ 2024-02-12 246/week @ 2024-02-19 54/week @ 2024-02-26 283/week @ 2024-03-04 389/week @ 2024-03-11 53/week @ 2024-03-18 16/week @ 2024-03-25 67/week @ 2024-04-01

804 downloads per month
Used in 5 crates

MIT license

125KB
4K SLoC

Astro run

Astro Run is a highly extensible runner that can execute any workflow.

astro-run CI codecov MIT

Features

Example

Dependencies

Add the following to your Cargo.toml file:

[dependencies]
astro-run = "0.1"

Code Example

use astro_run::{stream, AstroRun, RunResult, Workflow};

struct Runner;

impl Runner {
  fn new() -> Self {
    Runner
  }
}

#[astro_run::async_trait]
impl astro_run::Runner for Runner {
  async fn run(&self, ctx: astro_run::Context) -> astro_run::RunResponse {
    let (tx, rx) = stream();

    tokio::task::spawn(async move {
      // Send running log
      tx.log(ctx.command.run);

      // Send success log
      tx.end(RunResult::Succeeded);
    });

    Ok(rx)
  }
}

#[tokio::main]
async fn main() {
  // Create astro run
  let astro_run = AstroRun::builder().runner(Runner::new()).build();

  // Workflow
  let workflow = r#"
jobs:
  job:
    name: Job
    steps:
      - run: Hello World
  "#;

  // Create workflow
  let workflow = Workflow::builder()
    .config(workflow)
    .build(&astro_run)
    .await
    .unwrap();

  // Create a new execution context
  let ctx = astro_run.execution_context().build();

  // Run workflow
  let _res = workflow.run(ctx).await;
}

Astro Run only defines the interface for Runners. Users can implement their own desired Runners, e.g., Docker runner.

More Examples

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the project.

License

This project is licensed under the MIT License.

Dependencies

~18–33MB
~617K SLoC