[CI] Add sdk build test (#4092)
This commit is contained in:
parent
7495611bc4
commit
bbab9fbee4
7 changed files with 83 additions and 3 deletions
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
|
@ -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
|
||||
|
@ -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
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -37,6 +37,9 @@ Temporary Items
|
|||
/lib/cache/
|
||||
/lib/store/
|
||||
/lib/target/
|
||||
/tests/sdk/*/Cargo.lock
|
||||
/tests/sdk/*/target
|
||||
|
||||
.idea/
|
||||
.vscode/
|
||||
/result
|
||||
|
|
|
@ -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) => {
|
||||
|
@ -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(),
|
||||
|
|
14
tests/sdk/local/Cargo.toml
Normal file
14
tests/sdk/local/Cargo.toml
Normal file
|
@ -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
tests/sdk/local/main.rs
Normal file
9
tests/sdk/local/main.rs
Normal file
|
@ -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
tests/sdk/remote/Cargo.toml
Normal file
14
tests/sdk/remote/Cargo.toml
Normal file
|
@ -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
tests/sdk/remote/main.rs
Normal file
9
tests/sdk/remote/main.rs
Normal file
|
@ -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(())
|
||||
}
|
Loading…
Reference in a new issue