Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xtask simple CI #5

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --manifest-path xtask/Cargo.toml --"
27 changes: 27 additions & 0 deletions .github/workflows/xtask.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Runner for CI

on:
workflow_call:
push:
pull_request:
branches: [main]
types:
- opened
- ready_for_review

jobs:
build:
name: CI Xtask
runs-on: ubuntu-latest

steps:
- uses: dtolnay/rust-toolchain@stable
with:
target: x86_64-unknown-linux-gnu

- uses: actions/checkout@v3

- name: compile check
run: |
cargo clippy -- -D warnings
cargo xtask run
3 changes: 2 additions & 1 deletion examples/simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ impl HelloWorldActor {
{
self.say_hello().await;
reply.send(())
}.ok();
}
.ok();
}
HelloWorldEvent::Start => {
self.state = ActorState::Running;
Expand Down
3 changes: 2 additions & 1 deletion examples/supervised_simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ impl HelloWorldActor {
{
self.say_hello().await;
reply.send(())
}.ok();
}
.ok();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion examples/supervisor_core/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ impl HelloWorldActor {
{
self.say_hello().await;
reply.send(())
}.ok();
}
.ok();
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "xtask"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.86"
36 changes: 36 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::{env, path::Path, process::Command};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let task = if let Some(task) = std::env::args().nth(1) {
task
} else {
"build".to_string()
};

match task.as_str() {
"build" => command("build"),
"run" => command("run"),
_ => return Err(anyhow::anyhow! { "Unknown command" }.into()),
}?;

Ok(())
}

fn command(input: &str) -> Result<(), Box<dyn std::error::Error>> {
let cargo: String = env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
let status = Command::new(cargo)
.current_dir(
Path::new(&env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(1)
.unwrap()
.to_path_buf(),
)
.args([input, "--release", "--example", "simple"])
.status()?;

if !status.success() {
return Err(anyhow::anyhow! { "example run step failed" }.into());
}
Ok(())
}
Loading