Files
photocraft/scripts/ci-gpu-lavapipe.py
T
aiongg 0e3523cdcd CI: shard the Linux and Windows tests, lint leg, xtask environment fix, rust-cache v2.9.3
- xtask starts every cargo without the variables `cargo run` sets for xtask
  (CARGO_MANIFEST_DIR, CARGO_PKG_*, ...), so a build script that declares
  `rerun-if-env-changed` for them (ring) no longer reruns, with the whole
  craft facade above it, between builds inside and outside xtask.
- `cargo xtask ci` splits into the gate's parts without a second step list:
  `lint` (fmt, egui-fork, clippy, layers, panel-commands, scorecard, wasm,
  i18n report), `archive` (test build into the nextest archive, doctests),
  `tests --from <dir>` (test and panic_hunt from the extracted archive, on
  $NEXTEST_PARTITION; --gpu / --no-gpu select by the gpu test group) and
  `build` (cache warm-up). Plain `cargo xtask ci` still runs every step.
  PHOTOCRAFT_CI_EXCLUDE leaves packages out of the test build and doctests.
- The `ci` nextest profile's archive carries the xtask binary, so a shard
  builds nothing (scripts/ci-test-shard.sh).
- Linux gate: lint leg, one build, four shards. Shard 1 runs the gpu group
  alone on lavapipe and checks its output (scripts/ci-gpu-lavapipe.py now
  wraps that run); the second GPU run and its rebuild are gone.
- Windows unit, integration, clippy and warm legs move onto the shared gate
  (Windows runner, lint leg for Clippy, four shards), keeping the PR
  selection from the platforms job, rust-lld, /OPT:NOICF, /DEBUG:NONE and
  the D:\t target dir.
- The slowest-tests-first priorities apply on Linux too.
- Swatinem/rust-cache v2.9.3 by commit for this repository's own cache
  steps, with fresh keys; cache-version v2 for the gate and docs entries.
  `test (without heif)` restores the gate's entry through the shared action.
  Dispatch-only jobs no longer save caches no pull request reads; the quick
  perf suite restores perf-nightly's entry.
- windows_delay_loads reads the app from NEXTEST_BIN_EXE_photocraft, as the
  other app tests do, since archives relocate binaries.
2026-11-18 19:04:43 +00:00

69 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""Run a command with wgpu on lavapipe, and fail if a GPU comparison in its output was skipped.
The Linux gate runs nextest's `gpu` test group in a shard of its own through this script
(`ci-gpu-lavapipe.py <xtask> ci tests --from <dir> --gpu`, .github/workflows/ci.yml): every wgpu
device in the run is Vulkan on Mesa's CPU rasterizer, each test's output is shown, and the output
is checked here for authored skips and for the parity tests' Vulkan backend line.
Usage: ci-gpu-lavapipe.py COMMAND [ARGS...]
"""
import glob
import os
import re
import subprocess
import sys
import tempfile
def validate_log(lines):
vulkan = False
rejected = []
for line in lines:
vulkan |= 'GPU parity backend: Vulkan' in line
# Authored skips, not nextest's summary of ignored/filtered-out tests.
if re.search(r'\bskipping\b|\bno (?:GPU )?adapter\b', line):
rejected.append(line.rstrip())
if 'SKIP ' in line and not (
('SKIP gpu timing:' in line and 'is a software adapter' in line)
or 'SKIP the comparison: this GPU finishes' in line
or 'SKIP the sum: this refresh still fit one command buffer' in line
):
rejected.append(line.rstrip())
if not vulkan:
rejected.append('GPU parity tests did not report the Vulkan backend')
return rejected
def run(command, icds, out=sys.stdout):
"""Runs `command` on the Vulkan drivers in `icds`; returns its exit status, or 1 when it passed
but its output shows a skipped comparison."""
env = dict(os.environ, WGPU_BACKEND='vulkan', VK_ICD_FILENAMES=os.pathsep.join(icds))
# Stream output and keep it on disk, rather than buffering every successful test in memory.
with tempfile.TemporaryFile(mode='w+t') as log:
with subprocess.Popen(command, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
text=True) as process:
for line in process.stdout:
out.write(line)
log.write(line)
result = process.wait()
log.seek(0)
errors = validate_log(log)
for error in errors:
print(f'::error::{error}', file=sys.stderr)
return result if result else int(bool(errors))
def main(argv):
if not argv:
print(__doc__, file=sys.stderr)
return 2
icds = sorted(glob.glob('/usr/share/vulkan/icd.d/lvp_icd*.json'))
if not icds:
raise RuntimeError('Install mesa-vulkan-drivers and libvulkan1 before this check')
return run(argv, icds)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))