Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix: execute Wasm tests on node in CI #2205

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install stable toolchain, tools, and restore cache
uses: ./.github/workflows/actions/toolchain-and-cache
with:
Expand Down Expand Up @@ -158,7 +163,7 @@ jobs:
- name: Test 'mithril-client-wasm' - NodeJS
shell: bash
run: |
wasm-pack test --node mithril-client-wasm --release
wasm-pack test --node mithril-client-wasm --release --features test-node

- name: Publish Mithril Distribution (WASM)
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/client-wasm-nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/client-wasm-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion mithril-client-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-client-wasm"
version = "0.7.4"
version = "0.7.5"
description = "Mithril client WASM"
authors = { workspace = true }
edition = { workspace = true }
Expand Down Expand Up @@ -34,6 +34,7 @@ mithril-build-script = { path = "../internal/mithril-build-script" }
[features]
# Include nothing by default
default = []
test-node = []

[package.metadata.docs.rs]
all-features = true
Expand Down
7 changes: 5 additions & 2 deletions mithril-client-wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ build:
test:
pkill -f "mithril-aggregator-fake" || true
${CARGO} run -p mithril-aggregator-fake -- -p 8000 &
if wasm-pack test --headless --firefox --chrome --node --release; then \
if ! wasm-pack test --headless --firefox --chrome --release; then \
pkill -f "mithril-aggregator-fake" || true; \
else \
exit 1; \
fi
if ! wasm-pack test --node --release --features test-node; then \
pkill -f "mithril-aggregator-fake" || true; \
exit 1; \
fi
pkill -f "mithril-aggregator-fake" || true

check:
${CARGO} check --release --all-features --all-targets
Expand Down
2 changes: 1 addition & 1 deletion mithril-client-wasm/ci-test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mithril-client-wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mithril-dev/mithril-client-wasm",
"version": "0.7.4",
"version": "0.7.5",
"description": "Mithril client WASM",
"license": "Apache-2.0",
"collaborators": [
Expand Down
4 changes: 2 additions & 2 deletions mithril-client-wasm/src/certificate_verification_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl CertificateVerifierCache for LocalStorageCertificateVerifierCache {
}
}

#[cfg(test)]
#[cfg(all(test, not(feature = "test-node")))]
pub(crate) mod test_tools {
use std::collections::HashMap;

Expand Down Expand Up @@ -249,7 +249,7 @@ pub(crate) mod test_tools {
}
}

#[cfg(test)]
#[cfg(all(test, not(feature = "test-node")))]
mod tests {
use std::collections::HashMap;
use wasm_bindgen_test::*;
Expand Down
7 changes: 4 additions & 3 deletions mithril-client-wasm/src/client_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ impl JSBroadcastChannelFeedbackReceiver {
impl FeedbackReceiver for JSBroadcastChannelFeedbackReceiver {
async fn handle_event(&self, event: MithrilEvent) {
let event = MithrilEventWasm::from(event);
let _ = web_sys::BroadcastChannel::new(&self.channel)
.unwrap()
.post_message(&serde_wasm_bindgen::to_value(&event).unwrap());
let bc = web_sys::BroadcastChannel::new(&self.channel).unwrap();
let _ = bc.post_message(&serde_wasm_bindgen::to_value(&event).unwrap());
bc.close();
}
}

Expand Down Expand Up @@ -477,6 +477,7 @@ mod tests {
get_mithril_client(options)
}

#[cfg(not(feature = "test-node"))]
wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
Expand Down
2 changes: 1 addition & 1 deletion mithril-explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.