Skip to content
Draft
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a421c24
ci: add metadrive simulation workflow
dhruvpandoh Jun 24, 2026
93e9b64
ci: use python 3.12 for metadrive workflow
dhruvpandoh Jun 24, 2026
66a4fc9
ci: install comma metadrive fork
dhruvpandoh Jun 24, 2026
4d4d609
ci: fix metadrive asset pull
dhruvpandoh Jun 24, 2026
cf7852d
ci: install imgui for metadrive build
dhruvpandoh Jun 24, 2026
50a1bb4
ci: use comma imgui dependency
dhruvpandoh Jun 25, 2026
f6b4cf1
ci: pull lfs assets for metadrive build
dhruvpandoh Jun 25, 2026
90a0b6e
ci: pull only font lfs assets
dhruvpandoh Jun 25, 2026
5696e70
ci: pull all font lfs assets
dhruvpandoh Jun 25, 2026
6c03b6c
ci: pull model lfs assets for metadrive build
dhruvpandoh Jun 25, 2026
c4ac7cf
ci: install pytest-xdist for metadrive test
dhruvpandoh Jun 25, 2026
df6281a
ci: ignore repo pytest config for metadrive test
dhruvpandoh Jun 25, 2026
247f971
ci: set pytest rootdir for metadrive test
dhruvpandoh Jun 25, 2026
25da09f
ci: fix metadrive test path
dhruvpandoh Jun 25, 2026
246a2b8
ci: pull sound lfs assets for metadrive test
dhruvpandoh Jun 25, 2026
efb40d9
ci: print metadrive failure logs
dhruvpandoh Jun 25, 2026
2910793
ci: print metadrive failure diagnostics
dhruvpandoh Jun 25, 2026
ca8fe20
ci: run metadrive test with ONNX CPU
dhruvpandoh Jun 25, 2026
4a1fe26
ci: reduce cpu contention in metadrive test
dhruvpandoh Jun 25, 2026
e2fcc42
ci: prioritize metadrive test process
dhruvpandoh Jun 25, 2026
46af340
ci: use actions python for prioritized metadrive test
dhruvpandoh Jun 25, 2026
1b6888e
ci: preserve python path for metadrive test
dhruvpandoh Jun 25, 2026
523251a
ci: show metadrive runtime output
dhruvpandoh Jun 25, 2026
ec60d28
ci: use openpilot testing dependencies for metadrive
dhruvpandoh Jun 25, 2026
dd70cbc
ci: extend metadrive test duration on actions
dhruvpandoh Jun 25, 2026
b07a53d
ci: extend metadrive bridge duration on actions
dhruvpandoh Jun 25, 2026
f3939e4
ci: revert metadrive test timeout changes
dhruvpandoh Jun 25, 2026
d3f7150
ci: configure virtual audio for metadrive
dhruvpandoh Jun 25, 2026
5af455e
ci: remove extra cpu limits for metadrive
dhruvpandoh Jun 25, 2026
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
263 changes: 263 additions & 0 deletions .github/workflows/metadrive-simulation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
name: MetaDrive Simulation Test

on:
pull_request:
branches: [master]
paths:
- ".github/workflows/metadrive-simulation.yml"
- "tools/sim/**"
- "selfdrive/**"
- "system/**"
- "cereal/**"
- "openpilot/**"
- "pyproject.toml"
- "uv.lock"
workflow_dispatch:

concurrency:
group: metadrive-simulation-${{ github.ref }}
cancel-in-progress: true

jobs:
metadrive-simulation:
runs-on: ubuntu-24.04
timeout-minutes: 30

env:
DISPLAY: ":99"
LIBGL_ALWAYS_SOFTWARE: "1"
GALLIUM_DRIVER: "llvmpipe"
LP_NUM_THREADS: "4"
MESA_GL_VERSION_OVERRIDE: "3.3"
MESA_GLSL_VERSION_OVERRIDE: "330"
SIMULATION: "1"
PASSIVE: "0"
SKIP_FW_QUERY: "1"
ONNXCPU: "1"
CI: "true"
PYTHONUNBUFFERED: "1"

steps:
- name: Checkout openpilot
uses: actions/checkout@v4
with:
submodules: recursive
lfs: false

- name: Pull font LFS assets
run: |
git lfs install
git lfs pull --include="openpilot/selfdrive/assets/fonts/*,openpilot/selfdrive/assets/sounds/*,openpilot/selfdrive/modeld/models/*" --exclude=""

- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /opt/ghc "$AGENT_TOOLSDIRECTORY" || true
df -h

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
ca-certificates \
capnproto \
libcapnp-dev \
ffmpeg \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libegl1 \
libegl1-mesa-dev \
libgles2-mesa-dev \
libgl1-mesa-dev \
libgl1-mesa-dri \
libglx-mesa0 \
libglu1-mesa-dev \
mesa-utils \
mesa-common-dev \
xvfb \
x11-utils \
pulseaudio \
portaudio19-dev

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Start Xvfb
run: |
Xvfb :99 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset > /tmp/xvfb.log 2>&1 &
echo "XVFB_PID=$!" >> "$GITHUB_ENV"
sleep 5

