Skip to content

Commit 5c79f87

Browse files
committed
ci: add wasm test and examples
1 parent cb4f404 commit 5c79f87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+313
-103
lines changed

.github/workflows/ci.yml

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,78 @@ jobs:
9090
with:
9191
command: run
9292
args: --bin sqllogictest-test --manifest-path ./tests/sqllogictest/Cargo.toml
93-
# codecov:
94-
# name: Upload coverage reports to Codecov
95-
# runs-on: ubuntu-latest
96-
# steps:
97-
# - name: Upload coverage reports to Codecov
98-
# uses: codecov/codecov-action@v3
99-
# with:
100-
# files: ./lcov.info
101-
# flags: rust
102-
# env:
103-
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
93+
# 4
94+
wasm-tests:
95+
name: Wasm cargo tests
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v2
99+
100+
- name: Install stable with wasm target
101+
uses: actions-rs/toolchain@v1
102+
with:
103+
toolchain: stable
104+
target: wasm32-unknown-unknown
105+
override: true
106+
107+
- name: Setup Node.js
108+
uses: actions/setup-node@v4
109+
with:
110+
node-version: 20
111+
112+
- name: Install wasm-pack
113+
uses: jetli/[email protected]
114+
with:
115+
version: latest
116+
117+
- name: Run wasm-bindgen tests (wasm32 target)
118+
run: wasm-pack test --node -- --package kite_sql --lib
119+
# 5
120+
wasm-examples:
121+
name: Wasm examples (nodejs)
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v2
125+
126+
- name: Install stable with wasm target
127+
uses: actions-rs/toolchain@v1
128+
with:
129+
toolchain: stable
130+
target: wasm32-unknown-unknown
131+
override: true
132+
133+
- name: Setup Node.js
134+
uses: actions/setup-node@v4
135+
with:
136+
node-version: 20
137+
138+
- name: Install wasm-pack
139+
uses: jetli/[email protected]
140+
with:
141+
version: latest
142+
143+
- name: Build wasm package
144+
run: wasm-pack build --release --target nodejs
145+
146+
- name: Run wasm example scripts
147+
run: |
148+
node examples/wasm_hello_world.test.mjs
149+
node examples/wasm_index_usage.test.mjs
150+
# 6
151+
native-examples:
152+
name: Native examples
153+
runs-on: ubuntu-latest
154+
steps:
155+
- uses: actions/checkout@v2
156+
157+
- name: Install stable toolchain
158+
uses: actions-rs/toolchain@v1
159+
with:
160+
toolchain: stable
161+
override: true
162+
163+
- name: Run hello_world example
164+
run: cargo run --example hello_world
165+
166+
- name: Run transaction example
167+
run: cargo run --example transaction

Cargo.lock

Lines changed: 45 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,35 +71,35 @@ pgwire = { version = "0.28.0", optional = true }
7171
tokio = { version = "1.36", features = ["full"], optional = true }
7272

7373

74-
[dev-dependencies]
74+
[target.'cfg(unix)'.dev-dependencies]
75+
pprof = { version = "0.13", features = ["flamegraph", "criterion"] }
76+
77+
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
7578
criterion = { version = "0.5", features = ["html_reports"] }
7679
indicatif = { version = "0.17" }
7780
tempfile = { version = "3.10" }
7881
# Benchmark
7982
sqlite = { version = "0.34" }
8083

81-
[target.'cfg(unix)'.dev-dependencies]
82-
pprof = { version = "0.13", features = ["flamegraph", "criterion"] }
83-
8484
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
8585
dirs = { version = "5" }
8686
rocksdb = { version = "0.23" }
8787

8888
[target.'cfg(target_arch = "wasm32")'.dependencies]
89-
wasm-bindgen = { version = "0.2" }
90-
web-sys = { version = "0.3", features = [
89+
wasm-bindgen = { version = "0.2.106" }
90+
web-sys = { version = "0.3.83", features = [
9191
"Storage",
9292
"Window",
9393
] }
9494
base64 = { version = "0.21" }
9595
getrandom = { version = "0.2", features = ["js"] }
9696
getrandom_03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }
97-
js-sys = { version = "0.3" }
98-
serde-wasm-bindgen = { version = "0.6" }
97+
js-sys = { version = "0.3.83" }
98+
serde-wasm-bindgen = { version = "0.6.5" }
9999
once_cell = { version = "1" }
100100

101101
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
102-
wasm-bindgen-test = "0.3"
102+
wasm-bindgen-test = "0.3.56"
103103

104104
[workspace]
105105
members = [

examples/hello_world.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(target_arch = "wasm32"))]
2+
13
use kite_sql::db::{DataBaseBuilder, ResultIter};
24
use kite_sql::errors::DatabaseError;
35
use kite_sql::implement_from_tuple;

examples/transaction.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(target_arch = "wasm32"))]
2+
13
use kite_sql::db::{DataBaseBuilder, ResultIter};
24
use kite_sql::errors::DatabaseError;
35

src/binder/create_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
154154
}
155155
}
156156

157-
#[cfg(test)]
157+
#[cfg(all(test, not(target_arch = "wasm32")))]
158158
mod tests {
159159
use super::*;
160160
use crate::binder::BinderContext;

src/binder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ pub(crate) fn is_valid_identifier(s: &str) -> bool {
524524
&& !s.chars().all(|c| c == '_')
525525
}
526526

527-
#[cfg(test)]
527+
#[cfg(all(test, not(target_arch = "wasm32")))]
528528
pub mod test {
529529
use crate::binder::{is_valid_identifier, Binder, BinderContext};
530530
use crate::catalog::{ColumnCatalog, ColumnDesc, TableCatalog};

src/binder/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
11891189
}
11901190
}
11911191

1192-
#[cfg(test)]
1192+
#[cfg(all(test, not(target_arch = "wasm32")))]
11931193
mod tests {
11941194
use crate::binder::test::build_t1_table;
11951195
use crate::errors::DatabaseError;

src/catalog/table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl TableCatalog {
4949
self.columns.get(id).map(|i| &self.schema_ref[*i])
5050
}
5151

52-
#[cfg(test)]
52+
#[cfg(all(test, not(target_arch = "wasm32")))]
5353
pub(crate) fn get_column_id_by_name(&self, name: &str) -> Option<&ColumnId> {
5454
self.column_idxs.get(name).map(|(id, _)| id)
5555
}
@@ -270,7 +270,7 @@ impl TableMeta {
270270
}
271271
}
272272

273-
#[cfg(test)]
273+
#[cfg(all(test, not(target_arch = "wasm32")))]
274274
mod tests {
275275
use super::*;
276276
use crate::catalog::ColumnDesc;

0 commit comments

Comments
 (0)