|
| 1 | +# Working on gpu.js |
| 2 | + |
| 3 | +## Build environment |
| 4 | + |
| 5 | +Use Node 22.23.1 via `~/.asdf/installs/nodejs/22.23.1/bin`. The system Node |
| 6 | +(22.2.0) is too old — early v22 hits a vinyl-fs bug that breaks gulp. Node 23 |
| 7 | +breaks headless-gl. |
| 8 | + |
| 9 | +```bash |
| 10 | +export PATH="$HOME/.asdf/installs/nodejs/22.23.1/bin:$PATH" |
| 11 | +``` |
| 12 | + |
| 13 | +`npx gulp make` runs build → beautify → minify → build-tests. It rewrites |
| 14 | +`dist/` and regenerates `test/all.html`, so run it before anything that loads |
| 15 | +the browser bundle, and commit `dist/` with the change. |
| 16 | + |
| 17 | +Note `beautify` reformats `src/`, so `gulp make` can produce unrelated |
| 18 | +whitespace churn in files you did not touch. That is expected. |
| 19 | + |
| 20 | +## Tests |
| 21 | + |
| 22 | +`npm test` runs qunit over `test/issues test/internal test/features`. |
| 23 | + |
| 24 | +The suite has platform-dependent failures that are **not** regressions: |
| 25 | + |
| 26 | +- **macOS**: 3 known failures, all `Infinity without float` (the unsigned |
| 27 | + encoding saturates to ~1.7e38 instead of producing NaN). |
| 28 | +- **Linux/Mesa**: a different and larger set, baselined in |
| 29 | + `.github/known-test-failures.txt`. CI compares against it with |
| 30 | + `.github/compare-test-failures.js` and fails only on *new* failures, so the |
| 31 | + raw exit code is not the signal. |
| 32 | +- `test/internal/math.random.js` "unique every time" is flaky (seed |
| 33 | + collisions, related to #850). A single failure there is not meaningful. |
| 34 | + |
| 35 | +Confirm any new regression test actually catches the bug by reverting the fix |
| 36 | +and watching it fail — a test that passes both ways is worse than none. |
| 37 | + |
| 38 | +## Real devices |
| 39 | + |
| 40 | +Bugs that only reproduce on real GPU drivers are a recurring theme here; three |
| 41 | +were found this way in 2.19.8 alone, none of which any CI runner could have |
| 42 | +caught. See the Testing section of README.md for how to run it. |
| 43 | + |
| 44 | +```bash |
| 45 | +npx gulp make # devices load dist/, so build first |
| 46 | +npm run test:browserstack # real iOS/Android |
| 47 | +node test/browserstack/run.js --dry-run --browsers=desktop # inspect caps, no session |
| 48 | +``` |
| 49 | + |
| 50 | +Credentials live in gitignored `test/browserstack/.credentials.json`, and as |
| 51 | +`BROWSERSTACK_USERNAME` / `BROWSERSTACK_ACCESS_KEY` repo secrets for CI. |
| 52 | + |
| 53 | +BrowserStack groups runs into one build by `buildName`, distinguishing them by |
| 54 | +`buildIdentifier`. Keep `buildName` stable — a name that varies per run creates |
| 55 | +a separate build every time and there is no single `gpu.js` entry to find in |
| 56 | +the dashboard. |
| 57 | + |
| 58 | +## Releasing |
| 59 | + |
| 60 | +Every step below is required; skipping the npm publish is the usual mistake — |
| 61 | +2.19.5 and 2.19.7 have tags and GitHub releases but were never published, so |
| 62 | +their release notes tell people to install a version that does not exist. |
| 63 | + |
| 64 | +```bash |
| 65 | +export PATH="$HOME/.asdf/installs/nodejs/22.23.1/bin:$PATH" |
| 66 | + |
| 67 | +npm version <version> --no-git-tag-version # package.json only |
| 68 | +npx gulp make # dist/ carries the version header |
| 69 | +npm test # expect the known baseline |
| 70 | + |
| 71 | +git add -A && git commit -m "chore: Release <version>" |
| 72 | +git tag <version> |
| 73 | +git push origin develop && git push origin <version> |
| 74 | + |
| 75 | +gh release create <version> --title "<version>" --notes-file <notes> |
| 76 | +``` |
| 77 | + |
| 78 | +### npm publish without an OTP code |
| 79 | + |
| 80 | +Publishing needs 2FA. Run it under a pty and npm offers **web** auth — it |
| 81 | +prints a URL to approve in a browser, and no authenticator code changes hands: |
| 82 | + |
| 83 | +```bash |
| 84 | +script -q /tmp/npm-publish.log npm publish --auth-type=web & |
| 85 | +# then read /tmp/npm-publish.log for: |
| 86 | +# Authenticate your account at: |
| 87 | +# https://www.npmjs.com/auth/cli/<uuid> |
| 88 | +``` |
| 89 | + |
| 90 | +Without a pty this fails immediately with `EOTP` and no URL: npm's `otplease` |
| 91 | +gates on `process.stdin.isTTY` and rethrows before it ever reaches the web |
| 92 | +flow. `--auth-type=web` alone is not enough. |
| 93 | + |
| 94 | +Two things that will waste time otherwise: |
| 95 | + |
| 96 | +- Do not pipe the command through `tail`/`head` — the output buffers until |
| 97 | + exit and the URL never appears while you need it. Let `script` write its own |
| 98 | + transcript and read that. |
| 99 | +- `npm view gpu.js version` lags behind a publish by up to a minute. Check |
| 100 | + `curl -s https://registry.npmjs.org/gpu.js` for the truth. |
| 101 | + |
| 102 | +If publish fails with `E404 PUT ... not found`, the npm token expired — run |
| 103 | +`npm login`. |
| 104 | + |
| 105 | +### Pushing workflow files |
| 106 | + |
| 107 | +`git push` rejects changes under `.github/workflows/` because the PAT in |
| 108 | +`GITHUB_TOKEN` lacks the `workflow` scope. Either use the keyring credential: |
| 109 | + |
| 110 | +```bash |
| 111 | +env -u GITHUB_TOKEN git push |
| 112 | +``` |
| 113 | + |
| 114 | +or push everything else and add the workflow file through the GitHub API. |
0 commit comments