Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to test against CockroachDB #628

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,43 @@ jobs:
DATABASE_URL: "postgres://postgres:postgres@localhost/test_db"
MINIO_URL: "http://127.0.0.1:9000"
REDIS_URL: "redis://localhost"

test-cockroach:
name: Test against CockroachDB
runs-on: ubuntu-latest
services:
minio:
image: bitnami/minio
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- 9000:9000
cockroach:
image: timveil/cockroachdb-single-node:latest
ports:
- 26257:26257
env:
DATABASE_NAME: test_db
redis:
image: valkey/valkey:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: Swatinem/rust-cache@v2
- uses: rui314/setup-mold@v1
- uses: taiki-e/install-action@nextest
- run: nix develop --impure --command bash -c "unset LD_LIBRARY_PATH && cargo nextest run --all-features"
env:
DATABASE_URL: "postgres://root@localhost:26257/test_db"
DB_SETUP_NO_TEMPLATE: "1"
MINIO_URL: "http://127.0.0.1:9000"
REDIS_URL: "redis://localhost"
12 changes: 6 additions & 6 deletions crates/kitsune-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ where

let mut admin_conn = AsyncPgConnection::establish(url.as_str()).await.unwrap();

admin_conn
.batch_execute(&format!(
"CREATE DATABASE {db_name} ENCODING 'UTF8' TEMPLATE template0"
))
.await
.unwrap();
let mut query = format!("CREATE DATABASE {db_name} ENCODING 'UTF8'");
if env::var("DB_SETUP_NO_TEMPLATE").is_err() {
query.push_str(" TEMPLATE template0");
}

admin_conn.batch_execute(&query).await.unwrap();

url.set_path(&db_name);

Expand Down
Loading