npm test was a brace counter: it checked each file was >10 chars and that {
and } counts matched. It passed on a build whose shader would not compile.
- tests/shaders.test.js compiles the game's real GLSL with glslangValidator
(Khronos' reference compiler) under a three.js-style attribute prefix, and
includes a canary that asserts a known-bad vec4 construction is REJECTED, so
the suite cannot pass vacuously.
- tests/terrain.test.js covers heightfield determinism (the "persistent world"
claim), airport flattening inside the 200 m radius with no leakage outside it,
out-of-bounds behaviour, plausible height range, and vertex colour counts.
- scripts/headless-check.mjs (npm run test:render) serves dist/, drives the
game over raw CDP with SwiftShader software WebGL, and fails if the canvas is
black, the shaders fail to compile, or the scene does not change after input.
No new dependencies: Node 22 built-in fetch/WebSocket. 120 s watchdog so it
cannot hang a runner.
- npm test -> node --test "tests/*.test.js"; old checker kept as npm run lint:syntax.
- CI installs glslang-tools and runs the real tests; render job is
continue-on-error because not every runner has a Chrome binary.
Verified non-vacuous: re-breaking the shader makes the unit tests fail 2/4 with
glslang's own "constructor: too many arguments" and makes the render check fail
four ways (1 distinct colour, 0/64000 lit pixels, shader error, frozen scene).
57 lines
1.3 KiB
YAML
57 lines
1.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
# glslangValidator is Khronos' reference GLSL compiler. The shader tests compile
|
|
# the game's real shaders with it; without it they skip, so install it explicitly.
|
|
- name: Install GLSL compiler
|
|
run: sudo apt-get update && sudo apt-get install -y glslang-tools
|
|
|
|
- run: npm ci
|
|
|
|
- name: Unit tests (shaders, terrain)
|
|
run: npm test
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Basic syntax lint
|
|
run: npm run lint:syntax
|
|
|
|
# Needs a Chrome/Chromium binary and CPU-rendered WebGL (SwiftShader). Not every
|
|
# runner has one, so this reports without blocking the pipeline.
|
|
render:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Install Chromium
|
|
run: sudo apt-get update && sudo apt-get install -y chromium
|
|
|
|
- run: npm ci
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Headless render check
|
|
run: CHROME=$(command -v chromium || command -v chromium-browser) npm run test:render
|