[CI] Add sdk build test (#4092)

This commit is contained in:
Emmanuel Keller 2024-05-24 18:56:14 +01:00 committed by GitHub
parent 7495611bc4
commit bbab9fbee4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 83 additions and 3 deletions

View file

@ -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
View file

@ -37,6 +37,9 @@ Temporary Items
/lib/cache/
/lib/store/
/lib/target/
/tests/sdk/*/Cargo.lock
/tests/sdk/*/target
.idea/
.vscode/
/result

View file

@ -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(),

View 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
View 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(())
}

View 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
View 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(())
}