Skip to content

Commit

Permalink
add wasm smoketest in ci (#47)
Browse files Browse the repository at this point in the history
* fix warning about deprecation

update minimu rust version

* fix wasm smoke test

* add ci test

* update rust to 1.64.0 (also in ci)
  • Loading branch information
Simon-Laux authored Sep 28, 2023
1 parent a9b3482 commit fcb757a
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 91 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.60.0
toolchain: 1.64.0
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
Expand All @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
toolchain: 1.64.0
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
Expand Down Expand Up @@ -68,9 +68,9 @@ jobs:
matrix:
include:
- os: ubuntu-latest
rust: 1.60.0
rust: 1.64.0
- os: windows-latest
rust: 1.60.0
rust: 1.64.0
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/smoketest-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- run: cargo test
- run: wasm-pack test --headless --chrome
- run: wasm-pack test --headless --firefox
138 changes: 73 additions & 65 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion message_parser_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"]
default = ["console_error_panic_hook"]

[dependencies]
wasm-bindgen = {version = "0.2.63", features = ["serde-serialize"]}
wasm-bindgen = {version = "0.2.63"}

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
Expand All @@ -28,6 +28,8 @@ console_error_panic_hook = { version = "0.1.6", optional = true }
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.5", optional = true }
deltachat_message_parser = { path = "../" }
serde-wasm-bindgen = "0.6.0"
serde = { version = "1.0.188", features = ["derive"] }

[dev-dependencies]
serde = "1.0.130"
Expand Down
4 changes: 2 additions & 2 deletions message_parser_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub fn parse_text(s: &str, enable_markdown: bool) -> JsValue {
true => deltachat_message_parser::parser::parse_markdown_text(s),
false => deltachat_message_parser::parser::parse_only_text(s),
};
JsValue::from_serde(&ast).expect("Element converts to JsValue")
serde_wasm_bindgen::to_value(&ast).expect("Element converts to JsValue")
}

/// parses text to json AST (text elements and labled links, to replicate current desktop implementation)
#[wasm_bindgen]
pub fn parse_desktop_set(s: &str) -> JsValue {
JsValue::from_serde(&deltachat_message_parser::parser::parse_desktop_set(s))
serde_wasm_bindgen::to_value(&deltachat_message_parser::parser::parse_desktop_set(s))
.expect("Element converts to JsValue")
}

Expand Down
Loading

0 comments on commit fcb757a

Please sign in to comment.