diff --git a/.github/workflows/build-qt-linux.yml b/.github/workflows/build-qt-linux.yml index 2a31109f2..edb936401 100644 --- a/.github/workflows/build-qt-linux.yml +++ b/.github/workflows/build-qt-linux.yml @@ -97,10 +97,11 @@ jobs: libwayland-client0 libwayland-egl1 libwayland-cursor0 libegl1 libgl1 \ patchelf file binutils - # Official Qt binaries. `qtshadertools` brings `qsb`; the committed .qsb - # files make it optional for the build (build.rs warns), but the - # re-bake keeps shaders honest against the pinned Qt. The arm64 host - # exists in aqt from 6.7 — the first aarch64 dispatch is the proof. + # Official Qt binaries — WITHOUT qtshadertools: with qsb on PATH build.rs + # re-bakes shaders by mtime and a fresh checkout is nondeterministic. + # The build ships the committed .qsb (build.rs warns and keeps them); + # shader health is judged by test-crates.yml's shader-gate. The arm64 + # host exists in aqt from 6.7 — the first aarch64 dispatch is the proof. - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: @@ -108,7 +109,6 @@ jobs: host: ${{ inputs.arch == 'aarch64' && 'linux_arm64' || 'linux' }} target: desktop arch: ${{ inputs.arch == 'aarch64' && 'linux_gcc_arm64' || 'linux_gcc_64' }} - modules: qtshadertools cache: true - name: Setup Rust (stable) diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index a45e0d6c5..98dba4932 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -112,6 +112,7 @@ jobs: exit 1 fi + # Without qtshadertools: the committed .qsb ship (see build-qt-linux.yml). - name: Install Qt ${{ env.QT_VERSION }} (universal) uses: jurplel/install-qt-action@v4 with: @@ -119,7 +120,6 @@ jobs: host: mac target: desktop arch: clang_64 - modules: qtshadertools cache: true - name: Setup Rust (stable) diff --git a/.github/workflows/test-crates.yml b/.github/workflows/test-crates.yml index c0ba84356..b1fd3d9fb 100644 --- a/.github/workflows/test-crates.yml +++ b/.github/workflows/test-crates.yml @@ -97,6 +97,26 @@ jobs: echo "::error::qbzd graph resolves Slint crates:"; echo "$hits"; exit 1 fi + # Every shader must bake with the pinned qsb. Separate job so qsb is never + # on PATH while cargo runs (see qt-gate). + shader-gate: + name: shader bake gate + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + - name: Install Qt ${{ env.QT_VERSION }} + shader tools + uses: jurplel/install-qt-action@v4 + with: + version: ${{ env.QT_VERSION }} + host: linux + target: desktop + arch: linux_gcc_64 + modules: qtshadertools + cache: true + - name: Bake every shader to a temp dir + run: scripts/qml-audits/shader_bake_gate.sh "$QT_ROOT_DIR/bin/qsb" + qt-gate: name: qt gate (audits, tests, offscreen boot) runs-on: ubuntu-24.04 @@ -105,17 +125,6 @@ jobs: - name: Checkout uses: actions/checkout@v7 - # Cheapest gates first. The audits are ~1 s and catch exactly the class - # of mistake nothing else in CI can see. - - name: QML audits - run: | - set -euo pipefail - for a in qml_resolution_audit qml_singleton_xref qml_eager_tab_audit qml_module_registration_audit qml_icon_bake_audit; do - echo "::group::$a" - python3 "scripts/qml-audits/$a.py" "$PWD/crates/qbz-qt" - echo "::endgroup::" - done - - name: Install system dependencies run: | sudo apt-get update @@ -124,6 +133,9 @@ jobs: libasound2-dev libjack-jackd2-dev libdbus-1-dev libssl-dev \ libgl1-mesa-dev libegl1-mesa-dev libxkbcommon-dev + # No qtshadertools here ON PURPOSE: with qsb on PATH build.rs re-bakes + # shaders by mtime, which makes a fresh checkout nondeterministic. The + # build ships the committed .qsb; shader health is the shader-gate job. - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: @@ -131,9 +143,23 @@ jobs: host: linux target: desktop arch: linux_gcc_64 - modules: qtshadertools cache: true + # The audits need Qt's own plugins.qmltypes to resolve QtQuick types — + # hence after the Qt install, pointed at it. ~1 s, and the class of + # mistake nothing else in CI can see (a missing component, a bridge + # member that does not exist). + - name: QML audits + env: + QBZ_QT_QML_DIR: ${{ env.QT_ROOT_DIR }}/qml + run: | + set -euo pipefail + for a in qml_resolution_audit qml_singleton_xref qml_eager_tab_audit qml_module_registration_audit qml_icon_bake_audit; do + echo "::group::$a" + python3 "scripts/qml-audits/$a.py" "$PWD/crates/qbz-qt" + echo "::endgroup::" + done + - name: Setup Rust uses: dtolnay/rust-toolchain@stable diff --git a/scripts/qml-audits/qml_resolution_audit.py b/scripts/qml-audits/qml_resolution_audit.py index 1c4e79e66..546c8c4e1 100644 --- a/scripts/qml-audits/qml_resolution_audit.py +++ b/scripts/qml-audits/qml_resolution_audit.py @@ -12,6 +12,33 @@ import pathlib import re import sys +def qt_qml_dir() -> pathlib.Path: + """Where Qt's own plugins.qmltypes live. QBZ_QT_QML_DIR wins (CI sets it to + the aqt install: $QT_ROOT_DIR/qml); then the distro layouts. Failing loudly + beats the alternative: with no qmltypes every Rectangle reads as unresolved + and the audit drowns the real findings in noise.""" + import os + candidates = [] + if os.environ.get("QBZ_QT_QML_DIR"): + # Explicit means explicit: a wrong value must not fall through to + # whatever Qt the box happens to have. + c = pathlib.Path(os.environ["QBZ_QT_QML_DIR"]) + if c.is_dir() and any(c.rglob("plugins.qmltypes")): + return c + sys.exit(f"qml_resolution_audit: QBZ_QT_QML_DIR={c} has no plugins.qmltypes") + if os.environ.get("QT_ROOT_DIR"): + candidates.append(pathlib.Path(os.environ["QT_ROOT_DIR"]) / "qml") + candidates += [pathlib.Path(x) for x in ( + "/usr/lib64/qt6/qml", "/usr/lib/x86_64-linux-gnu/qt6/qml", + "/usr/lib/aarch64-linux-gnu/qt6/qml", "/usr/lib/qt6/qml", + "/opt/homebrew/share/qt/qml", "/usr/local/share/qt/qml")] + for c in candidates: + if c.is_dir() and any(c.rglob("plugins.qmltypes")): + return c + sys.exit("qml_resolution_audit: no Qt qml dir with plugins.qmltypes found — " + "set QBZ_QT_QML_DIR (tried: " + ", ".join(str(c) for c in candidates) + ")") + + ROOT = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else "/home/blitzkriegfc/Personal/qbz/qbz-worktrees/qbz-qt/crates/qbz-qt") QML = ROOT / "qml" @@ -33,7 +60,7 @@ def strip(src: str) -> str: def qt_builtins() -> set: names = set() - for p in pathlib.Path("/usr/lib64/qt6/qml").rglob("*.qmltypes"): + for p in qt_qml_dir().rglob("*.qmltypes"): try: for m in re.finditer(r'"(?:[A-Za-z0-9_.]+)/([A-Z]\w+) [\d.]+"', p.read_text(errors="ignore")): names.add(m.group(1)) diff --git a/scripts/qml-audits/shader_bake_gate.sh b/scripts/qml-audits/shader_bake_gate.sh new file mode 100755 index 000000000..44bca8a82 --- /dev/null +++ b/scripts/qml-audits/shader_bake_gate.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# shader_bake_gate.sh — prove every shader under crates/qbz-qt/qml/assets/shaders +# still BAKES with the pinned qsb, without touching the committed .qsb files. +# +# Why this exists (2026-08-26): build.rs re-bakes a shader only when its source +# is newer than its .qsb (mtime), so a shader edit whose bake FAILS is invisible +# on a box where the .qsb happens to be newer — and a fresh checkout (CI) may +# or may not re-bake depending on checkout timing. plasma.frag shipped exactly +# that way: uint literals that GLSL 120 cannot express, a stale committed .qsb, +# and a build that broke only in CI. This gate bakes every shader to a temp dir +# with the SAME target lists build.rs uses (read from build.rs so they cannot +# drift) and fails if any one of them does not bake. +# +# The release/test builds themselves run WITHOUT qsb on PATH so they ship the +# committed .qsb deterministically; this gate is where shader health is judged. +# +# Usage: scripts/qml-audits/shader_bake_gate.sh [path/to/qsb] +set -euo pipefail +cd "$(dirname "$0")/../.." +CRATE=crates/qbz-qt +QSB="${1:-${QSB:-$(command -v qsb || true)}}" +[[ -x "$QSB" ]] || { echo "shader_bake_gate: no qsb (pass a path or put it on PATH)"; exit 2; } +glsl_all="$(grep -oE 'const SHADER_GLSL: &str = "[^"]+"' $CRATE/build.rs | sed 's/.*= "//; s/"$//')" +glsl_noes="$(grep -oE 'const SHADER_GLSL_NO_ES100: &str = "[^"]+"' $CRATE/build.rs | sed 's/.*= "//; s/"$//')" +hlsl="$(grep -oE 'const SHADER_HLSL: &str = "[^"]+"' $CRATE/build.rs | sed 's/.*= "//; s/"$//')" +msl="$(grep -oE 'const SHADER_MSL: &str = "[^"]+"' $CRATE/build.rs | sed 's/.*= "//; s/"$//')" +marker="$(grep -oE 'const NO_ES100_MARKER: &str = "[^"]+"' $CRATE/build.rs | sed 's/.*= "//; s/"$//')" +[[ -n "$glsl_all" && -n "$glsl_noes" && -n "$hlsl" && -n "$msl" && -n "$marker" ]] || { echo "shader_bake_gate: could not read the target lists from $CRATE/build.rs"; exit 2; } +tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT +fail=0; n=0 +for src in $CRATE/qml/assets/shaders/*.frag $CRATE/qml/assets/shaders/*.vert; do + n=$((n+1)) + if grep -q "$marker" "$src"; then glsl="$glsl_noes"; else glsl="$glsl_all"; fi + if ! "$QSB" --glsl "$glsl" --hlsl "$hlsl" --msl "$msl" -b -o "$tmp/$(basename "$src").qsb" "$src" > "$tmp/err" 2>&1; then + echo "FAIL $src [glsl: $glsl]"; sed 's/^/ /' "$tmp/err" | head -3; fail=$((fail+1)) + fi +done +echo "shader_bake_gate: $n shaders, $fail failed ($("$QSB" --version 2>/dev/null | head -1))" +exit $(( fail > 0 ))