Skip to content

Commit 2135473

Browse files
committed
feat(core): port Rust core runtime, codegen, and WASM host
Introduce the canonical Rust protocol crates (truapi, truapi-platform, truapi-server) plus the rustdoc-JSON codegen (truapi-codegen) that emits the Rust dispatcher/wire table and the @parity/truapi TypeScript client. truapi-server ships as a WASM host runtime consumed by @parity/truapi-host-wasm, and the playground talks to it over a MessagePort handshake. This is the smallest set that runs the dotli playground diagnosis e2e: the dotli submodule, Makefile (wasm/dev/e2e/codegen targets), codegen script, deny.toml licence exceptions, ci.yml dotli-e2e job, and the host-packages.yml WASM bundle checks are included.
1 parent eee5380 commit 2135473

128 files changed

Lines changed: 38120 additions & 501 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,30 @@ jobs:
7676
- uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly
7777
with:
7878
toolchain: nightly
79+
components: rustfmt
7980

8081
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
8182

8283
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
8384
with:
8485
node-version: 22
8586

86-
- name: Install workspace deps
87-
run: npm ci --ignore-scripts
88-
87+
# codegen.sh emits the gitignored generated TS first and only then
88+
# installs/builds the npm workspace, so package `prepare` (tsc -b)
89+
# scripts see the generated modules. Installing the workspace before
90+
# codegen fails: npm runs the truapi-host-wasm prepare build against
91+
# sources whose ./generated imports don't exist yet.
8992
- name: Run codegen
9093
run: ./scripts/codegen.sh
9194

95+
- name: Check committed Rust codegen output is current
96+
run: git diff --exit-code -- rust/crates/truapi-server/src/generated
97+
98+
- name: Wire-table parity (Rust vs generated TS)
99+
run: cargo test -p truapi-server --test wire_table_ts_parity
100+
env:
101+
TRUAPI_REQUIRE_GENERATED_TS: 1
102+
92103
- name: Upload codegen output
93104
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
94105
with:
@@ -101,6 +112,7 @@ jobs:
101112
js/packages/truapi/src/explorer/codegen
102113
js/packages/truapi/src/explorer/versions.ts
103114
js/packages/truapi-host/src/generated
115+
js/packages/truapi-host-wasm/src/generated
104116
playground/test/generated
105117
106118
ts-client:
@@ -219,60 +231,86 @@ jobs:
219231
run: npm run build
220232

221233
e2e:
222-
name: E2E (playground inside dotli)
223-
# Temporarily disabled while the dotli playground smoke test is stabilized.
224-
if: false
234+
name: E2E (dotli playground diagnosis)
225235
runs-on: ubuntu-latest
226236
needs: playground
227-
timeout-minutes: 30
237+
timeout-minutes: 35
228238
env:
229239
TRUAPI_REQUIRE_GENERATED: 1
240+
SIGNER_BOT_SVC_TOKEN: ${{ secrets.SIGNER_BOT_SVC_TOKEN }}
230241
steps:
231242
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
232243
with:
233-
submodules: recursive
234244
persist-credentials: false
235245

246+
- name: Check dotli submodule access
247+
id: dotli-access
248+
env:
249+
DOTLI_CHECKOUT_TOKEN: ${{ secrets.DOTLI_CHECKOUT_TOKEN }}
250+
run: |
251+
if [ -n "$DOTLI_CHECKOUT_TOKEN" ]; then
252+
git config --global url."https://x-access-token:${DOTLI_CHECKOUT_TOKEN}@github.com/".insteadOf "https://github.com/"
253+
fi
254+
if git ls-remote https://github.com/paritytech/dotli.git >/dev/null 2>&1; then
255+
echo "available=true" >> "$GITHUB_OUTPUT"
256+
git submodule update --init --recursive hosts/dotli
257+
else
258+
echo "::warning::dotli submodule is not accessible to this workflow; skipping dotli e2e."
259+
echo "available=false" >> "$GITHUB_OUTPUT"
260+
fi
261+
236262
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
263+
if: steps.dotli-access.outputs.available == 'true'
237264
with:
238265
node-version: 22
239266

240267
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
268+
if: steps.dotli-access.outputs.available == 'true'
241269
with:
242270
bun-version: latest
243271

272+
- uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable
273+
if: steps.dotli-access.outputs.available == 'true'
274+
with:
275+
toolchain: stable
276+
244277
- name: Download codegen output
278+
if: steps.dotli-access.outputs.available == 'true'
245279
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
246280
with:
247281
name: codegen-output
248282

249-
- name: Build @parity/truapi
250-
run: |
251-
npm ci --ignore-scripts
252-
npm run build --prefix js/packages/truapi
283+
- name: Install wasm-pack
284+
if: steps.dotli-access.outputs.available == 'true'
285+
run: cargo install wasm-pack --version 0.14.0 --locked
253286

254287
- name: Install dotli deps
288+
if: steps.dotli-access.outputs.available == 'true'
255289
working-directory: hosts/dotli
256290
run: bun install --frozen-lockfile
257291

258-
- name: Install playground deps
259-
working-directory: playground
260-
run: yarn install --frozen-lockfile
261-
262292
- name: Install Playwright browsers
263-
working-directory: playground
264-
run: npx playwright install --with-deps chromium
293+
if: steps.dotli-access.outputs.available == 'true'
294+
working-directory: hosts/dotli/apps/host
295+
run: bunx playwright install --with-deps chromium
265296

