openpencil/.github/workflows/rust-check.yml
Kayshen-X 372dfac047 ci(shell-native): force xvfb GLX + mesa software-render for P0 probe
Linux P0 probe was failing with `GLXBadWindow` because:
- bare `xvfb-run` brings up Xvfb with default args (no `+extension GLX`);
  the X server then advertises no GLX FBConfigs, so winit's X11 backend
  fails when glutin tries to create a GL window.
- the runner has no GPU, so even with GLX enabled mesa would not pick a
  hardware visual; without a software fallback configured glutin cannot
  resolve `ContextApi::OpenGl`.

Fix:
- pass `xvfb-run -s "-screen 0 1280x1024x24 +extension GLX +render
  -noreset"` so Xvfb advertises a 24-bit GLX-capable visual.
- set `LIBGL_ALWAYS_SOFTWARE=1`, `GALLIUM_DRIVER=llvmpipe`, and
  `MESA_GL_VERSION_OVERRIDE=4.5` so mesa loads llvmpipe (CPU
  rasterizer) and reports a desktop-GL version high enough for skia.

These env vars propagate naturally from the workflow shell down through
xvfb-run → cargo → the spawned `cargo run --example p0_probe`
subprocess (probe runs each verification in a fresh process so winit's
EventLoop singleton guard doesn't trip).
2026-05-05 12:23:07 +08:00

100 lines
3.9 KiB
YAML

name: Rust check (native)
on:
pull_request:
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/**'
- 'rust-toolchain.toml'
- 'rustfmt.toml'
- 'deny.toml'
- '.github/workflows/rust-check.yml'
push:
branches: [main, 'feat/rust-ification']
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/**'
- 'rust-toolchain.toml'
jobs:
check:
name: ${{ matrix.os }} / 1.85
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.85"
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
# Linux GL prerequisites for the P0 probe ignored test step. xvfb gives
# winit a virtual display; mesa software-rasterizes GL when no GPU is
# available; libxkbcommon-x11-dev / libwayland-dev are winit's link-time
# dependencies on Linux; libfreetype-dev / libfontconfig1-dev are
# skia-bindings' link-time dependencies on Linux (skia-safe v0.97 links
# against the system freetype + fontconfig). (No-op on macOS / Windows.)
- name: Install Linux GL prereqs (P0 probe gate)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
xvfb \
libgl1-mesa-dri libglu1-mesa libegl1 libgles2 \
libxkbcommon-dev libxkbcommon-x11-dev \
libwayland-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
libfreetype-dev libfontconfig1-dev
- run: cargo fmt --all -- --check
- run: cargo build --workspace
- run: cargo test --workspace
- run: cargo clippy --workspace --all-targets -- -D warnings
# P0 probe gate (Step 1a) — runs only the `#[ignore = "P0_PROBE_GATE"]`
# tests. Linux: route through `xvfb-run` for a virtual display.
# Windows: the test body early-returns with a "deferred" message
# (spec §8.2 WINDOWS_GPU_DEFERRED_NO_RUNNER); macOS: runs natively.
#
# Xvfb arguments:
# -screen 0 1280x1024x24 — 24-bit color so GLX visuals can match.
# +extension GLX — explicitly enable GLX (without this, a
# winit X11 window hits `GLXBadWindow` when
# the X server reports an empty FBConfig list).
# +render — RENDER extension (winit/skia path queries it).
# -noreset — keep the X server alive across the cargo
# subprocess fork (probe spawns
# `cargo run --example p0_probe` per test).
# Env:
# LIBGL_ALWAYS_SOFTWARE=1 + GALLIUM_DRIVER=llvmpipe forces mesa to
# software-render (xvfb has no GPU); without it create_context
# negotiates an unusable hardware visual.
- name: P0 probe gate (Linux)
if: runner.os == 'Linux'
env:
LIBGL_ALWAYS_SOFTWARE: '1'
GALLIUM_DRIVER: llvmpipe
MESA_GL_VERSION_OVERRIDE: '4.5'
run: |
xvfb-run -a -s "-screen 0 1280x1024x24 +extension GLX +render -noreset" \
cargo test -p openpencil-shell-native --test p0_probe -- --ignored
- name: P0 probe gate (macOS / Windows)
if: runner.os != 'Linux'
run: cargo test -p openpencil-shell-native --test p0_probe -- --ignored
deny:
name: cargo-deny (native)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: EmbarkStudios/cargo-deny-action@v2 # auto-updates within v2.x; runner cargo at this stage carries cargo-deny 0.18+ which handles modern transitive manifests (Phase 1 Task 1.8 finding)
with:
command: check