Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions .github/workflows/typescript-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: TypeScript bindings

on:
push:
branches: [master]
paths:
- "typescript/**"
- ".github/workflows/typescript-bindings.yml"
pull_request:
branches: [master]
paths:
- "typescript/**"
- ".github/workflows/typescript-bindings.yml"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

# The JS/Wasm bindings live under `typescript/`, which is a self-contained Cargo
# workspace (it pulls `rapier2d`/`rapier3d` from crates.io, not from the crates
# in this repo). Every step therefore runs inside that directory.

concurrency:
group: typescript-bindings-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
check-fmt:
runs-on: ubuntu-latest
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22.x"
- run: npm ci
- name: Check formatting
run: npm run fmt -- --check
- name: Check Rust formatting
run: cargo fmt -- --check
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: typescript
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
typescript/target/
key: ${{ runner.os }}-cargo-js-${{ hashFiles('typescript/builds/prepare_builds/templates/Cargo.toml.tera') }}
restore-keys: |
${{ runner.os }}-cargo-js-
- run: npm ci;
- name: Prepare no-compat builds
run: |
./builds/prepare_builds/prepare_all_projects.sh
- name: Build all no-compat projects
run: |
./builds/prepare_builds/build_all_projects.sh
# Install dependencies to check simd for builds
- name: Install wabt
run: |
sudo apt install wabt;
if: matrix.os == 'ubuntu-latest'
- name: Install wabt
run: |
brew install wabt;
if: matrix.os == 'macos-latest'
# Check simd for rust builds
- name: Check 2d simd rust build
run: |
if ! wasm-objdump -d builds/rapier2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1
fi
- name: Check 3d simd compat build
run: |
if ! wasm-objdump -d builds/rapier3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1
fi
- uses: actions/upload-artifact@v4
with:
name: pkg no-compat ${{ matrix.os }}
path: |
typescript/builds/*/pkg
overwrite: true
build-compat:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: typescript
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
typescript/target/
key: ${{ runner.os }}-cargo-js-${{ hashFiles('typescript/builds/prepare_builds/templates/Cargo.toml.tera') }}
restore-keys: |
${{ runner.os }}-cargo-js-
- run: npm ci;
- name: Prepare compat builds
run: |
./builds/prepare_builds/prepare_all_projects.sh
- name: Build rapier-compat
run: |
cd rapier-compat;
npm ci;
npm run build;
npm run test;
# Install dependencies to check simd for builds
- name: Install wabt
run: |
sudo apt install wabt;
if: matrix.os == 'ubuntu-latest'
- name: Install wabt
run: |
brew install wabt;
if: matrix.os == 'macos-latest'
# Check simd for compat builds
- name: Check 2d simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1;
fi
- name: Check 3d simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1;
fi
# Upload
- uses: actions/upload-artifact@v4
with:
name: pkg compat ${{ matrix.os }}
path: |
typescript/rapier-compat/builds/*/pkg
overwrite: true
publish:
runs-on: ubuntu-latest
needs: [build, build-compat]
if: github.ref == 'refs/heads/master'
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: pkg no-compat ubuntu-latest
path: typescript/builds
- uses: actions/download-artifact@v4
with:
name: pkg compat ubuntu-latest
path: typescript/rapier-compat/builds
- uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
- name: Publish projects
run: |
./publish_all_canary.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Shepperd = "Shepperd"
# with `bb`) and `typ` (a "type" value — `type` is reserved in Rust/Python).
ba = "ba"
typ = "typ"
# Voxel grid coordinate index in the JS bindings, paired with `ix`/`iz`.
iy = "iy"
# Template mesh data in the testbed instancer: `tpos`/`tnrm`/`tidx`
# (template positions/normals/indices). Only `tpos` collides with a word.
tpos = "tpos"
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ default-members = [
"crates/mjcf-rs",
"crates/rapier3d-mjcf",
]
# `typescript/` is the JS/Wasm bindings' own Cargo workspace; keep it out of
# this one so root-level `cargo` commands never try to absorb its crates.
exclude = ["typescript"]
resolver = "2"

[workspace.package]
Expand Down
27 changes: 27 additions & 0 deletions typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ignore rules specific to the TypeScript/Wasm bindings. Generic entries
# (node_modules, target, .idea, .DS_Store) already live in the repository-root
# .gitignore and are not repeated here.

# The root .gitignore excludes `package-lock.json`, but the JS bindings must
# commit it: `npm ci` (used throughout the JS CI) requires the lockfile. The
# Rust `Cargo.lock` stays ignored (matching the repo root): the workspace's only
# members are the `prepare_builds`-generated crates, so a committed lock would
# just churn with generated entries; CI regenerates it.
!package-lock.json

**/*.rs.bk
dist
pkg
gen2d/
gen3d/
docs
*.swp
*.d.ts

# Per-target crates generated by the `prepare_builds` crate; only the
# generator itself is tracked.
builds/*
!builds/prepare_builds

# Compat package's generated wasm builds.
rapier-compat/builds/
7 changes: 7 additions & 0 deletions typescript/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pkg
gen2d
gen3d
docs
target
**/CHANGELOG.md
**/README.md
5 changes: 5 additions & 0 deletions typescript/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 4,
"bracketSpacing": false,
"trailingComma": "all"
}
Loading
Loading