266-
- name: Run Playwright e2e
267-
working-directory: playground
268-
run: yarn e2e
269-
270-
- name: Upload Playwright report
271-
if: failure()
297+
- name: Run dotli diagnosis e2e
298+
if: steps.dotli-access.outputs.available == 'true'
299+
run: |
300+
if [ -n "$SIGNER_BOT_SVC_TOKEN" ]; then
301+
make e2e-dotli
302+
else
303+
echo "::warning::SIGNER_BOT_SVC_TOKEN is unavailable; running QR smoke mode only."
304+
E2E_DOTLI_SMOKE=1 make e2e-dotli
305+
fi
306+
307+
- name: Upload dotli e2e results
308+
if: always()
272309
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
273310
with:
274-
name: playwright-report
275-
path: playground/playwright-report
311+
name: dotli-e2e-results
312+
path: hosts/dotli/test-results/e2e-dotli
313+
if-no-files-found: ignore
276314
retention-days: 14
277315

278316
ci-status:
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: host-packages
2+
on:
3+
push:
4+
branches: [main]
5+
paths:
6+
- 'js/packages/truapi-host-wasm/**'
7+
- 'rust/crates/truapi-server/**'
8+
- 'rust/crates/truapi-platform/**'
9+
- 'rust/crates/truapi-codegen/**'
10+
- 'rust/crates/truapi-macros/**'
11+
- 'rust/crates/truapi/**'
12+
pull_request:
13+
paths:
14+
- 'js/packages/truapi-host-wasm/**'
15+
- 'rust/crates/truapi-server/**'
16+
- 'rust/crates/truapi-platform/**'
17+
- 'rust/crates/truapi-codegen/**'
18+
- 'rust/crates/truapi-macros/**'
19+
- 'rust/crates/truapi/**'
20+
21+
jobs:
22+
wasm-bundle-check:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@stable
27+
with:
28+
targets: wasm32-unknown-unknown
29+
- uses: actions/setup-node@v4
30+
with: { node-version: 22 }
31+
- name: Install wasm-pack
32+
run: cargo install wasm-pack
33+
# Builds the bundle from the current truapi-server source and runs the
34+
# truapi-host-wasm node smoke test against those freshly-built artifacts.
35+
# The dist/wasm/ artifacts are gitignored; every consumer (local dev via
36+
# `make wasm`, CI here) builds them from the Rust source.
37+
- name: Build WASM
38+
run: make wasm
39+
- name: Sanity-check artifact presence
40+
run: |
41+
test -s js/packages/truapi-host-wasm/dist/wasm/web/truapi_server_bg.wasm
42+
test -s js/packages/truapi-host-wasm/dist/wasm/web/truapi_server.js
43+
test -s js/packages/truapi-host-wasm/dist/wasm/node/truapi_server_bg.wasm
44+
test -s js/packages/truapi-host-wasm/dist/wasm/node/truapi_server.js
45+
- name: Build @parity/truapi-host (dep)
46+
run: cd js/packages/truapi-host && npm install --no-fund --no-audit && npm run build
47+
- name: Build @parity/truapi client (dep)
48+
run: cd js/packages/truapi && npm install --no-fund --no-audit && npm run build
49+
- name: Test @parity/truapi-host-wasm against the rebuilt bundle
50+
run: cd js/packages/truapi-host-wasm && npm install --no-fund --no-audit && npm test
51+
host-packages-js-tests:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: dtolnay/rust-toolchain@stable
56+
with:
57+
targets: wasm32-unknown-unknown
58+
- uses: actions/setup-node@v4
59+
with: { node-version: 22 }
60+
- name: Install wasm-pack
61+
run: cargo install wasm-pack
62+
# The truapi-host-wasm tests load dist/wasm/{web,node}, which is
63+
# gitignored, so build it from the Rust source first.
64+
- name: Build WASM
65+
run: make wasm
66+
- name: Build @parity/truapi-host (dep)
67+
run: cd js/packages/truapi-host && npm install --no-fund --no-audit && npm run build
68+
- name: Build @parity/truapi client (dep)
69+
run: cd js/packages/truapi && npm install --no-fund --no-audit && npm run build
70+
- name: Test @parity/truapi-host-wasm
71+
run: cd js/packages/truapi-host-wasm && npm install --no-fund --no-audit && npm test

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ lerna-debug.log*
1111
node_modules
1212
target
1313

14+
# Gradle (Android workspace at repo root)
15+
/.gradle/
16+
/build/
17+
/android/*/build/
18+
local.properties
19+
1420
# Environment / secrets (never commit real env files; keep example templates)
1521
.env
1622
.env.*
@@ -39,3 +45,16 @@ playground/public/static.files
3945

4046
# Auto-generated by truapi-codegen (typecheck fixtures for rustdoc ts blocks)
4147
playground/test/generated/
48+
49+
# Auto-generated FFI / WASM binding outputs
50+
android/truapi-host/src/main/kotlin/generated/
51+
ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift
52+
ios/truapi-host/Sources/truapi_serverFFI/
53+
rust/crates/truapi-server/pkg/
54+
js/packages/truapi/src/generated/
55+
js/packages/truapi/dist/generated/
56+
js/packages/truapi-host/src/generated/
57+
js/packages/truapi-host/dist/generated/
58+
js/packages/truapi-host-wasm/src/generated/
59+
js/packages/truapi-host-wasm/dist/generated/
60+
js/packages/truapi-host-wasm/dist/wasm/

0 commit comments

Comments
 (0)