Skip to content

Check your browser build in CI

The native workflow from Check your game in CI checks the Windows game. This optional second workflow checks the browser build from Build for the browser. It builds the game, tests its rules under Node, packages the page with its notices, draws and quits that packaged page in headless Chrome, then keeps the package as a downloadable artifact of the run.

Your game’s repository can remain private. The workflow asks only for contents: read to check out its files. It grants no Pages or deployment permissions, uses no publication secret and publishes no website. Put your game on the web remains the separate manual publication route; choosing where to host the finished game does not decide who can read its source.

Start with the unchanged starter project, or the same project made through the submodule walkthrough, already on GitHub. Keep its existing .github/workflows/ci.yml for Windows. From the project’s folder, make a second file:

Terminal window
if not exist .github\workflows mkdir .github\workflows
notepad .github\workflows\browser.yml

Paste this entire workflow into it, save and close Notepad. If you renamed the game, change the three input filenames containing MyGame and their .js and .wasm output names to your game’s names too. The HTML becomes index.html in the package, as in the manual web release.

.github/workflows/browser.yml
# Optional: copy to .github/workflows/browser.yml in your game project.
# Builds, tests and keeps a downloadable browser artifact. It publishes no site.
name: browser build and test
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
env:
EMSDK_VERSION: 6.0.12
jobs:
browser:
runs-on: windows-latest
timeout-minutes: 90
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
allow-unsafe-pr-checkout: false
- name: Find build tools and Chrome
shell: pwsh
run: |
$vs = & "${env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $vs) { throw 'Visual Studio C++ tools were not found.' }
"VCVARS=$vs/VC/Auxiliary/Build/vcvars64.bat" >> $env:GITHUB_ENV
"VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_ENV
$chrome = "$env:ProgramFiles/Google/Chrome/Application/chrome.exe"
if (-not (Test-Path -LiteralPath $chrome)) { throw 'Chrome was not found.' }
"CHROME=$chrome" >> $env:GITHUB_ENV
- name: Cache Emscripten
id: emsdk
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: C:/emsdk
key: starter-emsdk-${{ runner.os }}-${{ env.EMSDK_VERSION }}
- name: Install Emscripten
if: steps.emsdk.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch %EMSDK_VERSION% https://github.com/emscripten-core/emsdk.git C:/emsdk || exit /b 1
call C:/emsdk/emsdk.bat install %EMSDK_VERSION% || exit /b 1
call C:/emsdk/emsdk.bat activate %EMSDK_VERSION% || exit /b 1
- name: Cache vcpkg's browser binaries
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/AppData/Local/vcpkg/archives
key: starter-wasm-${{ runner.os }}-${{ env.EMSDK_VERSION }}-${{ hashFiles('vcpkg.json') }}
restore-keys: starter-wasm-${{ runner.os }}-${{ env.EMSDK_VERSION }}-
- name: Configure, build and test rules
run: |
call "%VCVARS%" || exit /b 1
call C:/emsdk/emsdk_env.bat || exit /b 1
cmake --preset wasm-release || exit /b 1
cmake --build --preset wasm-release --parallel 2 || exit /b 1
ctest --preset wasm-release || exit /b 1
- name: Package the browser runtime and notices
run: |
call C:/emsdk/emsdk_env.bat || exit /b 1
set "engine=external/labrador"
set "emscripten=%EMSDK%/upstream/emscripten"
"%EMSDK_NODE%" "%engine%/tools/web_bundle/bundle.mjs" ^
--out out/web-release ^
--repository . ^
--emscripten "%emscripten%" ^
--build-type Release ^
--file "index.html=out/build/wasm-release/game/MyGame.html" ^
--file "MyGame.js=out/build/wasm-release/game/MyGame.js" ^
--file "MyGame.wasm=out/build/wasm-release/game/MyGame.wasm" ^
--notice "%engine%/NOTICE" ^
--licence "Labrador=%engine%/LICENSE" ^
--licence "Microsoft sample code=%engine%/tools/web_bundle/Microsoft-LICENSE.txt" ^
--licence "RapidJSON=%engine%/external/rapidjson/license.txt" ^
--licence "LodePNG=out/build/wasm-release/vcpkg_installed/wasm32-emscripten/share/lodepng/copyright" ^
--licence "JetBrains Mono=game/content/fonts/OFL.txt" ^
--licence "Emscripten=%emscripten%/LICENSE" ^
--licence "libc++=%emscripten%/system/lib/libcxx/LICENSE.TXT" ^
--licence "libc++abi=%emscripten%/system/lib/libcxxabi/LICENSE.TXT" ^
--licence "libunwind=%emscripten%/system/lib/libunwind/LICENSE.TXT" ^
--licence "compiler-rt=%emscripten%/system/lib/compiler-rt/LICENSE.TXT" ^
--licence "musl=%emscripten%/system/lib/libc/musl/COPYRIGHT" || exit /b 1
- name: Start Chrome's GPU process
continue-on-error: true
run: |
call C:/emsdk/emsdk_env.bat || exit /b 1
"%EMSDK_NODE%" external/labrador/tests/render/web/run_page.mjs --browser "%CHROME%" --page out/web-release/index.html --quit-keys Escape,Enter --timeout 60
- name: Draw and quit the packaged page
run: |
call C:/emsdk/emsdk_env.bat || exit /b 1
"%EMSDK_NODE%" external/labrador/tests/render/web/run_page.mjs --browser "%CHROME%" --page out/web-release/index.html --quit-keys Escape,Enter --timeout 60
- name: Keep the tested runtime
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mygame-browser
path: out/web-release/
if-no-files-found: error
retention-days: 7
archive: true

