Skip to content

Commit 93dae3a

Browse files
Remove hash based code and use Pyodide/WASM
1 parent ee634e4 commit 93dae3a

4 files changed

Lines changed: 31 additions & 506 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 11 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
# Deploy multilingual docs to GitHub Pages.
22
#
3-
# This workflow replaces GitHub's default Jekyll deployment so we can:
4-
# 1. Build the browser WASM bundle from demo.ml via WATCodeGenerator.
5-
# `multilingual build-wasm-bundle demo.ml` emits:
6-
# - module.wat (WebAssembly Text — educational display in docs)
7-
# - module.wasm (binary — executed in the browser REPL)
8-
# - host_shim.js (JS host import stubs for print_str, print_f64, …)
9-
# - abi_manifest.json (ABI metadata)
10-
# 2. Copy all bundle artifacts into assets/wasm/.
11-
# 3. Build the Jekyll site.
12-
# 4. Deploy _site/ to GitHub Pages.
3+
# Jobs:
4+
# 1. test-blocks — verify every executable doc code block runs correctly.
5+
# 2. build-jekyll — build the Jekyll site.
6+
# 3. deploy — publish _site/ to GitHub Pages.
137
#
14-
# The build is purely Python-driven (multilingualprogramming[wasm]).
15-
# No Rust toolchain or wasm-pack is required.
8+
# The interactive REPL and inline Run buttons execute code client-side via
9+
# Pyodide (ProgramExecutor), so no server-side WASM bundle is required.
1610
#
1711
# Trigger: every push to main, or manually via workflow_dispatch.
1812

@@ -57,112 +51,26 @@ jobs:
5751
cache: pip
5852
cache-dependency-path: multilingual-src/pyproject.toml
5953

60-
- name: Install multilingual with WASM extras
54+
- name: Install multilingual
6155
working-directory: multilingual-src
62-
run: pip install -e ".[dev,wasm]"
63-
64-
- name: Install wabt (wat2wasm, wasm-validate)
65-
run: sudo apt-get install -y wabt
56+
run: pip install -e ".[dev]"
6657

6758
- name: Install pytest
6859
run: pip install pytest
6960

7061
- name: Run code-block tests
7162
run: pytest _tests/ -v --tb=short
7263

73-
# ── Job 2: Build WASM ────────────────────────────────────────────────────
74-
build-wasm:
75-
name: Build WASM browser bundle
76-
runs-on: ubuntu-latest
77-
needs: test-blocks
78-
79-
steps:
80-
- name: Checkout docs repo (for demo.ml)
81-
uses: actions/checkout@v4
82-
83-
- name: Checkout multilingual source
84-
uses: actions/checkout@v4
85-
with:
86-
repository: johnsamuelwrites/multilingual
87-
path: multilingual-src
88-
89-
- name: Set up Python
90-
uses: actions/setup-python@v5
91-
with:
92-
python-version: '3.12'
93-
cache: pip
94-
cache-dependency-path: multilingual-src/pyproject.toml
95-
96-
- name: Install multilingual with WASM extras
97-
working-directory: multilingual-src
98-
run: pip install -e ".[dev,wasm]"
99-
100-
# wabt must be installed before the bundle build so wat2wasm is
101-
# available to assemble the WAT text → WASM binary.
102-
- name: Install wabt (wat2wasm, wasm-validate, wasm2wat)
103-
run: sudo apt-get install -y wabt
104-
105-
- name: Build browser WASM bundle from demo.ml
106-
run: |
107-
# WATCodeGenerator compiles demo.ml → WAT text (module.wat).
108-
# Additional artifacts: host_shim.js, abi_manifest.json
109-
mkdir -p wasm-out
110-
multilingual build-wasm-bundle demo.ml --out-dir wasm-out
111-
112-
- name: Assemble and validate demo WASM binary
113-
run: |
114-
# Assemble the canonical WAT text into a binary.
115-
# This works whether build-wasm-bundle emits .wasm or not;
116-
# we always produce the binary from the WAT source of truth.
117-
wat2wasm wasm-out/module.wat -o wasm-out/module.wasm
118-
wasm-validate wasm-out/module.wasm
119-
120-
- name: Stage all WASM artifacts under assets/wasm/
121-
run: |
122-
# Collect everything into assets/wasm/ so the artifact layout
123-
# matches the Jekyll source tree exactly.
124-
mkdir -p assets/wasm/blocks
125-
# Rename module.* → multilingual.* and move into assets/wasm/
126-
mv wasm-out/module.wasm assets/wasm/multilingual.wasm
127-
mv wasm-out/module.wat assets/wasm/multilingual.wat
128-
mv wasm-out/host_shim.js assets/wasm/host_shim.js
129-
mv wasm-out/abi_manifest.json assets/wasm/abi_manifest.json
130-
# Per-block binaries compiled in the next step land in assets/wasm/blocks/
131-
132-
- name: Compile per-block WASM binaries
133-
run: |
134-
# Each executable code block in the docs gets its own WASM binary,
135-
# keyed by SHA-256 hash of its content, stored in assets/wasm/blocks/.
136-
# The browser Run button fetches the per-block binary and executes it,
137-
# falling back to the demo binary if a block wasn't compiled.
138-
python _scripts/compile_blocks.py
139-
140-
- name: Upload WASM artefacts
141-
uses: actions/upload-artifact@v4
142-
with:
143-
name: wasm-pkg
144-
path: assets/wasm/
145-
retention-days: 1
146-
147-
# ── Job 3: Build Jekyll ───────────────────────────────────────────────────
64+
# ── Job 2: Build Jekyll ───────────────────────────────────────────────────
14865
build-jekyll:
14966
name: Build Jekyll site
15067
runs-on: ubuntu-latest
151-
needs: build-wasm
68+
needs: test-blocks
15269

15370
steps:
15471
- name: Checkout docs repo
15572
uses: actions/checkout@v4
15673

157-
- name: Download WASM artefacts
158-
uses: actions/download-artifact@v4
159-
with:
160-
name: wasm-pkg
161-
path: assets/wasm/
162-
# Downloaded layout (relative to repo root):
163-
# assets/wasm/multilingual.wasm, multilingual.wat, …
164-
# assets/wasm/blocks/<hash16>.wasm (one per compiled code block)
165-
16674
- name: Set up Ruby
16775
uses: ruby/setup-ruby@v1
16876
with:
@@ -180,15 +88,12 @@ jobs:
18088
JEKYLL_ENV: production
18189
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
18290

183-
- name: Inject block hashes into built HTML
184-
run: python _scripts/inject_hashes.py
185-
18691
- name: Upload Pages artefact
18792
uses: actions/upload-pages-artifact@v3
18893
with:
18994
path: _site/
19095

191-
# ── Job 4: Deploy ─────────────────────────────────────────────────────────
96+
# ── Job 3: Deploy ─────────────────────────────────────────────────────────
19297
deploy:
19398
name: Deploy to GitHub Pages
19499
runs-on: ubuntu-latest

_scripts/compile_blocks.py

Lines changed: 0 additions & 142 deletions
This file was deleted.

_scripts/inject_hashes.py

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)