From f8a152a1b96839ab07b56ea8f3f83e150f2cf945 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Thu, 9 Jan 2025 16:07:03 -0700 Subject: [PATCH] build: add driver wasm builds --- .github/workflows/ci.yml | 29 ++++++++++++++++++++++++++--- Cargo.lock | 1 + Cargo.toml | 1 + rsql_drivers/Cargo.toml | 5 ++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccaa0626..1caedb70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,16 +28,28 @@ jobs: - macos-arm64 - macos-x64 - windows-x64 + - wasm32-unknown + - wasm32-wasi include: - platform: linux-x64 os: [ self-hosted, Linux, X64 ] + target: x86_64-unknown-linux-gnu - platform: macos-arm64 os: macos-15 + target: aarch64-apple-darwin - platform: macos-x64 os: macos-13 + target: x86_64-apple-darwin - platform: windows-x64 os: windows-2022 + target: x86_64-pc-windows-msvc + - platform: wasm32-unknown + os: ubuntu-latest + target: wasm32-unknown-unknown + - platform: wasm32-wasi + os: ubuntu-latest + target: wasm32-wasip1-threads steps: - name: Checkout source code @@ -58,8 +70,19 @@ jobs: with: tool: cargo-llvm-cov - - name: Tests - if: ${{ !startsWith(matrix.platform, 'linux-') }} + - name: Build + if: ${{ startsWith(matrix.platform, 'wasm32-') }} + env: + CARGO_TERM_COLOR: always + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + RUST_BACKTRACE: 1 + RUST_LOG: info + run: | + rustup target install ${{ matrix.target }} + cargo build --package rsql_drivers --target ${{ matrix.target }} + + - name: Test + if: ${{ !startsWith(matrix.platform, 'linux-') && !startsWith(matrix.platform, 'wasm32-') }} env: CARGO_TERM_COLOR: always GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} @@ -69,7 +92,7 @@ jobs: run: | cargo test --workspace --features all - - name: Tests + - name: Test if: ${{ startsWith(matrix.platform, 'linux-') }} env: CARGO_TERM_COLOR: always diff --git a/Cargo.lock b/Cargo.lock index ea3bafd5..745ab3a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6492,6 +6492,7 @@ dependencies = [ "file_type", "form_urlencoded", "futures-util", + "getrandom", "indexmap 2.7.0", "indoc", "jwt-simple", diff --git a/Cargo.toml b/Cargo.toml index b7e47d4f..a1b252a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ duckdb = "0.10.2" file_type = "0.2.1" form_urlencoded = "1.2.1" futures-util = "0.3.31" +getrandom = "0.2.15" indexmap = "2.7.0" indicatif = "0.17.9" indoc = "2.0.5" diff --git a/rsql_drivers/Cargo.toml b/rsql_drivers/Cargo.toml index c521a300..ba7c26f6 100644 --- a/rsql_drivers/Cargo.toml +++ b/rsql_drivers/Cargo.toml @@ -43,7 +43,7 @@ sha2 = { workspace = true, optional = true } sqlparser = { workspace = true } sqlx = { workspace = true, features = ["bit-vec", "chrono", "json", "macros", "runtime-tokio", "rust_decimal", "time", "uuid"], optional = true } thiserror = { workspace = true } -tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt", "macros"] } tokio-postgres = { workspace = true, features = ["array-impls", "with-bit-vec-0_6", "with-chrono-0_4", "with-serde_json-1", "with-uuid-1"], optional = true } tokio-util = { workspace = true, features = ["compat"], optional = true } tracing = { workspace = true } @@ -62,6 +62,9 @@ features = ["bigdecimal", "chrono", "rust_decimal", "tds73", "time", "vendored-o optional = true workspace = true +[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] +getrandom = { workspace = true, features = ["js"] } + [dev-dependencies] testcontainers = { workspace = true } testcontainers-modules = { workspace = true, features = ["cockroach_db", "mariadb", "mssql_server", "mysql", "postgres"] }