From 4fc6181b27757f6fdd9407536636da8cb1626e6d Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Sat, 14 Jan 2023 17:40:07 -0500 Subject: [PATCH] build: Support building on `wasm32-unknown-unknown` without default features * Don't depend on a particular ahash rng * chore: Use `getrandom/js` on `wasm32` * ci: Run `cargo build` for `wasm32-unknown-unknown` Co-authored-by: Dmitry Dygalo --- .github/workflows/build.yml | 33 ++++++++++++++++++++++++++++++++- jsonschema/Cargo.toml | 3 +++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc7c2fc..a616e49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,6 +65,38 @@ jobs: - run: cargo test --no-fail-fast --features ${{ matrix.draft }} working-directory: ./jsonschema + build-wasm32: + strategy: + fail-fast: false + matrix: + target: ['wasm32-unknown-unknown'] + + name: Build on ${{ matrix.target }} + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: ${{ matrix.target }} + override: true + + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: stable-${{ matrix.target }}-cargo-cache + + - run: cargo build --target ${{ matrix.target }} --no-default-features --features=cli + working-directory: ./jsonschema + coverage: name: Run test coverage runs-on: ubuntu-20.04 @@ -164,7 +196,6 @@ jobs: run: pip install dist/* working-directory: ./bindings/python - fmt: name: Rustfmt runs-on: ubuntu-20.04 diff --git a/jsonschema/Cargo.toml b/jsonschema/Cargo.toml index 987a968..797a357 100644 --- a/jsonschema/Cargo.toml +++ b/jsonschema/Cargo.toml @@ -47,6 +47,9 @@ time = { version = "0.3", features = ["parsing", "macros"] } url = "2.2" uuid = "1" +[target.'cfg(target_arch = "wasm32")'.dependencies] +getrandom = { version = "0.2", features = ["js"] } + [dev-dependencies] bench_helpers = { path = "../bench_helpers" } criterion = { version = "0.4.0", features = [], default-features = false }