Skip to content

Commit 2bf6e64

Browse files
authored
Merge pull request #4 from alexnodeland/claude/plan-wasm-packaging-01Y9i4UHPs7y3YSMrjK5ZJCD
2 parents 17ee2e0 + d12a316 commit 2bf6e64

29 files changed

Lines changed: 6131 additions & 56 deletions

.github/workflows/ci.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,44 @@ jobs:
122122
env:
123123
RUSTDOCFLAGS: -Dwarnings
124124

125+
wasm:
126+
name: WASM Build
127+
runs-on: ubuntu-latest
128+
steps:
129+
- uses: actions/checkout@v4
130+
131+
- name: Install Rust toolchain
132+
uses: dtolnay/rust-toolchain@stable
133+
with:
134+
targets: wasm32-unknown-unknown
135+
136+
- name: Install wasm-pack
137+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
138+
139+
- name: Cache cargo registry
140+
uses: actions/cache@v4
141+
with:
142+
path: |
143+
~/.cargo/registry
144+
~/.cargo/git
145+
target
146+
key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }}
147+
restore-keys: |
148+
${{ runner.os }}-cargo-wasm-
149+
150+
- name: Check WASM crate compiles
151+
run: cargo check -p fugue-evo-wasm --target wasm32-unknown-unknown
152+
153+
- name: Build WASM package
154+
run: wasm-pack build crates/fugue-evo-wasm --target web
155+
156+
- name: Run WASM tests (Node.js)
157+
run: wasm-pack test --node crates/fugue-evo-wasm
158+
125159
# Summary job that depends on all other jobs
126160
ci-success:
127161
name: CI Success
128-
needs: [check, fmt, clippy, test, doc]
162+
needs: [check, fmt, clippy, test, doc, wasm]
129163
runs-on: ubuntu-latest
130164
if: always()
131165
steps:
@@ -135,7 +169,8 @@ jobs:
135169
[[ "${{ needs.fmt.result }}" != "success" ]] || \
136170
[[ "${{ needs.clippy.result }}" != "success" ]] || \
137171
[[ "${{ needs.test.result }}" != "success" ]] || \
138-
[[ "${{ needs.doc.result }}" != "success" ]]; then
172+
[[ "${{ needs.doc.result }}" != "success" ]] || \
173+
[[ "${{ needs.wasm.result }}" != "success" ]]; then
139174
echo "One or more jobs failed"
140175
exit 1
141176
fi

Cargo.lock

Lines changed: 105 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[workspace]
2+
members = [".", "crates/fugue-evo-wasm"]
3+
14
[package]
25
name = "fugue-evo"
36
version = "0.1.0"
@@ -9,6 +12,12 @@ repository = "https://github.com/alexnodeland/fugue-evo"
912
keywords = ["genetic-algorithm", "evolution", "optimization", "probabilistic-programming"]
1013
categories = ["algorithms", "science"]
1114

15+
[features]
16+
default = ["std", "parallel", "checkpoint"]
17+
std = []
18+
parallel = ["rayon"]
19+
checkpoint = [] # File-based checkpointing (requires std)
20+
1221
[dependencies]
1322
# Linear algebra for CMA-ES
1423
nalgebra = "0.33"
@@ -17,27 +26,33 @@ nalgebra = "0.33"
1726
rand = "0.8"
1827
rand_distr = "0.4"
1928

20-
# Parallelism
21-
rayon = "1.10"
29+
# Parallelism (optional)
30+
rayon = { version = "1.10", optional = true }
2231

2332
# Serialization
2433
serde = { version = "1.0", features = ["derive"] }
2534
serde_json = "1.0"
2635
bincode = "1.3"
2736

28-
# Compression for checkpoints
29-
zstd = "0.13"
30-
3137
# Error handling
3238
thiserror = "2.0"
3339

3440
# Observability
3541
tracing = "0.1"
3642
fugue-ppl = "0.1.0"
3743

44+
# WASM support (enabled via getrandom js feature when targeting wasm32)
45+
[target.'cfg(target_arch = "wasm32")'.dependencies]
46+
getrandom = { version = "0.2", features = ["js"] }
47+
3848
[dev-dependencies]
3949
# Testing utilities
4050
proptest = "1.5"
4151
criterion = "0.5"
4252
approx = "0.5"
4353
tempfile = "3.10"
54+
55+
# Examples requiring parallel feature
56+
[[example]]
57+
name = "island_model"
58+
required-features = ["parallel"]

0 commit comments

Comments
 (0)