Skip to content

Commit

Permalink
feat(mrml-wasm): create wasm package (#312)
Browse files Browse the repository at this point in the history
* feat(wasm-pack): create package

Signed-off-by: Jérémie Drouet <[email protected]>

* feat(mrml-wasm): implement engine with toHtml function

Signed-off-by: Jérémie Drouet <[email protected]>

* ci(mrml-wasm): create workflow

Signed-off-by: Jérémie Drouet <[email protected]>

---------

Signed-off-by: Jérémie Drouet <[email protected]>
  • Loading branch information
jdrouet authored Jul 25, 2023
1 parent 1ae7bee commit 7dad08d
Show file tree
Hide file tree
Showing 11 changed files with 494 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ updates:
directory: "/packages/mrml-core"
schedule:
interval: "daily"

- package-ecosystem: "cargo"
directory: "/packages/mrml-wasm"
schedule:
interval: "daily"
87 changes: 87 additions & 0 deletions .github/workflows/mrml-wasm-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
on:
push:
paths:
- .github/workflows/mrml-wasm-*
- packages/mrml-wasm/**
- packages/mrml-core/**
- Cargo.lock
- Cargo.toml

defaults:
run:
working-directory: packages/mrml-wasm

env:
RUSTFLAGS: "-Dwarnings"

jobs:
code-checking:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-mrml-wasm-code-checking
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt,clippy

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-mrml-wasm-code-checking-${{ hashFiles('**/Cargo.lock') }}

- name: run lint
run: cargo fmt --check

- name: run check
run: cargo check --all-features --tests

- name: run clippy
run: cargo clippy --all-targets --all-features --tests

testing:
runs-on: ubuntu-latest
container: rust:1-bullseye

concurrency:
group: ${{ github.ref }}-mrml-wasm-testing
cancel-in-progress: true

steps:
- uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- uses: actions/setup-node@v3
with:
node-version: latest

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

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-mrml-wasm-testing-${{ hashFiles('**/Cargo.lock') }}

- name: run unit tests
run: cargo test

- name: run integration tests
run: wasm-pack test --node
113 changes: 113 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ members = [
"packages/mrml-core/lib/mrml-parse-macros",
"packages/mrml-core/lib/mrml-print-macros",
"packages/mrml-core",
"packages/mrml-wasm",
]
resolver = "2"
6 changes: 6 additions & 0 deletions packages/mrml-wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target
**/*.rs.bk
Cargo.lock
bin/
pkg/
wasm-pack.log
38 changes: 38 additions & 0 deletions packages/mrml-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "mrml-wasm"
version = "0.1.0"
authors = ["Jérémie Drouet <[email protected]>"]
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]

[dependencies]
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.7", optional = true }

mrml = { version = "2.0.0-rc3", path = "../mrml-core", default-features = false, features = [
"parse",
"render",
] }

serde = { version = "1.0", features = ["derive"] }
serde-wasm-bindgen = { version = "0.5" }

# to generate typescript binding
tsify = { version = "0.4" }

wasm-bindgen = { version = "0.2" }

[dev-dependencies]
wasm-bindgen-test = "0.3.34"

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"
Loading

0 comments on commit 7dad08d

Please sign in to comment.