Skip to content

Commit

Permalink
Merge pull request #2 from lindera/fix_example
Browse files Browse the repository at this point in the history
Add example web application
  • Loading branch information
mosuka authored Dec 12, 2024
2 parents 224733e + 33abacd commit d67d998
Show file tree
Hide file tree
Showing 11 changed files with 4,172 additions and 93 deletions.
61 changes: 51 additions & 10 deletions .github/workflows/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,61 @@ on:
- cron: 0 0 * * SUN

jobs:
fmt:
name: Format
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Run checkout
uses: actions/checkout@v4

- name: Install toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Check format
run: cargo fmt --all -- --check

check:
name: Check
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Run checkout
uses: actions/checkout@v4

- name: Install toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Run check
run: cargo check --features "${{ matrix.features }}"

test:
name: Test
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
wasm-runner: --node
toolchain: [stable, beta, nightly]
test-runner: --node
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
steps:
Expand All @@ -30,11 +77,5 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

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

- name: Run test with node.js
run: wasm-pack test ${{ matrix.platform.wasm-runner }}
- name: Run test
run: wasm-pack test ${{ matrix.platform.test-runner }}
13 changes: 4 additions & 9 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ jobs:
run: cargo check --features "${{ matrix.features }}"

test:
name: Test
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
wasm-runner: --node
test-runner: --node
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
Expand All @@ -79,11 +80,5 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

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

- name: Run test with node.js
run: wasm-pack test ${{ matrix.platform.wasm-runner }}
- name: Run test
run: wasm-pack test ${{ matrix.platform.test-runner }}
64 changes: 51 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,63 @@ permissions:
contents: read

jobs:
fmt:
name: Format
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Run checkout
uses: actions/checkout@v4

- name: Install toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Check format
run: cargo fmt --all -- --check

check:
name: Check
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Run checkout
uses: actions/checkout@v4

- name: Install toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Run check
run: cargo check --features "${{ matrix.features }}"

test:
name: Test
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
wasm-target: nodejs
wasm-runner: --node
test-runner: --node
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}

steps:
- name: Run checkout
uses: actions/checkout@v4
Expand All @@ -37,14 +82,8 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

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

- name: Run test with node.js
run: wasm-pack test ${{ matrix.platform.wasm-runner }}
- name: Run test
run: wasm-pack test ${{ matrix.platform.test-runner }}

release:
name: Release
Expand All @@ -53,8 +92,7 @@ jobs:
platform:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
wasm-target: nodejs
wasm-runner: --node
wasm-target: bundler
toolchain: [stable]
features: [cjk]
runs-on: ${{ matrix.platform.runner }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/target
/pkg
**/node_modules
**/dist
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ test:
wasm-pack test --node

build:
wasm-pack build --release --target=nodejs --features=cjk
wasm-pack build --release --features=cjk --target=bundler

publish:
wasm-pack publish --access=public --target=nodejs
wasm-pack publish --access=public --target=bundler

serve:
python3 -m http.server
tag_example:
jq '.version = "$(VERSION)"' ./example/package.json > ./example/temp.json && mv ./example/temp.json ./example/package.json

build_example: tag_example
cd example && npm install && npm run build && cp index.html dist/index.html

run_example:
cd example && npm run start

tag:
git tag v$(VERSION)
Expand Down
17 changes: 17 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Lindera WASM Example</title>
</head>

<body>
<h1>Lindera WASM Example</h1>
<input id="inputText" type="text" placeholder="Enter text to tokenize">
<button id="runButton">Tokenize</button>
<ul id="resultList"></ul>
<script src="bundle.js"></script>
</body>

</html>
Loading

0 comments on commit d67d998

Please sign in to comment.