8000 Add GitHub Pages deployment for WASM app by johschmitz · Pull Request #852 · esmini/esmini · GitHub
[go: up one dir, main page]

Skip to content
8000
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/publish_esmini_wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Publish esmini WASM app

on:
push:
branches:
- master
paths:
- .github/workflows/publish_esmini_wasm.yml
- EnvironmentSimulator/Applications/esmini-wasm/**
- EnvironmentSimulator/Libraries/esminiJS/**
- EnvironmentSimulator/Modules/**
- externals/**
- scripts/patches/**
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: publish-esmini-wasm
cancel-in-progress: false

jobs:
build:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04

steps:
- name: Check out esmini
uses: actions/checkout@v6
with:
submodules: true
lfs: false

- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y bzip2 cmake ninja-build

- name: Install Emscripten
run: |
git clone https://github.com/emscripten-core/emsdk.git "$RUNNER_TEMP/emsdk"
"$RUNNER_TEMP/emsdk/emsdk" install 6.0.10
"$RUNNER_TEMP/emsdk/emsdk" activate 6.0.10

- name: Build esminiJS
working-directory: EnvironmentSimulator/Libraries/esminiJS
run: |
source "$RUNNER_TEMP/emsdk/emsdk_env.sh"
./build.sh
test -s ../../Applications/esmini-wasm/esmini.js

- name: Configure GitHub Pages
uses: actions/configure-pages@v5

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: EnvironmentSimulator/Applications/esmini-wasm

deploy:
if: github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ EnvironmentSimulator/Libraries/esminiJS/build*/*
support/generated
CMakeUserPresets.json
.DS_Store
EnvironmentSimulator/Libraries/esminiJS/example/esmini.js
EnvironmentSimulator/Applications/esmini-wasm/esmini.js
EnvironmentSimulator/Applications/esmini-wasm/esmini.wasm
35 changes: 35 additions & 0 deletions EnvironmentSimulator/Applications/esmini-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# esmini WASM web app

This application is published at <https://esmini.github.io/esmini/>. Its HTML,
JavaScript, styles, and bundled sample assets live in this directory. The
Emscripten wrapper lives in `EnvironmentSimulator/Libraries/esminiJS`; its
build script places the generated runtime here so the application stays
self-contained without duplicating the WASM build logic.

## Publish flow

The `Publish esmini WASM app` workflow runs for relevant changes on `master` or
when manually dispatched on `master`. It builds `esmini.js` with Emscripten,
uploads the application directory as a GitHub Pages artifact, and deploys it
from this repository. Generated app files are not committed to either the
esmini repository or the documentation repository, so repeated publishes do
not grow their Git histories. This is a separate project site at
`https://esmini.github.io/esmini/`; alongside the existing documentation site
at `https://esmini.github.io/`.

In the esmini repository settings, enable Pages and select **GitHub Actions**
as the build and deployment source. No cross-repository token is needed. The
workflow deploys the contents of this application directory to the project
site root.

The runtime is built with Emscripten's single-file WASM packaging, so `esmini.js`
contains the WASM payload and is copied with the static viewer files. Three.js
is loaded from unpkg as configured in the viewer's import map.

## Local preview

Build esminiJS using the instructions in
`EnvironmentSimulator/Libraries/esminiJS/README.md`, then serve this directory
over HTTP. From the repository root, run
`python3 -m http.server 8080 --directory EnvironmentSimulator/Applications/esmini-wasm`
and open <http://localhost:8080/>.
16 changes: 8 additions & 8 deletions EnvironmentSimulator/Libraries/esminiJS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This directory contains the standalone Emscripten/WebAssembly wrapper for esmini

Status:

- intended as the starting point for browser integrations
- not yet a complete web visualization solution
- currently focused on simulation stepping and data access, not rendering
- provides the WebAssembly simulation runtime and browser-facing API
- the maintained three.js browser application is in `EnvironmentSimulator/Applications/esmini-wasm`
- the build script copies the generated runtime into the application directory

## Points of attention

Expand Down Expand Up @@ -100,7 +100,7 @@ mkdir build
cd build
emcmake cmake ..
emmake ninja
copy esmini.js ..\example /y
copy esmini.js ..\..\..\Applications\esmini-wasm /y
cd ..
```

Expand All @@ -109,15 +109,15 @@ cd ..

Linux & Mac
```
ll example/esmini.js
ls -l ../../Applications/esmini-wasm/esmini.js
```

Windows cmd
```
dir example\esmini.js
dir ..\..\Applications\esmini-wasm\esmini.js
```

* Load `example/index.html` in a browser
* Serve `EnvironmentSimulator/Applications/esmini-wasm` over HTTP and open its `index.html`
- The page should load the `esmini.js` runtime successfully
- Use the demo buttons to step a scenario and inspect object state output in the page log

Expand Down Expand Up @@ -156,4 +156,4 @@ Compatibility helpers kept for the existing demo:

These helpers still accumulate snapshots across multiple simulation steps, but new web clients should prefer the live stepping API.

The example directory now also contains a separate three.js viewer page that consumes `get_road_geometry()` and the live frame API.
The three.js application consumes `get_road_geometry()` and the live frame API; see `EnvironmentSimulator/Applications/esmini-wasm/README.md` for local preview and publishing details.
8 changes: 4 additions & 4 deletions EnvironmentSimulator/Libraries/esminiJS/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd -- "$script_dir/../../.." && pwd)"
build_dir="${script_dir}/build"
example_dir="${script_dir}/example"
app_dir="${repo_root}/EnvironmentSimulator/Applications/esmini-wasm"
patched_fmt_root="${build_dir}/patched-externals/fmt"
patched_fmt_include_dir="${patched_fmt_root}/include"
fmt_patch="${repo_root}/scripts/patches/fmt-11.2.0-emscripten-cstdlib.patch"
Expand Down Expand Up @@ -58,9 +58,9 @@ cd "$build_dir"
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DFMT_OVERRIDE_INCLUDE_DIR="$patched_fmt_include_dir" ..
cmake --build . --parallel "$parallel_jobs"

cp -f esmini.js "$example_dir/"
cp -f esmini.js "$app_dir/"
if [[ -f esmini.wasm ]]; then
cp -f esmini.wasm "$example_dir/"
cp -f esmini.wasm "$app_dir/"
fi

echo "Built esminiJS artifacts in $build_dir and copied runtime files to $example_dir"
echo "Built esminiJS artifacts in $build_dir and copied runtime files to $app_dir"
49 changes: 0 additions & 49 deletions EnvironmentSimulator/Libraries/esminiJS/example/README.md

This file was deleted.

0