1
0
mirror of https://github.com/actix/examples synced 2024-12-03 18:22:14 +01:00

fix diesel test in CI (#592)

This commit is contained in:
Rob Ede 2022-12-12 02:41:22 +00:00 committed by GitHub
parent fbf376db47
commit a814ac0d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 26 deletions

View File

@ -32,33 +32,39 @@ jobs:
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2.2.0
- name: Create test DBs
- name: Install DB CLI tools
run: |
cargo install sqlx-cli --no-default-features --features=rustls,sqlite
cargo install diesel_cli --no-default-features --features sqlite
- name: Create Test DBs
env:
DATABASE_URL: sqlite://./todo.db
run: |
sudo apt-get update && sudo apt-get install sqlite3
cargo install sqlx-cli --no-default-features --features=rustls,sqlite
cd basics/todo
DATABASE_URL="sqlite://./todo.db" sqlx database create
sqlx database create
chmod a+rwx todo.db
DATABASE_URL="sqlite://./todo.db" sqlx migrate run
sqlx migrate run
- name: cargo check
uses: actions-rs/cargo@v1
run: cargo check --workspace --bins --examples --tests
timeout-minutes: 30
with:
command: check
args: --workspace --bins --examples --tests
- name: start redis
- name: Start Redis
uses: supercharge/redis-github-action@1.1.0
with: { redis-version: 6 }
# - name: run diesel migrations
# run: |
# cargo install diesel_cli --no-default-features --features sqlite
# cd databases/diesel
# diesel migration run
# chmod a+rwx test.db
- name: cargo test
run: cargo test --workspace --all-features --no-fail-fast -- --nocapture
run: cargo test --workspace --all-features --no-fail-fast --exclude=diesel-example -- --nocapture
timeout-minutes: 30
- name: cargo test (diesel)
env:
DATABASE_URL: test.db
run: |
cd databases/diesel
diesel migration run
chmod a+rwx test.db
cargo test -p=diesel-example --all-features --no-fail-fast -- --nocapture
timeout-minutes: 10

3
Cargo.lock generated
View File

@ -5118,7 +5118,8 @@ dependencies = [
[[package]]
name = "r2d2_mysql"
version = "23.0.0"
source = "git+https://github.com/outersky/r2d2-mysql.git?rev=v23.0.0#5827ac32742f505d60590707e1f79ba735668dca"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9733d738ce65959a744f387bae69aa690a867e18d48e5486b171c47bc7b0c575"
dependencies = [
"mysql",
"r2d2",

View File

@ -63,7 +63,3 @@ members = [
"websockets/echo",
]
resolver = "2"
[patch.crates-io.r2d2_mysql]
git = "https://github.com/outersky/r2d2-mysql.git"
rev = "v23.0.0"

View File

@ -13,5 +13,5 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
[dev-dependencies]
actix-test = "0.1.0-beta.11"
time = "0.3.7"
actix-test = "0.1"
time = "0.3"

View File

@ -100,8 +100,8 @@ mod tests {
env_logger::init();
dotenv::dotenv().ok();
let connspec = std::env::var("DATABASE_URL").expect("DATABASE_URL");
let manager = ConnectionManager::<SqliteConnection>::new(connspec);
let conn_spec = std::env::var("DATABASE_URL").expect("DATABASE_URL");
let manager = ConnectionManager::<SqliteConnection>::new(conn_spec);
let pool = r2d2::Pool::builder()
.build(manager)
.expect("Failed to create pool.");