Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci build for WASM target for specific packages #394

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: wasm-build

on:
push:
branches:
- dev
tags:
- "[v]?[0-9]+.[0-9]+.[0-9]+*"
pull_request:
branches:
- dev

env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
build_and_test:
name: Build for target wasm32-unknown-unknown
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- tlsn/tlsn-core
- tlsn/tlsn-prover
- components/tls/tls-client
defaults:
run:
working-directory: ${{ matrix.package }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install stable rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
toolchain: stable

- name: Use caching
uses: Swatinem/[email protected]
with:
workspaces: ${{ matrix.package }} -> ../target

- name: "Build"
run: cargo build --target wasm32-unknown-unknown
4 changes: 4 additions & 0 deletions components/tls/tls-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ path = "examples/internal/bench.rs"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"] }
getrandom = { version = "0.2", features = ["js"] }
3 changes: 3 additions & 0 deletions tlsn/tlsn-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ bincode.workspace = true
[[test]]
name = "api"
required-features = ["fixtures"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
Copy link
Collaborator

@mhchia mhchia Dec 18, 2023

Choose a reason for hiding this comment

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

Should ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"] } also be required here since tlsn-tls-core is a dependency and it depends on ring?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mhchia I am not sure. I have not fully analysed the dependencies.
It builds without specifying it here, so that is why I didn't add it here.

Copy link
Member

@th4s th4s Dec 18, 2023

Choose a reason for hiding this comment

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

I think tls-core already pulls in ring 0.17 because it has ring.workspace = true. So no need to make it a dependency of tlsn-core?

Copy link
Collaborator

@mhchia mhchia Dec 18, 2023

Choose a reason for hiding this comment

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

@heeckhau I see 🙏
@th4s Yeah but in order for tlsn-core (and thus ring 0.17) to build in wasm32, should we specify the feature flag wasm32_unknown_unknown_js for ring 0.17, or do I misunderstand something?

Copy link
Member

@th4s th4s Dec 18, 2023

Choose a reason for hiding this comment

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

Ahh, haven't thought about this. Following this additive-features it would probably work in most cases, since it is never pulled in alone.

But it would probably be better to add the feature to tls-core then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Following this additive-features it would probably work in most cases, since it is never pulled in alone.

I see. Thanks for sharing! If tlsn-core is not used alone then whether adding or not both works for me 🙏

getrandom = { version = "0.2", features = ["js"] }
6 changes: 5 additions & 1 deletion tlsn/tlsn-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ derive_builder.workspace = true
opaque-debug.workspace = true
bytes.workspace = true

tracing = { workspace = true, optional = true}
tracing = { workspace = true, optional = true }

web-time.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"] }
getrandom = { version = "0.2", features = ["js"] }