if ! xdpyinfo -display :99 >/dev/null 2>&1; then
echo "Xvfb failed to start"
cat /tmp/xvfb.log
exit 1
fi

- name: Verify software OpenGL
run: |
glxinfo | grep -E "OpenGL renderer|OpenGL version" || true

- name: Start virtual audio
run: |
pulseaudio --start --exit-idle-time=-1 || true
sleep 2
pactl load-module module-null-sink sink_name=virtual-speaker || true
pactl set-default-sink virtual-speaker || true
pactl info || true
pactl list sinks short || true

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -e ".[testing]"
python -m pip install \
"metadrive-simulator @ git+https://github.com/commaai/metadrive.git@minimal" \
"imgui @ git+https://github.com/commaai/dependencies.git@release-imgui#subdirectory=imgui" \
pytest-timeout

- name: Pull MetaDrive assets
run: |
python - <<'PY'
from metadrive.pull_asset import pull_asset
pull_asset(False)
PY

- name: Build openpilot
run: |
scons -u -j$(nproc)

- name: Run MetaDrive simulation test
id: metadrive_test
timeout-minutes: 15
run: |
"$pythonLocation/bin/python" -m pytest \
"$GITHUB_WORKSPACE/openpilot/tools/sim/tests/test_metadrive_bridge.py::TestMetaDriveBridge::test_driving" \
-o addopts="" \
-v \
--tb=short \
--timeout=900 \
--log-cli-level=INFO \
-s
- name: Print failure diagnostics
if: failure()
run: |
echo "=== Disk ==="
df -h || true

echo "=== Memory ==="
free -h || true

echo "=== OOM / kernel messages ==="
dmesg -T | grep -Ei "killed process|out of memory|oom|modeld|python" | tail -100 || true

echo "=== Running processes ==="
ps aux | sort -nrk 4 | head -40 || true

echo "=== Find logs ==="
find /tmp "$HOME/.comma"* "$GITHUB_WORKSPACE" -type f \( \
-name "*.log" -o \
-name "crash*" -o \
-name "error*" -o \
-name "*.txt" \
\) 2>/dev/null | sort | head -200

echo "=== Tail logs ==="
for f in $(find /tmp "$HOME/.comma"* "$GITHUB_WORKSPACE" -type f \( \
-name "*.log" -o \
-name "crash*" -o \
-name "error*" \
\) 2>/dev/null | sort | head -80); do
echo ""
echo "----- $f -----"
tail -200 "$f" || true
done

- name: Print simulation logs on failure
if: failure()
run: |
echo "=== Searching for crash/error logs ==="
find /tmp "$HOME/.comma" "$GITHUB_WORKSPACE" -type f \( \
-name "*.log" -o \
-name "crash*" -o \
-name "error*" -o \
-name "*.txt" \
\) 2>/dev/null | sort | head -200

echo "=== Showing likely crash/error logs ==="
for f in $(find /tmp "$HOME/.comma" "$GITHUB_WORKSPACE" -type f \( \
-name "*.log" -o \
-name "crash*" -o \
-name "error*" \
\) 2>/dev/null | sort | head -50); do
echo ""
echo "----- $f -----"
tail -200 "$f" || true
done

- name: Collect simulation artifacts
if: always()
run: |
mkdir -p simulation_artifacts

for location in /tmp /tmp/comma "$HOME/.comma" "$GITHUB_WORKSPACE"; do
if [ -d "$location" ]; then
find "$location" \( \
-name "*.qlog" -o \
-name "*.rlog" -o \
-name "*.hevc" -o \
-name "fcamera.hevc" -o \
-name "dcamera.hevc" -o \
-name "ecamera.hevc" -o \
-name "error.log" -o \
-name "crash.log" -o \
-name "*.log" \
\) -type f -exec cp --parents {} simulation_artifacts/ \; 2>/dev/null || true
fi
done

cat > simulation_artifacts/metadata.txt << EOF
MetaDrive Simulation Test
=========================
Run ID: ${{ github.run_id }}
Run attempt: ${{ github.run_attempt }}
Commit: ${{ github.sha }}
Test outcome: ${{ steps.metadrive_test.outcome }}
Date: $(date -Iseconds)

System
======
OS: $(uname -a)
Python: $(python --version 2>&1)
OpenGL:
$(glxinfo | grep -E "OpenGL renderer|OpenGL version" || true)

Files
=====
EOF

find simulation_artifacts -type f -maxdepth 10 -print >> simulation_artifacts/metadata.txt
cat simulation_artifacts/metadata.txt

- name: Upload simulation artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: metadrive-simulation-${{ github.run_id }}-${{ github.run_attempt }}
path: simulation_artifacts/
retention-days: 30
if-no-files-found: warn

- name: Cleanup
if: always()
run: |
pulseaudio --kill || true
if [ -n "${XVFB_PID:-}" ]; then
kill "$XVFB_PID" || true
fi
Loading