refactor(web-platform): release V0.6 精简代码
web-platform-ci / TypeScript、Lint、Unit、Build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
web-platform-ci / TypeScript、Lint、Unit、Build (pull_request) Has been cancelled
web-platform-ci / Playwright E2E (pull_request) Has been cancelled

This commit is contained in:
2026-08-28 14:10:16 +08:00
parent 8e3d56d619
commit f4b415c54f
2283 changed files with 208 additions and 962948 deletions
-447
View File
@@ -1,447 +0,0 @@
# This configuration is used to build and test on GitHub Actions only.
# It is not the same configuration that is used by Google DeepMind to create release binaries.
# The "official" binaries are built with Clang 13 on all platforms, and are linked against libc++
# on Linux.
#
# We set CMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF here to reduce build time.
# It is highly recommended that this is set to ON for production builds.
#
# Build speed notes:
# * The compiler matrix lives in build_matrix.json. Pull requests build the
# representative "core" subset; pushes to main run the full compiler sweep.
# (See generate_matrix() in build_steps.sh.)
# * Studio/Filament and WASM are NOT built in the main matrix - they are covered
# by the dedicated `studio` and `wasm` jobs below. WASM in particular is built
# with emcc, which ignores the host compiler, so building it per-compiler added
# no coverage.
# * ccache is used to wrap the compiler. PR branches fall back to main's cache, so
# the expensive (and pinned) Filament build is restored rather than recompiled.
# TODO(matijak): Consider switching Windows to Ninja builds only, this configures slightly faster
# and brings Windows in line with other OSes. Also we wouldn't need to specify the --config option
# in the build step because Ninja doesn't support multiple configurations (unlike MSBuild).
name: build
on:
push:
branches:
- main
paths-ignore:
- "doc/**"
- "**/README.md"
pull_request:
paths-ignore:
- "doc/**"
- "**/README.md"
# Limit the default GITHUB_TOKEN to read-only. No job here writes via the token:
# checkout reads the repo; ccache/cache and upload-artifact use their own backend
# tokens; the chat notification uses a secret webhook.
permissions:
contents: read
jobs:
# Compute the build matrix based on the event: PRs get the "core" representative
# compiler set, pushes to main get the full sweep.
setup:
name: "setup (compute matrix)"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@v6
- name: Generate build matrix
id: generate
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: bash ./.github/workflows/build_steps.sh generate_matrix
mujoco:
needs: setup
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
name: "${{ matrix.label }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Prepare Linux
if: ${{ runner.os == 'Linux' }}
run: bash ./.github/workflows/build_steps.sh prepare_linux
- name: Prepare macOS
if: ${{ runner.os == 'macOS' }}
run: brew install ninja
- uses: actions/setup-python@v6
with:
python-version: "3.11"
# uv makes the dependency install much faster, with a cross-run cache. POSIX
# only: Windows stays on pip (it is not a Python-setup bottleneck, and this
# keeps the venv activate fixup path untouched there).
- name: Install uv
if: ${{ runner.os != 'Windows' }}
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-dependency-glob: "python/build_requirements*.txt"
- name: Prepare Python
shell: bash
env:
TMPDIR: ${{ matrix.tmpdir }}
run: bash ./.github/workflows/build_steps.sh prepare_python
# ccache dramatically speeds up warm rebuilds. The key is the matrix label so
# each compiler gets its own cache; the action's restore-keys let PR branches
# fall back to main's cache. ccache on Windows/MSVC is finicky and Windows
# isn't the bottleneck, so we skip it there.
- name: Setup ccache
if: ${{ runner.os != 'Windows' }}
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: ${{ matrix.label }}
max-size: "1.5G"
- name: Configure MuJoCo
env:
TMPDIR: ${{ matrix.tmpdir }}
CMAKE_ARGS: ${{ matrix.cmake_args }}
run: bash ./.github/workflows/build_steps.sh configure_mujoco
- name: Upload CMake Configure Log
if: always()
uses: actions/upload-artifact@v7
with:
name: cmake-configure-log-${{ matrix.label }}
path: build/CMakeFiles/CMakeConfigureLog.yaml
retention-days: 5
- name: Build MuJoCo
working-directory: build
env:
CMAKE_BUILD_ARGS: ${{ matrix.cmake_build_args }}
run: bash ../.github/workflows/build_steps.sh build_mujoco
- name: Test MuJoCo
working-directory: build
run: bash ../.github/workflows/build_steps.sh test_mujoco
- name: Install MuJoCo
working-directory: build
run: bash ../.github/workflows/build_steps.sh install_mujoco
- name: Copy plugins (POSIX)
if: ${{ runner.os != 'Windows' }}
working-directory: build
env:
TMPDIR: ${{ matrix.tmpdir }}
run: bash ../.github/workflows/build_steps.sh copy_plugins_posix
- name: Copy plugins (Windows)
if: ${{ runner.os == 'Windows' }}
working-directory: build
env:
TMPDIR: ${{ matrix.tmpdir }}
run: bash ../.github/workflows/build_steps.sh copy_plugins_window
- name: Configure samples
working-directory: sample
env:
TMPDIR: ${{ matrix.tmpdir }}
CMAKE_ARGS: ${{ matrix.cmake_args }}
run: bash ../.github/workflows/build_steps.sh configure_samples
- name: Build samples
working-directory: sample/build
run: cmake --build . --config=Release ${{ matrix.cmake_build_args }}
- name: Configure simulate
working-directory: simulate
env:
TMPDIR: ${{ matrix.tmpdir }}
CMAKE_ARGS: ${{ matrix.cmake_args }}
run: bash ../.github/workflows/build_steps.sh configure_simulate
- name: Build simulate
working-directory: simulate/build
env:
CMAKE_BUILD_ARGS: ${{ matrix.cmake_build_args }}
run: bash ../../.github/workflows/build_steps.sh build_simulate
- name: Make Python sdist
shell: bash
working-directory: python
env:
TMPDIR: ${{ matrix.tmpdir }}
run: bash ../.github/workflows/build_steps.sh make_python_sdist
- name: Build Python bindings
if: ${{ runner.os != 'Windows' }}
shell: bash
working-directory: python/dist
env:
TMPDIR: ${{ matrix.tmpdir }}
CMAKE_ARGS: ${{ matrix.cmake_args }}
run: bash ../../.github/workflows/build_steps.sh build_python_bindings
- name: Install Python bindings
if: ${{ runner.os != 'Windows' }}
shell: bash
working-directory: python/dist
env:
TMPDIR: ${{ matrix.tmpdir }}
run: bash ../../.github/workflows/build_steps.sh install_python_bindings
- name: Test Python bindings
if: ${{ runner.os != 'Windows' }}
shell: bash
env:
MUJOCO_GL: disable
TMPDIR: ${{ matrix.tmpdir }}
run: bash ./.github/workflows/build_steps.sh test_python_bindings
# MJX (mujoco.mjx) is covered by the dedicated `mjx` job below; it is
# compiler-independent so it does not need to run in every matrix job.
- name: Notify team chat
shell: bash
env:
GCHAT_API_URL: ${{ secrets.GCHAT_API }}
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
CHATMSG_JOB_ID: ${{ matrix.label }}
if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != ''
run: bash ./.github/workflows/build_steps.sh notify_team_chat
# This job quickly determines if MuJoCo Studio is broken. It is the only place
# Filament is compiled in CI, so ccache here is what keeps the long pole short.
studio:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
label: "ubuntu-24.04-clang-18-studio"
cmake_args: >-
-G Ninja
-DCMAKE_C_COMPILER:STRING=clang-18
-DCMAKE_CXX_COMPILER:STRING=clang++-18
-DMUJOCO_HARDEN:BOOL=ON
# gcc canary: Filament is compiler-dependent and historically finicky on
# gcc, so keep one gcc Studio build even though the matrix no longer does.
- os: ubuntu-24.04
label: "ubuntu-24.04-gcc-14-studio"
cmake_args: >-
-G Ninja
-DCMAKE_C_COMPILER:STRING=gcc-14
-DCMAKE_CXX_COMPILER:STRING=g++-14
-DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed
- os: windows-2025
label: "windows-2025-ninja-studio"
cmake_args: >-
-G Ninja
-DCMAKE_SYSTEM_VERSION=10.0.26100.0
- os: macos-15
label: "macos-15-arm64-studio"
cmake_args: >-
-G Ninja
-DCMAKE_CXX_FLAGS="-Wno-error=deprecated-declarations"
-DMUJOCO_HARDEN:BOOL=ON
name: "${{ matrix.label }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Prepare Windows (setup MSVC)
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
- name: Prepare Linux
if: ${{ runner.os == 'Linux' }}
run: bash ./.github/workflows/build_steps.sh prepare_linux
# Key the cache on the Filament pin: hashing cmake/third_party_deps/filament.cmake
# captures BOTH the pinned commit hash and the FILAMENT_* build flags, so bumping
# either starts a fresh cache namespace instead of restoring stale artifacts.
# (Correctness does not depend on this: ccache is content-addressed on the full
# compiler invocation, so changing any build flag forces a recompile regardless.)
- name: Setup ccache
if: ${{ runner.os != 'Windows' }}
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: ${{ matrix.label }}-filament-${{ hashFiles('cmake/third_party_deps/filament.cmake') }}
restore-keys: ${{ matrix.label }}-filament-
max-size: "2.0G"
- name: Configure Studio
env:
CMAKE_ARGS: ${{ matrix.cmake_args }}
run: bash ./.github/workflows/build_steps.sh configure_studio
- name: Build Studio
run: bash ./.github/workflows/build_steps.sh build_studio
- name: Notify team chat
shell: bash
env:
GCHAT_API_URL: ${{ secrets.GCHAT_API }}
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
CHATMSG_JOB_ID: ${{ matrix.label }}
if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != ''
run: bash ./.github/workflows/build_steps.sh notify_team_chat
# This job quickly determines if WASM bindings are broken.
wasm:
name: "ubuntu-24.04-clang-18-wasm"
runs-on: ubuntu-24.04
env:
label: "ubuntu-24.04-clang-18-wasm"
cmake_args: >-
-G Ninja
-DCMAKE_C_COMPILER:STRING=clang-18
-DCMAKE_CXX_COMPILER:STRING=clang++-18
-DMUJOCO_HARDEN:BOOL=ON
steps:
- uses: actions/checkout@v6
- name: Setup Node.js for WASM bindings
uses: actions/setup-node@v6
with:
node-version: '24.x'
- name: Prepare Linux
if: ${{ runner.os == 'Linux' }}
run: bash ./.github/workflows/build_steps.sh prepare_linux
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: ${{ env.label }}
max-size: "1.5G"
# For convenience run multiple build_steps functions in a single step.
- name: Prepare, Build and Test WASM bindings
env:
CMAKE_ARGS: ${{ env.cmake_args }}
run: |
bash ./.github/workflows/build_steps.sh npm_ci
bash ./.github/workflows/build_steps.sh setup_emsdk
bash ./.github/workflows/build_steps.sh build_test_wasm
- name: Notify team chat
shell: bash
env:
GCHAT_API_URL: ${{ secrets.GCHAT_API }}
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
CHATMSG_JOB_ID: ${{ env.label }}
if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != ''
run: bash ./.github/workflows/build_steps.sh notify_team_chat
# MJX (mujoco.mjx) is pure JAX/XLA and compiler-independent: it imports the
# mujoco Python package only as a reference, so its tests run once here instead
# of in every matrix job. MuJoCo is built WITHOUT the C++ test suite (MJX does
# not need it) to keep the build lean.
mjx:
name: "ubuntu-24.04-clang-18-mjx"
runs-on: ubuntu-24.04
env:
TMPDIR: "/tmp"
CMAKE_ARGS: >-
-G Ninja
-DCMAKE_C_COMPILER:STRING=clang-18
-DCMAKE_CXX_COMPILER:STRING=clang++-18
-DMUJOCO_HARDEN:BOOL=ON
-DMUJOCO_BUILD_TESTS:BOOL=OFF
steps:
- uses: actions/checkout@v6
- name: Prepare Linux
run: bash ./.github/workflows/build_steps.sh prepare_linux
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-dependency-glob: "python/build_requirements*.txt"
- name: Prepare Python
run: bash ./.github/workflows/build_steps.sh prepare_python
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: ubuntu-24.04-clang-18-mjx
max-size: "1.0G"
- name: Configure MuJoCo
run: bash ./.github/workflows/build_steps.sh configure_mujoco
- name: Build MuJoCo
working-directory: build
run: bash ../.github/workflows/build_steps.sh build_mujoco
- name: Install MuJoCo
working-directory: build
run: bash ../.github/workflows/build_steps.sh install_mujoco
- name: Copy plugins
working-directory: build
run: bash ../.github/workflows/build_steps.sh copy_plugins_posix
- name: Make Python sdist
working-directory: python
run: bash ../.github/workflows/build_steps.sh make_python_sdist
- name: Build Python bindings
working-directory: python/dist
run: bash ../../.github/workflows/build_steps.sh build_python_bindings
- name: Install Python bindings
working-directory: python/dist
run: bash ../../.github/workflows/build_steps.sh install_python_bindings
- name: Package MJX
working-directory: mjx
run: bash ../.github/workflows/build_steps.sh package_mjx
- name: Install MJX
working-directory: mjx
run: bash ../.github/workflows/build_steps.sh install_mjx
- name: Test MJX
working-directory: mjx
run: bash ../.github/workflows/build_steps.sh test_mjx
- name: Notify team chat
shell: bash
env:
GCHAT_API_URL: ${{ secrets.GCHAT_API }}
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CHATMSG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
CHATMSG_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
CHATMSG_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
CHATMSG_JOB_ID: "ubuntu-24.04-clang-18-mjx"
if: failure() && github.ref_name == 'main' && github.event_name == 'push' && env.GCHAT_API_URL != ''
run: bash ./.github/workflows/build_steps.sh notify_team_chat
-69
View File
@@ -1,69 +0,0 @@
{
"comment": "Build matrix for build.yml. 'tier' controls when an entry runs: 'core' runs on every pull_request and push; 'extended' runs only on push to main (full compiler sweep). See generate_matrix() in build_steps.sh.",
"include": [
{
"os": "ubuntu-24.04",
"label": "ubuntu-24.04-gcc-14",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=gcc-14 -DCMAKE_CXX_COMPILER:STRING=g++-14 -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed",
"tmpdir": "/tmp",
"tier": "core"
},
{
"os": "ubuntu-24.04",
"label": "ubuntu-24.04-gcc-13",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=gcc-13 -DCMAKE_CXX_COMPILER:STRING=g++-13 -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed",
"tmpdir": "/tmp",
"tier": "extended"
},
{
"os": "ubuntu-22.04",
"label": "ubuntu-22.04-gcc-12",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=gcc-12 -DCMAKE_CXX_COMPILER:STRING=g++-12 -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--no-as-needed",
"tmpdir": "/tmp",
"tier": "core"
},
{
"os": "ubuntu-24.04",
"label": "ubuntu-24.04-clang-18",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-18 -DCMAKE_CXX_COMPILER:STRING=clang++-18 -DMUJOCO_HARDEN:BOOL=ON",
"tmpdir": "/tmp",
"tier": "core"
},
{
"os": "ubuntu-24.04",
"label": "ubuntu-24.04-clang-17",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-17 -DCMAKE_CXX_COMPILER:STRING=clang++-17 -DMUJOCO_HARDEN:BOOL=ON",
"tmpdir": "/tmp",
"tier": "extended"
},
{
"os": "ubuntu-24.04",
"label": "ubuntu-24.04-clang-16",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-16 -DCMAKE_CXX_COMPILER:STRING=clang++-16 -DMUJOCO_HARDEN:BOOL=ON",
"tmpdir": "/tmp",
"tier": "extended"
},
{
"os": "ubuntu-22.04",
"label": "ubuntu-22.04-clang-15",
"cmake_args": "-G Ninja -DCMAKE_C_COMPILER:STRING=clang-15 -DCMAKE_CXX_COMPILER:STRING=clang++-15 -DMUJOCO_HARDEN:BOOL=ON",
"tmpdir": "/tmp",
"tier": "extended"
},
{
"os": "macos-15",
"label": "macos-15-arm64",
"cmake_args": "-G Ninja -DMUJOCO_HARDEN:BOOL=ON",
"tmpdir": "/tmp",
"tier": "core"
},
{
"os": "windows-2025",
"label": "windows-2025",
"cmake_args": "-DCMAKE_SYSTEM_VERSION=\"10.0.26100.0\"",
"cmake_build_args": "-- -m",
"tmpdir": "C:/Temp",
"tier": "core"
}
]
}
-430
View File
@@ -1,430 +0,0 @@
#!/bin/bash
# Copyright 2025 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO(matijak): Make all cmake commands run from the top-level directory, and
# consider making the builds parallel.
# Wrap the compiler with ccache when it is available (set up by ccache-action in
# CI). This makes warm rebuilds - including the expensive, pinned Filament build -
# much faster. ccache is content-addressed on the full compiler invocation, so
# changing a flag or source forces a recompile: a stale object is never reused.
# Guarded by `command -v` so the script still works locally without ccache.
CCACHE_ARGS=""
if command -v ccache >/dev/null 2>&1; then
CCACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi
# Emit the build matrix for build.yml as a step output. On pull_request we run
# only the representative "core" compiler set; on push (e.g. to main) we run the
# full compiler sweep. Tiers are defined in build_matrix.json.
generate_matrix() {
echo "Generating build matrix for event '${GITHUB_EVENT_NAME}'..."
local file=".github/workflows/build_matrix.json"
local matrix
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
matrix="$(jq -c '{include: [.include[] | select(.tier == "core") | del(.tier)]}' "${file}")"
else
matrix="$(jq -c '{include: [.include[] | del(.tier)]}' "${file}")"
fi
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
echo "${matrix}" | jq .
}
prepare_linux() {
echo "Preparing Linux..."
sudo apt-get update && sudo apt-get install \
libgl1-mesa-dev \
libwayland-dev \
libxinerama-dev \
libxcursor-dev \
libxkbcommon-dev \
libxrandr-dev \
libxi-dev \
ninja-build
}
prepare_python() {
echo "Preparing Python..."
repo="${PWD}"
pushd "${TMPDIR}" > /dev/null
python -m venv venv
if [[ $RUNNER_OS == "Windows" ]]; then
mkdir venv/bin
fixpath="$(s="$(cat venv/Scripts/activate | grep VIRTUAL_ENV=)"; echo "${s:13:-1}")"
sed -i "s#$(printf "%q" "${fixpath}")#$(cygpath "${fixpath}")#g" venv/Scripts/activate
ln -s ../Scripts/activate venv/bin/activate
fi
source venv/bin/activate
# Install build deps with uv when available (set up by setup-uv in CI on
# POSIX) - much faster than pip. Fall back to pip otherwise (e.g. Windows,
# local dev). The venv is still created by `python -m venv`, so pip stays
# available for later steps (pip wheel / python -m build).
if command -v uv > /dev/null 2>&1; then
uv pip install --require-hashes -r "${repo}/python/build_requirements.txt"
uv pip install --require-hashes -r "${repo}/python/build_requirements_usd.txt"
else
python -m pip install --upgrade --require-hashes -r "${repo}/python/build_requirements.txt"
python -m pip install --upgrade --require-hashes -r "${repo}/python/build_requirements_usd.txt"
fi
popd > /dev/null
}
npm_ci() {
echo "Installing NPM dependencies for WASM bindings..."
pushd wasm
npm ci
popd
}
setup_emsdk() {
echo "Setting up Emscripten..."
git clone https://github.com/emscripten-core/emsdk.git
./emsdk/emsdk install 4.0.10
./emsdk/emsdk activate 4.0.10
# Force installing emscripten's typescript dependencies. This is a
# workaround for the github update to a newer typescript, which gives an
# error on the deprecated `--outFile` flag.
pushd emsdk/upstream/emscripten
npm i
popd
}
configure_mujoco() {
echo "Configuring MuJoCo..."
# Disable IPO/LTO to cut build time. Skip this on Windows: turning off MSVC's
# whole-program optimization (/GL) exposes a latent heap corruption in
# SetConstTest.SleepingNotAllowed (a real bug worth a separate investigation),
# and Windows build time is not a CI bottleneck.
local ipo_off="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF"
if [[ "${RUNNER_OS}" == "Windows" ]]; then
ipo_off=""
fi
mkdir build &&
cd build &&
cmake .. \
-DCMAKE_BUILD_TYPE:STRING=Release \
${ipo_off} \
-DCMAKE_INSTALL_PREFIX:STRING=${TMPDIR}/mujoco_install \
-DMUJOCO_BUILD_EXAMPLES:BOOL=OFF \
${CCACHE_ARGS} \
${CMAKE_ARGS}
}
build_mujoco() {
echo "Building MuJoCo..."
cmake --build . --config=Release ${CMAKE_BUILD_ARGS}
}
test_mujoco() {
echo "Testing MuJoCo..."
# ctest defaults to serial. The suite is ~1650 independent tests that use
# unique temp files (mkstemp / testing::TempDir) and declare no RUN_SERIAL /
# RESOURCE_LOCK, so running them in parallel is safe and ~2x faster on POSIX.
# Windows is kept serial conservatively: parallel-safety on the Windows file
# system is unverified and its test time is not a CI bottleneck.
if [[ "${RUNNER_OS}" == "Windows" ]]; then
ctest -C Release --output-on-failure .
else
local ncpu
ncpu="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo "${NUMBER_OF_PROCESSORS:-2}")"
ctest -C Release --output-on-failure --parallel "${ncpu}" .
fi
}
install_mujoco() {
echo "Installing MuJoCo..."
cmake --install .
}
copy_plugins_posix() {
echo "Copying plugins..."
mkdir -p ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp lib/libactuator.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp lib/libelasticity.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp lib/libsensor.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp lib/libsdf_plugin.* ${TMPDIR}/mujoco_install/mujoco_plugin
}
copy_plugins_window() {
echo "Copying plugins..."
mkdir -p ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp bin/Release/actuator.dll ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp bin/Release/elasticity.dll ${TMPDIR}/mujoco_install/mujoco_plugin &&
cp bin/Release/sensor.dll ${TMPDIR}/mujoco_install/mujoco_plugin
}
configure_samples() {
echo "Configuring samples..."
# Samples are tiny, so they keep the default IPO/LTO: disabling it saves no
# meaningful build time and would expose the same gcc -Werror false positives
# that -O3-without-LTO triggers (see configure_mujoco).
mkdir build &&
cd build &&
cmake .. \
-DCMAKE_BUILD_TYPE:STRING=Release \
-Dmujoco_ROOT:STRING=${TMPDIR}/mujoco_install \
${CCACHE_ARGS} \
${CMAKE_ARGS}
}
configure_simulate() {
echo "Configuring simulate..."
# See configure_samples: keep the default IPO/LTO for this small build.
mkdir build &&
cd build &&
cmake .. \
-DCMAKE_BUILD_TYPE:STRING=Release \
-Dmujoco_ROOT:STRING=${TMPDIR}/mujoco_install \
${CCACHE_ARGS} \
${CMAKE_ARGS}
}
build_simulate() {
echo "Building simulate..."
cmake --build . --config=Release ${CMAKE_BUILD_ARGS}
}
configure_studio() {
echo "Configuring Studio..."
cmake -B build \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \
-DUSE_STATIC_LIBCXX=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DMUJOCO_BUILD_EXAMPLES=OFF \
-DMUJOCO_BUILD_SIMULATE=OFF \
-DMUJOCO_BUILD_STUDIO=ON \
-DMUJOCO_BUILD_TESTS=OFF \
-DMUJOCO_TEST_PYTHON_UTIL=OFF \
-DMUJOCO_WITH_USD=OFF \
-DMUJOCO_USE_FILAMENT=ON \
${CCACHE_ARGS} \
${CMAKE_ARGS}
echo "Configuring Studio... DONE"
}
build_studio() {
echo "Building Studio..."
cmake --build build --config=Release --target mujoco_studio --parallel
echo "Building Studio... DONE"
}
make_python_sdist() {
echo "Making Python sdist..."
source ${TMPDIR}/venv/bin/activate &&
./make_sdist.sh
}
build_python_bindings() {
echo "Building Python bindings..."
source ${TMPDIR}/venv/bin/activate
# pip unpacks the sdist into a randomized temp dir every run, so the absolute
# source/include paths differ each time and defeat ccache (0% hit, full
# recompile). CCACHE_BASEDIR rewrites absolute paths under it to paths relative
# to the (also-in-temp) build cwd, cancelling the random component so objects
# hash identically across runs. CCACHE_SLOPPINESS ignores timestamp/path noise.
#
# Do NOT add system_headers here: CMake adds the imported mujoco target's
# include dir (MUJOCO_PATH/include) as -isystem, so ccache would treat the
# public MuJoCo headers as system headers and skip hashing them. A change that
# lives only in those headers (a new mjData field, a new enum value) would then
# go undetected and ccache would reuse an object compiled against the old struct
# layout, producing an ABI-mismatched binding (wrong field offsets, stale
# mjNENABLE, signature mismatch). The mtime/ctime flags are kept: they handle the
# temp-dir churn without affecting header content detection.
export CCACHE_BASEDIR="${TMPDIR}"
export CCACHE_SLOPPINESS="time_macros,include_file_mtime,include_file_ctime,pch_defines,locale"
MUJOCO_PATH="${TMPDIR}/mujoco_install" \
MUJOCO_PLUGIN_PATH="${TMPDIR}/mujoco_install/mujoco_plugin" \
MUJOCO_CMAKE_ARGS="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF ${CCACHE_ARGS} ${CMAKE_ARGS}" \
pip wheel -v --no-deps mujoco-*.tar.gz
}
install_python_bindings() {
echo "Installing Python bindings..."
source ${TMPDIR}/venv/bin/activate &&
pip install --no-index mujoco-*.whl
}
test_python_bindings() {
echo "Testing Python bindings..."
source ${TMPDIR}/venv/bin/activate &&
pytest -v --pyargs mujoco
}
build_test_wasm() {
echo "Building and testing WASM bindings..."
source emsdk/emsdk_env.sh
export PATH="$(pwd)/node_modules/.bin:$PATH"
echo "Build MuJoCo with Emscripten (Multi-Threaded)..."
emcmake cmake -B build_wasm_mt \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \
-DMUJOCO_WASM_THREADS=ON \
${CCACHE_ARGS} \
$WASM_CMAKE_ARGS
cmake --build build_wasm_mt --parallel $(nproc)
echo "Run bindings tests for Multi-Threaded version..."
npm run test --prefix ./wasm
echo "Moving Multi-Thread version under mt subfolder..."
mkdir -p wasm/dist/mt
mv wasm/dist/mujoco.* wasm/dist/mt/
echo "Build MuJoCo with Emscripten (Single-Threaded)..."
emcmake cmake -B build_wasm_st \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \
-DMUJOCO_WASM_THREADS=OFF \
${CCACHE_ARGS} \
$WASM_CMAKE_ARGS
cmake --build build_wasm_st --parallel $(nproc)
echo "Run bindings tests for Single-Threaded version..."
npm run test --prefix ./wasm
}
package_wasm() {
echo "Publishing WASM bindings..."
cp wasm/package.npm.json wasm/dist/package.json
cp wasm/README.md wasm/dist/README.md
VERSION="${VERSION:-${GITHUB_REF#refs/tags/}}"
npm --prefix wasm/dist version "${VERSION}" --no-git-tag-version
npm pack --dry-run ./wasm/dist
npm publish ./wasm/dist --access public --provenance
}
package_mjx() {
echo "Packaging MJX..."
source ${TMPDIR}/venv/bin/activate &&
python -m build .
}
install_mjx() {
echo "Installing MJX..."
source ${TMPDIR}/venv/bin/activate
# The MJX requirements (jax, jaxlib, scipy, ...) are a big install; use uv when
# available. Keep pip for the local --no-index wheel.
if command -v uv > /dev/null 2>&1; then
uv pip install --require-hashes -r requirements.txt
else
pip install --require-hashes -r requirements.txt
fi
pip install --no-index dist/mujoco_mjx-*.whl
}
test_mjx() {
echo "Testing MJX..."
source ${TMPDIR}/venv/bin/activate &&
pytest -n auto -v -k 'not IntegrationTest' --pyargs mujoco.mjx
}
notify_team_chat() {
CHATMSG="$(cat <<-'EOF' | python3
import json
import os
env = lambda x: os.getenv(x, '')
data = dict(
result=env('JOB_URL'),
job=env('CHATMSG_JOB_ID'),
commit=env('GITHUB_SHA')[:6],
name=env('CHATMSG_AUTHOR_NAME').replace('```', ''),
email=env('CHATMSG_AUTHOR_EMAIL'),
msg=env('CHATMSG_COMMIT_MESSAGE').replace('```', '')
)
text = '<{result}|*FAILURE*>: job `{job}` commit `{commit}`\n```Author: {name} <{email}>\n\n{msg}```'.format(**data)
print(json.dumps({'text' : text}))
EOF
)" &&
curl "$GCHAT_API_URL&threadKey=$GITHUB_SHA&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD" \
-X POST \
-H "Content-Type: application/json" \
--data-raw "${CHATMSG}"
}
build_mujoco_live() {
echo "Setting up Emscripten SDK..."
source emsdk/emsdk_env.sh
echo "Building Filament tools, targeting host platform..."
cmake -S . -B build_host -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_STATIC_LIBCXX=OFF \
-DMUJOCO_BUILD_STUDIO=ON \
-DMUJOCO_USE_FILAMENT=ON \
-DMUJOCO_BUILD_TESTS=OFF \
-DMUJOCO_BUILD_EXAMPLES=OFF \
-DMUJOCO_BUILD_SIMULATE=OFF
cmake --build build_host --target matc resgen cmgen mujoco_filament_assets -j$(nproc)
echo "Building WASM app..."
emcmake cmake -S . -B build_wasm -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DMUJOCO_BUILD_STUDIO=ON \
-DMUJOCO_USE_FILAMENT=ON \
-DMUJOCO_BUILD_TESTS_WASM=OFF \
-DMUJOCO_NATIVE_BUILD_DIR=$(pwd)/build_host
cmake --build build_wasm --target mujoco_studio -j$(nproc)
}
# Discover functions defined in this script by finding identifiers followed by
# "()" and capturing the identifier as a valid function name.
VALID_FUNCTIONS=()
while IFS= read -r func_name; do
VALID_FUNCTIONS+=("$func_name")
done < <(grep -E '^[[:alnum:]_]+\(\)' "$0" | sed 's/().*$//')
# Exit with an error if the requested function is not found.
if [[ ! " ${VALID_FUNCTIONS[*]} " =~ " ${1} " ]]; then
echo "Usage: $0 {$(IFS='|'; echo "${VALID_FUNCTIONS[*]}")}, got '$1'"
exit 1
fi
# Set options to print the commands being run, and cause the script to exit with
# an error code if any command fails. Note we do this just before executing
# the requested function to avoid cluttering the output with the above command
# discovery code.
set -xe
# Execute the requested function.
"$1"
+34
View File
@@ -0,0 +1,34 @@
name: web-platform-ci
on:
push:
pull_request:
permissions:
contents: read
jobs:
quality:
name: TypeScript、Lint、Unit、Build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm run check
e2e:
name: Playwright E2E
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm run build
- run: npm run test:e2e
-23
View File
@@ -1,23 +0,0 @@
# Run pre-commit hooks on files changed in the PR only.
name: lint
on:
pull_request:
permissions:
contents: read
jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: pre-commit/action@v3.0.1
with:
extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
-58
View File
@@ -1,58 +0,0 @@
name: live
on:
push:
branches:
- live
permissions:
contents: read
pages: write
id-token: write
jobs:
build-and-upload-artifacts:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Prepare Linux
run: bash ./.github/workflows/build_steps.sh prepare_linux
- name: Setup Emscripten
run: bash ./.github/workflows/build_steps.sh setup_emsdk
- name: Build MuJoCo Live
env:
CC: clang-18
CXX: clang++-18
run: bash ./.github/workflows/build_steps.sh build_mujoco_live
- name: Prepare files for GitHub Pages
run: |
mkdir -p dist/bin
cp -r build_wasm/bin/* dist/bin/
cp src/experimental/studio/live.html dist/index.html
cp src/experimental/studio/live.css dist/live.css
cp src/experimental/studio/live.js dist/live.js
cp src/experimental/studio/favicon.ico dist/favicon.ico
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || true)
if [ -n "$COMMIT_HASH" ]; then
sed -i "s/__COMMIT_HASH_PLACEHOLDER__/$COMMIT_HASH/g" dist/index.html
fi
- name: Upload GitHub Pages artifacts
uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy-pages:
needs: build-and-upload-artifacts
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
-50
View File
@@ -1,50 +0,0 @@
name: publish-wasm
on:
push:
tags:
- '[0-9]*.[0-9]*.[0-9]*'
workflow_dispatch:
inputs:
tag_version:
description: 'Release tag version to deploy'
required: true
default: '0.0.0'
permissions:
id-token: write
contents: read
jobs:
publish:
name: Publish MuJoCo WASM package
runs-on: ubuntu-24.04
env:
VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_version || github.ref_name }}
steps:
- uses: actions/checkout@v6
- name: Setup Node.js for WASM bindings
uses: actions/setup-node@v6
with:
node-version: '24.x'
- name: Prepare Linux
run: bash ./.github/workflows/build_steps.sh prepare_linux
- name: Install NPM Dependencies for WASM bindings
run: bash ./.github/workflows/build_steps.sh npm_ci
- name: Setup Emscripten for WASM bindings
run: bash ./.github/workflows/build_steps.sh setup_emsdk
- name: Build WASM bindings
run: bash ./.github/workflows/build_steps.sh build_test_wasm
- name: Package WASM bindings
env:
VERSION: ${{ env.VERSION }}
run: bash ./.github/workflows/build_steps.sh package_wasm
-28
View File
@@ -1,28 +0,0 @@
name: update-live
on:
release:
types: [published] # Trigger when publishing releases ...
workflow_dispatch: # or manually (updates to main HEAD).
permissions:
contents: write
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout MuJoCo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fast-forward the live branch
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
git fetch origin main:refs/remotes/origin/main
REF_NAME="origin/main"
else
REF_NAME="${{ github.ref_name }}"
fi
git push origin ${REF_NAME}:refs/heads/live