Skip to content

Commit 524c6f8

Browse files
sipemuclaude
andcommitted
Add WASM tests for npm workflow
- Add test-wasm job to npm.yml workflow - Create tests/web.rs with smoke tests for: - Version check - t-test - Shapiro-Wilk - Mann-Whitney U - Pearson correlation - Publish job now depends on passing tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7a408d7 commit 524c6f8

File tree

3 files changed

+134
-1
lines changed

3 files changed

+134
-1
lines changed

.github/workflows/npm.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,26 @@ jobs:
4848
path: crates/anofox-statistics-js/pkg/
4949
retention-days: 1
5050

51+
test-wasm:
52+
name: Test WebAssembly
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Setup Rust
58+
uses: dtolnay/rust-toolchain@stable
59+
with:
60+
targets: wasm32-unknown-unknown
61+
62+
- name: Install wasm-pack
63+
run: cargo install wasm-pack
64+
65+
- name: Run WASM tests
66+
run: wasm-pack test --node crates/anofox-statistics-js
67+
5168
publish-npm:
5269
name: Publish to npm
53-
needs: [build-wasm]
70+
needs: [build-wasm, test-wasm]
5471
runs-on: ubuntu-latest
5572
permissions:
5673
contents: read

AGENTS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Agent Instructions
2+
3+
This project uses **bd** (beads) for issue tracking. Run `bd onboard` to get started.
4+
5+
## Quick Reference
6+
7+
```bash
8+
bd ready # Find available work
9+
bd show <id> # View issue details
10+
bd update <id> --status in_progress # Claim work
11+
bd close <id> # Complete work
12+
bd sync # Sync with git
13+
```
14+
15+
## Landing the Plane (Session Completion)
16+
17+
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
18+
19+
**MANDATORY WORKFLOW:**
20+
21+
1. **File issues for remaining work** - Create issues for anything that needs follow-up
22+
2. **Run quality gates** (if code changed) - Tests, linters, builds
23+
3. **Update issue status** - Close finished work, update in-progress items
24+
4. **PUSH TO REMOTE** - This is MANDATORY:
25+
```bash
26+
git pull --rebase
27+
bd sync
28+
git push
29+
git status # MUST show "up to date with origin"
30+
```
31+
5. **Clean up** - Clear stashes, prune remote branches
32+
6. **Verify** - All changes committed AND pushed
33+
7. **Hand off** - Provide context for next session
34+
35+
**CRITICAL RULES:**
36+
- Work is NOT complete until `git push` succeeds
37+
- NEVER stop before pushing - that leaves work stranded locally
38+
- NEVER say "ready to push when you are" - YOU must push
39+
- If push fails, resolve and retry until it succeeds
40+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//! WASM integration tests for anofox-statistics-js
2+
3+
#![cfg(target_arch = "wasm32")]
4+
5+
use wasm_bindgen_test::*;
6+
7+
use anofox_statistics_js::*;
8+
9+
#[wasm_bindgen_test]
10+
fn test_version() {
11+
let version = get_version();
12+
assert!(!version.is_empty());
13+
assert!(version.starts_with("0."));
14+
}
15+
16+
#[wasm_bindgen_test]
17+
fn test_t_test() {
18+
let x = js_sys::Float64Array::new_with_length(5);
19+
x.copy_from(&[1.0, 2.0, 3.0, 4.0, 5.0]);
20+
21+
let y = js_sys::Float64Array::new_with_length(5);
22+
y.copy_from(&[2.0, 3.0, 4.0, 5.0, 6.0]);
23+
24+
let result = js_t_test(
25+
x.to_vec().as_slice(),
26+
y.to_vec().as_slice(),
27+
JsTTestKind::Welch,
28+
JsAlternative::TwoSided,
29+
Some(0.0),
30+
Some(0.95),
31+
);
32+
33+
assert!(result.is_ok());
34+
}
35+
36+
#[wasm_bindgen_test]
37+
fn test_shapiro_wilk() {
38+
let data = js_sys::Float64Array::new_with_length(10);
39+
data.copy_from(&[2.3, 3.1, 2.8, 3.5, 2.9, 3.2, 2.7, 3.0, 2.6, 3.3]);
40+
41+
let result = js_shapiro_wilk(data.to_vec().as_slice());
42+
assert!(result.is_ok());
43+
}
44+
45+
#[wasm_bindgen_test]
46+
fn test_mann_whitney() {
47+
let x = js_sys::Float64Array::new_with_length(5);
48+
x.copy_from(&[1.0, 2.0, 3.0, 4.0, 5.0]);
49+
50+
let y = js_sys::Float64Array::new_with_length(5);
51+
y.copy_from(&[3.0, 4.0, 5.0, 6.0, 7.0]);
52+
53+
let result = js_mann_whitney_u(
54+
x.to_vec().as_slice(),
55+
y.to_vec().as_slice(),
56+
JsAlternative::TwoSided,
57+
Some(true),
58+
Some(false),
59+
None,
60+
Some(0.0),
61+
);
62+
63+
assert!(result.is_ok());
64+
}
65+
66+
#[wasm_bindgen_test]
67+
fn test_pearson_correlation() {
68+
let x = js_sys::Float64Array::new_with_length(5);
69+
x.copy_from(&[1.0, 2.0, 3.0, 4.0, 5.0]);
70+
71+
let y = js_sys::Float64Array::new_with_length(5);
72+
y.copy_from(&[2.0, 4.0, 6.0, 8.0, 10.0]);
73+
74+
let result = js_pearson(x.to_vec().as_slice(), y.to_vec().as_slice(), Some(0.95));
75+
assert!(result.is_ok());
76+
}

0 commit comments

Comments
 (0)