Files
photocraft/scripts/test-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

61 lines
2.7 KiB
Python

import importlib.util
import io
from pathlib import Path
import sys
import unittest
spec = importlib.util.spec_from_file_location('gpu_check', Path(__file__).with_name('ci-gpu-lavapipe.py'))
check = importlib.util.module_from_spec(spec)
spec.loader.exec_module(check)
class LogChecks(unittest.TestCase):
def test_requires_vulkan_evidence(self):
self.assertTrue(check.validate_log(['GPU parity backend: Gl']))
self.assertTrue(check.validate_log([]))
def test_success_and_nextest_summary(self):
self.assertFalse(check.validate_log(['GPU parity backend: Vulkan (llvmpipe, Cpu)',
'Summary 100 tests run: 100 passed, 3 skipped']))
def test_rejects_missing_comparisons(self):
for message in ['skipping GPU parity tests: no device', 'skipping: unsupported format',
'no GPU adapter', 'SKIP gpu timing: no adapter',
'SKIP gpu timing: no device with timestamp queries', 'SKIP unknown test']:
with self.subTest(message=message):
self.assertTrue(check.validate_log(['GPU parity backend: Vulkan', message]))
def test_allows_only_known_timing_exceptions(self):
self.assertFalse(check.validate_log(['GPU parity backend: Vulkan',
'SKIP gpu timing: llvmpipe is a software adapter, which cannot show a GPU/CPU split',
'SKIP the comparison: this GPU finishes a 6 MP composite in 1 ms against 2 ms of encoding',
'SKIP the sum: this refresh still fit one command buffer']))
class Wrapper(unittest.TestCase):
"""The gate's GPU shard runs xtask through `run`: its output is shown and checked."""
def status(self, script, icds=('/icd/lvp_icd.x86_64.json',)):
out = io.StringIO()
return check.run([sys.executable, '-c', script], list(icds), out), out.getvalue()
def test_runs_on_the_given_vulkan_driver_and_shows_the_output(self):
status, out = self.status(
"import os; print('GPU parity backend: Vulkan', os.environ['WGPU_BACKEND'], os.environ['VK_ICD_FILENAMES'])")
self.assertEqual(status, 0)
self.assertIn('GPU parity backend: Vulkan vulkan /icd/lvp_icd.x86_64.json', out)
def test_a_passing_run_with_a_skip_fails(self):
status, _ = self.status("print('GPU parity backend: Vulkan'); print('skipping GPU parity tests: no device')")
self.assertEqual(status, 1)
status, _ = self.status("print('no parity test ran')")
self.assertEqual(status, 1)
def test_a_failing_run_keeps_its_status(self):
status, _ = self.status("print('GPU parity backend: Vulkan'); raise SystemExit(100)")
self.assertEqual(status, 100)
if __name__ == '__main__':
unittest.main()