First commit

This commit is contained in:
continuist 2025-04-13 00:08:55 -04:00
parent 8660b42cfb
commit da406d4943
9 changed files with 2113 additions and 0 deletions

View file

@ -0,0 +1,20 @@
name: Pipeline main branch
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest # Or other appropriate runner
steps:
- uses: actions/checkout@v4 # Checkout the repository
- name: Install Rust toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -
source $HOME/.cargo/env
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

2001
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

38
Cargo.toml Normal file
View file

@ -0,0 +1,38 @@
[package]
name = "rust_app"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
publish = false
[workspace]
members = ["crates/server"]
[workspace.package]
authors = ["continuist <continuist02@gmail.com>"]
version = "0.0.0"
edition = "2021"
rust-version = "1.81.0"
[[bin]]
name = "web"
path = "src/bin/web.rs"
[dependencies]
axum = { version = "0.8.3" }
reqwest = { version = "0.12.15" }
tokio = { version = "1.26", features = ["full"] }
axum-test = "17.3.0"
server = "=0.0.0"
[patch.crates-io]
server = { path = "crates/server" }
[profile.release]
lto = true
opt-level = 3
codegen-units = 1
strip = true

11
crates/server/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "server"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
publish = false
[dependencies]
axum = { version = "0.8.3" }
tokio = { version = "1.26", features = ["full"] }

1
crates/server/src/lib.rs Normal file
View file

@ -0,0 +1 @@
pub mod server;

View file

@ -0,0 +1,12 @@
use axum::{
routing::get,
Router,
};
async fn hello_world() -> &'static str {
"Hello, World!"
}
pub async fn create_app() -> Router {
Router::new().route("/", get(hello_world))
}

11
src/bin/web.rs Normal file
View file

@ -0,0 +1,11 @@
use server::server::create_app;
#[tokio::main]
async fn main() {
let app = create_app().await;
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}

18
tests/test_hello.rs Normal file
View file

@ -0,0 +1,18 @@
#[tokio::test]
async fn test_hello_route() {
use axum_test::TestServer;
use server::server::create_app;
// Create a TestServer with your application
let app = create_app().await;
let server = TestServer::new(app).unwrap();
// Make a request to the `/hello` route
let response = server.get("/").await;
// Assert that the status code is OK (200)
response.assert_status_ok();
// Assert that the response body contains the expected text
response.assert_text("Hello, World!");
}