add github workflow
This commit is contained in:
33
.github/workflows/rust.yml
vendored
Normal file
33
.github/workflows/rust.yml
vendored
Normal file
@@ -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
|
||||||
@@ -114,30 +114,3 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.run()
|
.run()
|
||||||
.await
|
.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::<PgConnection>::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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user