diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..3bf0fae --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,38 @@ +name: Rust CI + +on: + push: + branches: [ "v0.2" ] # Changed from main to master + pull_request: + branches: [ "v0.2" ] # Changed from main to master + +jobs: + build: + + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - name: Install Rust 1.85.0 + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.85.0 + components: clippy, rustfmt + override: true + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + - name: Build + run: | + mkdir -p ~/.ssh + echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitea_deploy_key + chmod 600 ~/.ssh/gitea_deploy_key + ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts + eval $(ssh-agent -s) + ssh-add -v ~/.ssh/gitea_deploy_key + cargo build --verbose --release + - name: Run tests + run: cargo test --verbose + - name: Run clippy + run: cargo clippy -- -D warnings + - name: Run rustfmt + run: cargo fmt --all -- --check diff --git a/Cargo.toml b/Cargo.toml index cc9a92b..9920c88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,10 @@ version = "0.2.0" edition = "2024" [dependencies] +axum = { version = "0.8.3" } +serde = { version = "1.0.218", features = ["derive"] } +serde_json = { version = "1.0.139" } +tokio = { version = "1.44.1", features = ["rt-multi-thread"] } +tracing-subscriber = "0.3.19" +icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.1.0-main-0dc8c153d2-680" } +icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" } diff --git a/src/main.rs b/src/main.rs index e7a11a9..2ec5576 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,41 @@ -fn main() { - println!("Hello, world!"); +use axum::{ + // Json, + Router, + // http::StatusCode, + // routing::{get, post}, + routing::get, +}; +// use serde::{Deserialize, Serialize}; + +#[tokio::main] +async fn main() { + // initialize tracing + tracing_subscriber::fmt::init(); + + // build our application with a route + let app = Router::new() + // `GET /` goes to `root` + .route("/", get(root)); + // `POST /users` goes to `create_user` + // .route("/users", post(create_user)); + + // run our app with hyper, listening globally on port 3000 + let listener = tokio::net::TcpListener::bind(get_full()).await.unwrap(); + axum::serve(listener, app).await.unwrap(); +} + +fn get_full() -> String { + get_address() + ":" + &get_port() +} +fn get_address() -> String { + String::from("0.0.0.0") +} + +fn get_port() -> String { + String::from("3000") +} + +// basic handler that responds with a static string +async fn root() -> &'static str { + "Hello, World!" }