Skip to content

Commit

Permalink
[CI] Add sdk build test (#4092)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel-keller committed May 24, 2024
1 parent 7495611 commit bbab9fb
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 3 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ jobs:

test:
name: Test workspace
runs-on: ["self-hosted", "arm64", "builder"]
runs-on: [ "self-hosted", "arm64", "builder" ]
steps:
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -344,6 +344,35 @@ jobs:
path: target/llvm-cov/html/
retention-days: 5

test-sdk-build:
name: Test SDK build
runs-on: ubuntu-latest
steps:
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Checkout sources
uses: actions/checkout@v4

- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install dependencies
run: |
sudo apt-get -y update
- name: Build local
working-directory: tests/sdk/local
run: cargo build

- name: Build remote
working-directory: tests/sdk/remote
run: cargo build

ws-engine:
name: WebSocket engine
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Temporary Items
/lib/cache/
/lib/store/
/lib/target/
/tests/sdk/*/Cargo.lock
/tests/sdk/*/target

.idea/
.vscode/
/result
Expand Down
6 changes: 4 additions & 2 deletions core/src/kvs/ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,22 +1021,25 @@ impl Datastore {
/// Ok(())
/// }
/// ```
#[allow(unreachable_code)]
pub async fn transaction(
&self,
write: TransactionType,
lock: LockType,
) -> Result<Transaction, Error> {
#![allow(unused_variables)]
#[allow(unused_variables)]
let write = match write {
Read => false,
Write => true,
};

#[allow(unused_variables)]
let lock = match lock {
Pessimistic => true,
Optimistic => false,
};

#[allow(unused_variables)]
let inner = match &self.inner {
#[cfg(feature = "kv-mem")]
Inner::Mem(v) => {
Expand Down Expand Up @@ -1080,7 +1083,6 @@ impl Datastore {
let (send, recv): (Sender<TrackedResult>, Receiver<TrackedResult>) =
channel::bounded(LQ_CHANNEL_SIZE);

#[allow(unreachable_code)]
Ok(Transaction {
inner,
cache: super::cache::Cache::default(),
Expand Down
14 changes: 14 additions & 0 deletions tests/sdk/local/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "sdk_test_local"
version = "1.0.0"
edition = "2021"

[dependencies]
surrealdb = { path = "../../../lib", features = ["kv-mem"] }
tokio = { version = "1", features = ["full"] }

[workspace]

[[bin]]
path = "main.rs"
name = "sdk_test_local"
9 changes: 9 additions & 0 deletions tests/sdk/local/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use surrealdb::engine::local::Mem;
use surrealdb::Surreal;

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
let db = Surreal::new::<Mem>(()).await?;
let _ = db.query("INFO FOR ROOT").await.unwrap().check().is_ok();
Ok(())
}
14 changes: 14 additions & 0 deletions tests/sdk/remote/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "sdk_test_remote"
version = "1.0.0"
edition = "2021"

[dependencies]
surrealdb = { path = "../../../lib" }
tokio = { version = "1", features = ["full"] }

[workspace]

[[bin]]
path = "main.rs"
name = "sdk_test_remote"
9 changes: 9 additions & 0 deletions tests/sdk/remote/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use surrealdb::engine::remote::ws::Ws;
use surrealdb::Surreal;

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
let db = Surreal::new::<Ws>("localhost:8000").await?;
let _ = db.query("INFO FOR ROOT").await.unwrap().check().is_ok();
Ok(())
}

0 comments on commit bbab9fb

Please sign in to comment.