diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4333654 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: ci + +on: + push: + branches: ["main"] + tags: ["*"] + pull_request: + branches: ["main"] + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dsherret/rust-toolchain-file@v1 + + - name: Install protoc + uses: arduino/setup-protoc@v2 + with: + version: "21.12" + + - name: Check formatting + run: cargo fmt -- --check + + - name: Check linting + run: cargo clippy --all-targets --all-features -- -D clippy::all + + - name: Build + run: cargo build --all-targets --all-features --tests -v + + - name: Test + run: cargo test + + - name: Publish + if: | + contains(matrix.os, 'ubuntu') && + github.repository == 'denoland/denokv' && + startsWith(github.ref, 'refs/tags/') + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: | + cargo publish -vv -p denokv_proto + cargo publish -vv -p denokv_sqlite diff --git a/Cargo.lock b/Cargo.lock index 6664df6..57ba834 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,7 +157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] -name = "deno_kv_proto" +name = "denokv_proto" version = "0.1.0" dependencies = [ "anyhow", @@ -171,13 +171,13 @@ dependencies = [ ] [[package]] -name = "deno_kv_sqlite" +name = "denokv_sqlite" version = "0.1.0" dependencies = [ "anyhow", "async-trait", "chrono", - "deno_kv_proto", + "denokv_proto", "futures", "log", "num-bigint", @@ -455,6 +455,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" dependencies = [ + "cc", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index e331ca5..5f5734e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ num-bigint = "0.4" prost = "0.11" prost-build = "0.11" rand = "0.8.5" -rusqlite = "0.29.0" +rusqlite = { version = "0.29.0" } serde = { version = "1", features = ["derive"] } serde_json = "1.0.107" tokio = { version = "1.33.0", features = ["full"] } diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 7c83696..9b16d86 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "deno_kv_proto" +name = "denokv_proto" version = "0.1.0" edition.workspace = true license.workspace = true diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..b44c3df --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.73.0" +components = ["rustfmt", "clippy"] diff --git a/sqlite/Cargo.toml b/sqlite/Cargo.toml index c77b9d6..d01eec1 100644 --- a/sqlite/Cargo.toml +++ b/sqlite/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "deno_kv_sqlite" +name = "denokv_sqlite" version = "0.1.0" edition.workspace = true license.workspace = true @@ -9,11 +9,15 @@ authors.workspace = true [lib] path = "lib.rs" +[features] +default = ["bundled"] +bundled = ["rusqlite/bundled"] + [dependencies] anyhow.workspace = true async-trait.workspace = true chrono.workspace = true -deno_kv_proto = { path = "../proto" } +denokv_proto = { path = "../proto" } futures.workspace = true log.workspace = true num-bigint.workspace = true diff --git a/sqlite/backend.rs b/sqlite/backend.rs index eb818e1..8057c7f 100644 --- a/sqlite/backend.rs +++ b/sqlite/backend.rs @@ -5,18 +5,18 @@ use std::time::Duration; use anyhow::anyhow; use chrono::DateTime; use chrono::Utc; -use deno_kv_proto::decode_value; -use deno_kv_proto::encode_value; -use deno_kv_proto::encode_value_owned; -use deno_kv_proto::AtomicWrite; -use deno_kv_proto::CommitResult; -use deno_kv_proto::KvEntry; -use deno_kv_proto::MutationKind; -use deno_kv_proto::ReadRange; -use deno_kv_proto::ReadRangeOutput; -use deno_kv_proto::SnapshotReadOptions; -use deno_kv_proto::Value; -use deno_kv_proto::VALUE_ENCODING_V8; +use denokv_proto::decode_value; +use denokv_proto::encode_value; +use denokv_proto::encode_value_owned; +use denokv_proto::AtomicWrite; +use denokv_proto::CommitResult; +use denokv_proto::KvEntry; +use denokv_proto::MutationKind; +use denokv_proto::ReadRange; +use denokv_proto::ReadRangeOutput; +use denokv_proto::SnapshotReadOptions; +use denokv_proto::Value; +use denokv_proto::VALUE_ENCODING_V8; use rand::Rng; use rand::RngCore; use rusqlite::params; diff --git a/sqlite/lib.rs b/sqlite/lib.rs index 435e73f..39f9643 100644 --- a/sqlite/lib.rs +++ b/sqlite/lib.rs @@ -14,13 +14,13 @@ use crate::backend::SqliteBackend; pub use crate::backend::TypeError; use chrono::DateTime; use chrono::Utc; -use deno_kv_proto::AtomicWrite; -use deno_kv_proto::CommitResult; -use deno_kv_proto::Database; -use deno_kv_proto::QueueMessageHandle; -use deno_kv_proto::ReadRange; -use deno_kv_proto::ReadRangeOutput; -use deno_kv_proto::SnapshotReadOptions; +use denokv_proto::AtomicWrite; +use denokv_proto::CommitResult; +use denokv_proto::Database; +use denokv_proto::QueueMessageHandle; +use denokv_proto::ReadRange; +use denokv_proto::ReadRangeOutput; +use denokv_proto::SnapshotReadOptions; use futures::future::Either; use rand::RngCore; pub use rusqlite::Connection;