diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..5d74df1 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,33 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + name: pre-commit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.0 + test: + name: tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test diff --git a/backend/src/main.rs b/backend/src/main.rs index db18daf..874cb52 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -114,30 +114,3 @@ async fn main() -> std::io::Result<()> { .run() .await } - -#[cfg(test)] -mod tests { - use super::*; - use actix_web::test; - - #[actix_web::test] - async fn user_routes() { - std::env::set_var("RUST_LOG", "actix_web=debug"); - env_logger::init(); - dotenv::dotenv().ok(); - - let connspec = std::env::var("DATABASE_URL").expect("DATABASE_URL"); - let manager = ConnectionManager::::new(connspec); - let pool = r2d2::Pool::builder() - .build(manager) - .expect("Failed to create pool."); - - let _app = test::init_service( - App::new() - .app_data(web::Data::new(pool.clone())) - .wrap(middleware::Logger::default()), // .service(get_user) - // .service(add_user), - ) - .await; - } -}