Skip to content

Commit

Permalink
Update Rust and split into dedicated folder (#290)
Browse files Browse the repository at this point in the history
* Allow Rust to run Module export

* Convert to use ts scripts.

* Disable rust test for now.

* Change rust test to web.

* Add readme to run rust test.

* Move snake game into dedicated crate folder.
  • Loading branch information
yoonghan authored Sep 20, 2024
1 parent d9037f6 commit 900870c
Show file tree
Hide file tree
Showing 43 changed files with 604 additions and 516 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/wasm-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Can't compare *.wasm file as binary compilation are different
# Can't compare js., order of generated function is different.

cd crate
cd crate/snake

wasm_dir_compare="./$1/"
wasm_dir=./pkg/
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/validate-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,26 @@ jobs:
node-version: ${{ matrix.node }}
cache: "npm"

- uses: browser-actions/setup-chrome@v1

- name: ⎔ Compile rust code
run: cd crate && wasm-pack build --target web --out-dir pkg_compare
run: cd crate/snake && wasm-pack build --target web --out-dir pkg_compare
shell: bash

- name: ✅ Validate Wasm binary is latest with BEST effort
run: chmod a+x ./.github/scripts/wasm-check.sh && ./.github/scripts/wasm-check.sh pkg_compare
shell: bash

- name: ✅ Validate wasm test
run: npm run rust:generate && npm run rust:test
run: |
chrome --version
npm run rust:generate && npm run rust:test
shell: bash

- name: Add rust wasm bindgen for code coverage run
run: |
echo "commented, core Rust needs to improved"
# cd crate && cargo install wasm-bindgen-cli --vers "0.2.84"
# cd crate/snake && cargo install wasm-bindgen-cli --vers "0.2.84"
shell: bash

- name: ✅ Validate for code coverage, work stopped here apparrently there are no solutions yet
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Process.env variable for client side access are required to be defined in .env f

1. To regenerate new Wasm from webassembly, run the command below:
2. The scripts include a custom .gitignore.
3. Incase wanted to run rust:test, remove --headless and browse with https://localhost:8000. Failed to run it in MacOS.

```
npm run rust:generate
Expand Down
2 changes: 0 additions & 2 deletions crate/.cargo/config

This file was deleted.

243 changes: 0 additions & 243 deletions crate/Cargo.lock

This file was deleted.

Loading

0 comments on commit 900870c

Please sign in to comment.