diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..758ed61 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.wasm32-unknown-unknown] +runner = "wasm-server-runner" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c04e3bd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v4 + + - name: Setup | Toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy,rustfmt + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Build | Clippy + run: cargo clippy -- -D warnings + + - name: Build | Rustfmt + run: cargo fmt --all -- --check + + check: + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v4 + + - name: Setup | Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Build | Check (native) + run: cargo check + + - name: Build | Check (wasm) + run: cargo check --target wasm32-unknown-unknown + + test: + needs: [check] + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v4 + + - name: Setup | Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + + - name: Setup | wasm-pack + uses: jetli/wasm-pack-action@v0.4.0 + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Build | Test (native) + run: cargo test --all + + - name: Build | Test (wasm) + run: wasm-pack test --node \ No newline at end of file diff --git a/.github/workflows/web-demo.yml b/.github/workflows/web-demo.yml new file mode 100644 index 0000000..3b7d0a6 --- /dev/null +++ b/.github/workflows/web-demo.yml @@ -0,0 +1,67 @@ +name: Web Demo Update + +on: + push: + branches: + - main + +jobs: + release-web: + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: install stable toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + + - name: install wasm-bindgen + uses: jetli/wasm-bindgen-action@v0.2.0 + with: + version: 'latest' + + - name: build (wasm) + run: cargo build --example simple --release --target wasm32-unknown-unknown + + - name: package wasm + run: | + mkdir public + wasm-bindgen --target web --out-dir public target/wasm32-unknown-unknown/release/examples/simple.wasm --no-typescript + cat << EOF > public/index.html + +