Commit the file and push when you are ready, as Sending the next change shows. The separate browser build and test workflow starts on pushes and pull requests. Its browser job has the same 90-minute timeout as the native example. Installing the pinned SDK and fetching vcpkg packages makes its first run longer than a cached one.

The SDK version matches Labrador’s pinned compiler. Emscripten and vcpkg have separate caches; the browser dependency key includes both that compiler version and the game’s manifest. Each command step loads its own tool environment, since steps do not share a command prompt.

The rules run through ctest --preset wasm-release. The template embeds its content in the module, so its runtime is three files: MyGame.html, MyGame.js and MyGame.wasm. The bundler renames the page to index.html and adds NOTICE.txt and BUILD.json in out/web-release/. The record names the source commit, compiler version, build type and file hashes; it does not measure a physical display or prove that the game plays well on a phone.

The browser check serves that package, rather than the build folder. After it draws, Escape,Enter opens and confirms the starter’s quit question; success ends with Module.onQuit was called. Console errors and warnings, loader failures, Module.onError and a page that never quits fail the check. If you change the game’s quit controls, update --quit-keys in both browser steps. A missing runtime or licence input fails packaging, and a failed final browser check prevents the artifact upload.

The first browser step starts Chrome’s GPU process and may fail without failing the job. Labrador’s hosted runners have a recorded first-page context-loss problem; the second step must pass against the same package. The first load is preparation and supplies no acceptance evidence on its own.

On a successful run, open its summary and download mygame-browser under Artifacts. It contains the five files above and is retained for seven days. Serve the extracted folder over HTTP as Build for the browser shows; opening the HTML as a local file does not run it. Before sharing or publishing it, add the visible notices link from Put your game on the web step 1 to your page template and rebuild.

If you later use external content such as a .data preload, worker scripts or other downloaded files, add those runtime files to the bundler’s --file list and keep their relative names. Add the licences of any new dependencies too. The final browser check will catch missing files the tested route loads; it cannot discover files used only by a later level or another route.

The workflow’s permissions, artifact path, required final check and optional nature have offline fixtures. Those fixtures execute this file’s actual packaging command against runtime and licence files, check its names and hashes, and require failure when each input is missing. On 16 November 2026 the assembled starter’s Release build and Node rules passed locally with Emscripten 6.0.12, and its packaged page quit in Chrome 157.0.8103.78 through the keys above. This recipe has not yet run as its own hosted workflow; local command execution and a future GitHub run remain distinct evidence.

Development documentation (unreleased). Built from Labrador aceb130 of 2026-11-20.

All documentation versions