Registry Mirror
Skip to content
28 changes: 14 additions & 14 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,25 @@ jobs:
run: ci/scripts/rust_docs.sh

linux-wasm-pack:
name: build with wasm-pack
runs-on: ubuntu-latest
container:
image: amd64/rust
name: build and run with wasm-pack
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: ./.github/actions/setup-builder
with:
rust-version: stable
- name: Setup for wasm32
run: |
rustup target add wasm32-unknown-unknown
- name: Install dependencies
run: |
apt-get update -qq
apt-get install -y -qq clang
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build with wasm-pack
sudo apt-get update -qq
sudo apt-get install -y -qq clang
- name: Setup wasm-pack
run: |
cargo install wasm-pack
- name: Run tests with headless mode
working-directory: ./datafusion/wasmtest
run: wasm-pack build --dev
run: |
wasm-pack test --headless --firefox

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

wasm-pack test --headless --chrome --chromedriver $CHROMEWEBDRIVER/chromedriver

# verify that the benchmark queries return the correct results
verify-benchmark-results:
Expand Down
2 changes: 0 additions & 2 deletions datafusion/wasmtest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ wasm-pack test --headless --chrome
wasm-pack test --headless --safari
```

**Note:** In GitHub Actions we test the compilation with `wasm-build`, but we don't currently invoke `wasm-pack test`. This is because the headless mode is not yet working. Document of adding a GitHub Action job: https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/continuous-integration.html#github-actions.

To tweak timeout setting, use `WASM_BINDGEN_TEST_TIMEOUT` environment variable. E.g., `WASM_BINDGEN_TEST_TIMEOUT=300 wasm-pack test --firefox --headless`.

## Compatibility
Expand Down
28 changes: 14 additions & 14 deletions datafusion/wasmtest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ pub fn basic_parse() {
#[cfg(test)]
mod test {
use super::*;
use datafusion::execution::options::ParquetReadOptions;
use datafusion::{
arrow::{
array::{ArrayRef, Int32Array, RecordBatch, StringArray},
Expand All @@ -98,7 +97,6 @@ mod test {
};
use datafusion_physical_plan::collect;
use datafusion_sql::parser::DFParser;
use insta::assert_snapshot;
use object_store::{memory::InMemory, path::Path, ObjectStore};
use url::Url;
use wasm_bindgen_test::wasm_bindgen_test;
Expand Down Expand Up @@ -240,22 +238,24 @@ mod test {

let url = Url::parse("memory://").unwrap();
session_ctx.register_object_store(&url, Arc::new(store));

let df = session_ctx
.read_parquet("memory:///", ParquetReadOptions::new())
session_ctx
.register_parquet("a", "memory:///a.parquet", Default::default())
.await
.unwrap();

let df = session_ctx.sql("SELECT * FROM a").await.unwrap();

let result = df.collect().await.unwrap();

assert_snapshot!(batches_to_string(&result), @r"
+----+-------+
| id | value |
+----+-------+
| 1 | a |
| 2 | b |
| 3 | c |
+----+-------+
");
assert_eq!(
batches_to_string(&result),
"+----+-------+\n\
| id | value |\n\
+----+-------+\n\
| 1 | a |\n\
| 2 | b |\n\
| 3 | c |\n\
+----+-------+"
);
}
}
15 changes: 15 additions & 0 deletions datafusion/wasmtest/webdriver.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"moz:firefoxOptions": {
"prefs": {
"media.navigator.streams.fake": true,
"media.navigator.permission.disabled": true
},
"args": []
},
"goog:chromeOptions": {
"args": [
"--use-fake-device-for-media-stream",
"--use-fake-ui-for-media-stream"
]
}
}