From 129c840089a1e3536252b733fc734f16beb7024b Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Sun, 29 Nov 2026 19:17:38 -0500 Subject: [PATCH 1/3] ci: fix runtime/windows timeout, remove redundant CI legs, and harden caches --- .github/workflows/ci.yml | 196 ++++++-------------- .github/workflows/jactionlint.yml | 6 +- .github/workflows/launcher.yml | 18 +- .github/workflows/runtime.yml | 75 ++++++-- .github/workflows/xma2-decoder.yml | 20 ++ docs/linux.md | 4 +- docs/testing.md | 10 +- tests/semantic/test_spirv_tools_required.py | 4 +- tests/test_ci_registration.py | 24 +-- tests/test_feature_scan.py | 2 +- tests/test_vs_input_survey.py | 2 +- 11 files changed, 171 insertions(+), 190 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 641b8476a6..c04a3f5466 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,13 @@ name: CI on: push: branches: [main] + # Docs-only merges already ran all documentation tests on their pull request and are excluded here so they + # neither waste runner slots nor coalesce/cancel a pending code push in ci-push-refs/heads/main. + paths-ignore: + - "README.md" + - "CONTRIBUTING.md" + - "AGENTS.md" + - "docs/**/*.md" pull_request: workflow_dispatch: # One independent default-branch snapshot daily, not a full run for every queued merge. @@ -34,21 +41,26 @@ jobs: persist-credentials: false - name: Check whether only documentation changed id: paths - shell: pwsh + shell: bash run: | # A pull_request checkout is the test merge; its first parent is the PR base. # Treat missing history, an empty diff, and renames out of code conservatively. - $PSNativeCommandUseErrorActionPreference = $false - $docsOnly = $false - git diff --quiet "$env:GITHUB_SHA^1" "$env:GITHUB_SHA" -- - if ($LASTEXITCODE -eq 1) { - git diff --quiet --no-renames "$env:GITHUB_SHA^1" "$env:GITHUB_SHA" -- . ` - ':(exclude,top)README.md' ':(exclude,top)CONTRIBUTING.md' ` - ':(exclude,top)AGENTS.md' ':(exclude,top,glob)docs/**/*.md' - $docsOnly = $LASTEXITCODE -eq 0 - } - "docs-only=$($docsOnly.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT - exit 0 # GitHub's pwsh wrapper would otherwise forward git diff's status. + docs_only=false + base="${GITHUB_SHA}^1" + if git rev-parse --verify -q "${base}^{commit}" >/dev/null 2>&1; then + diff_rc=0 + git diff --quiet "$base" "$GITHUB_SHA" -- || diff_rc=$? + if [ "$diff_rc" -eq 1 ]; then + code_rc=0 + git diff --quiet --no-renames "$base" "$GITHUB_SHA" -- . \ + ':(exclude,top)README.md' ':(exclude,top)CONTRIBUTING.md' \ + ':(exclude,top)AGENTS.md' ':(exclude,top,glob)docs/**/*.md' || code_rc=$? + if [ "$code_rc" -eq 0 ]; then + docs_only=true + fi + fi + fi + echo "docs-only=$docs_only" >> "$GITHUB_OUTPUT" # A docs-only diff still needs the tests that read those documents, because `check` is skipped for it: every # tests/test_docs_*.py (links, the design.md contract rows, list items, the repository paths a document # names) and the i18n index, which checks docs/i18n/README.md. All are standard library only and read only @@ -96,14 +108,14 @@ jobs: - name: Tests (standard library only, no game data) shell: bash run: | - # Keep the pytest selection predicate, but run the selected files two at a time. + # Keep the pytest selection predicate, but run the selected files four at a time. # The runner reports every failure instead of stopping at the first one. while IFS= read -r t; do if grep -Eq "$PYTEST_FILE_MARKERS" "$t" || ! grep -q '__main__' "$t"; then continue fi printf '%s\n' "$t" - done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) | python -I scripts/run_standalone_tests.py -j 2 + done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) | python -I scripts/run_standalone_tests.py -j 4 - name: Build rpf9dump run: dotnet build tools/rpf9dump/rpf9dump.csproj -c Release - name: Test TTPF export retry @@ -127,7 +139,11 @@ jobs: python -I tests/test_ttpf_assets.py - name: Test rpf9dump diagnostics run: dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release - translator-tests: + + # Consolidated Linux job: viewer streaming tests, pytest translator/numpy tests, and the Linux standard-library + # test loop (with SPIRV-Tools, LLVM 21, and numpy installed so spirv-val checks, numpy paths, and POSIX-only + # tests that skip on Windows run here). + linux-python-and-viewer: needs: change-scope if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }} runs-on: ubuntu-24.04 @@ -141,7 +157,12 @@ jobs: python-version: "3.12" cache: "pip" cache-dependency-path: tests/requirements.txt - - name: Install llvm-mc (LLVM 21) and spirv-tools + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: "24" + - name: Viewer chunk streaming (synthetic, no browser or game data) + run: node --test tests/test_*.cjs + - name: Install llvm-mc (LLVM 21), SPIRV-Tools and Python test dependencies shell: bash run: | # The signing key is checked against apt.llvm.org's published fingerprint before apt trusts it. @@ -171,131 +192,21 @@ jobs: fi done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) python -m pytest "${pytest_files[@]}" -q - semantic-tests: - needs: change-scope - if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }} - runs-on: ${{ matrix.os }} - # The Windows leg does not fit in 10 minutes. On windows-latest, 14 of 23 runs on 24 November 2026 were cancelled - # at 10, each time with test_mutations.py the only file still running (250-381 s there, 25-42 s on Linux), and the - # 9 that finished spent 374-577 s in the test step. The Linux leg, the one pull requests run, takes 3-5 minutes. - timeout-minutes: ${{ matrix.os == 'windows-latest' && 20 || 10 }} - strategy: - matrix: - # Pull requests run the Linux leg only: in 914 sampled pull request runs the Windows leg never failed while the - # Linux leg passed, and it took about 14% of the account's runner time. Pushes to main and workflow_dispatch - # run both legs. - os: ${{ fromJSON(github.event_name == 'pull_request' && '["ubuntu-latest"]' || '["windows-latest", "ubuntu-latest"]') }} - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 - with: - python-version: "3.12" - # Some semantic tests assemble and validate the translator's output with spirv-as / spirv-val and skip without - # them (test_fma_khr, test_bary_fallback, test_image_coherent...). The runner images have neither, so a skip - # here reads as a pass. The Linux leg installs SPIRV-Tools and LEONIDA_REQUIRE_SPIRV_TOOLS=1 makes - # tests/semantic/test_spirv_tools_required.py fail when they are missing, so those tests cannot go quiet again. - # The Windows leg has no SPIRV-Tools and still skips them. - - name: Install SPIRV-Tools - if: runner.os == 'Linux' - shell: bash - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends spirv-tools - spirv-as --version - spirv-val --version - - name: Translator semantic tests - env: - LEONIDA_REQUIRE_SPIRV_TOOLS: ${{ runner.os == 'Linux' && '1' || '0' }} - run: python -I scripts/run_semantic_tests.py tests/semantic -v - - # The Python suites on an Apple Silicon Mac: the standard-library loop of the check job, the translator semantic - # tests and the pytest files of the translator-tests job, with Homebrew's llvm-mc and SPIRV-Tools. macos-26, not - # macos-15: the Homebrew bottles cover Sequoia and later, but the runtime needs Xcode 26's libc++ (runtime.yml). - macos-python: - needs: change-scope - if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }} - runs-on: macos-26 - timeout-minutes: 20 - env: - HOMEBREW_NO_AUTO_UPDATE: "1" - HOMEBREW_NO_INSTALL_CLEANUP: "1" - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 - with: - python-version: "3.12" - cache: "pip" - cache-dependency-path: tests/requirements.txt - - name: Python tools compile - run: python -m compileall -q make_game.py tools tests - - name: make_game.py help - run: python -I make_game.py --help - # Before anything is installed, as in the check job, so these files stay standard library only. The semantic - # suite runs alongside the loop, on another of the runner's three cores; together they take about 6 minutes. - - name: Translator semantic tests and tests (standard library only, no game data) + - name: Tests (standard library only, Linux) shell: bash run: | - python -m unittest discover -s tests/semantic > "$RUNNER_TEMP/semantic.log" 2>&1 & - semantic=$! while IFS= read -r t; do if grep -Eq "$PYTEST_FILE_MARKERS" "$t" || ! grep -q '__main__' "$t"; then continue fi - echo "== $t" - python -I "$t" || exit 1 - done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) - status=0 - wait "$semantic" || status=$? - echo "== tests/semantic" - cat "$RUNNER_TEMP/semantic.log" - exit "$status" - - name: Install llvm-mc and SPIRV-Tools - run: | - brew install llvm spirv-tools - pip install -r tests/requirements.txt - LLVM_MC="$(brew --prefix llvm)/bin/llvm-mc" # keg-only: not on PATH - echo "LLVM_MC=$LLVM_MC" >> "$GITHUB_ENV" - "$LLVM_MC" --version | grep -E 'LLVM version|amdgcn' - - name: Translator tests (pytest) - shell: bash - run: | - pytest_files=() - while IFS= read -r t; do - if grep -Eq "$PYTEST_FILE_MARKERS" "$t" || ! grep -q '__main__' "$t"; then - pytest_files+=("$t") - elif [[ "$t" == tests/test_tex_headers.py ]]; then - pytest_files+=("$t::TestTextureDescriptorParsing::test_stdlib_qword_scanner_edge_cases_and_parity") - fi - done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) - python -m pytest "${pytest_files[@]}" -q + printf '%s\n' "$t" + done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) | python -I scripts/run_standalone_tests.py -j 4 - viewer-tests: + semantic-tests: needs: change-scope if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }} runs-on: ubuntu-latest timeout-minutes: 10 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: "24" - - name: Viewer chunk streaming (synthetic, no browser or game data) - run: node --test tests/test_*.cjs - - # The check job runs the standard-library loop on Windows, which has no SPIRV-Tools or numpy: the spirv-val checks - # (test_split_big_switch, test_image_load_typed...), the numpy paths and the POSIX-only tests skip there. This job - # runs the same loop on Linux with them installed, so those tests run somewhere. - stdlib-tests-linux: - needs: change-scope - if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }} - runs-on: ubuntu-24.04 - timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -303,21 +214,18 @@ jobs: - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: python-version: "3.12" - cache: "pip" - cache-dependency-path: tests/requirements.txt - - name: Install SPIRV-Tools and numpy + # Some semantic tests assemble and validate the translator's output with spirv-as / spirv-val and skip without + # them (test_fma_khr, test_bary_fallback, test_image_coherent...). The runner image has neither, so a skip + # here reads as a pass. Installing SPIRV-Tools and setting LEONIDA_REQUIRE_SPIRV_TOOLS=1 makes + # tests/semantic/test_spirv_tools_required.py fail when they are missing, so those tests cannot go quiet again. + - name: Install SPIRV-Tools shell: bash run: | sudo apt-get update sudo apt-get install -y --no-install-recommends spirv-tools - pip install -r tests/requirements.txt - - name: Tests (standard library only, Linux) - shell: bash - run: | - while IFS= read -r t; do - if grep -Eq "$PYTEST_FILE_MARKERS" "$t" || ! grep -q '__main__' "$t"; then - continue - fi - echo "== $t" - python -I "$t" || exit 1 - done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) + spirv-as --version + spirv-val --version + - name: Translator semantic tests + env: + LEONIDA_REQUIRE_SPIRV_TOOLS: "1" + run: python -I scripts/run_semantic_tests.py tests/semantic -v diff --git a/.github/workflows/jactionlint.yml b/.github/workflows/jactionlint.yml index 0e0ed1e5ce..5445c2eb2e 100644 --- a/.github/workflows/jactionlint.yml +++ b/.github/workflows/jactionlint.yml @@ -25,8 +25,8 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - # `correctness` checks workflow syntax, expressions, shellcheck, and dependabot.yml; - # switch to `default` once all workflows declare timeouts and concurrency. + # `default` checks workflow syntax, expressions, shellcheck, dependabot.yml, + # pinned actions, permissions, timeouts, and concurrency. - uses: jdx/jactionlint@72c00452809bcca05b8bc12acdcf15dd7a9c1c5e # v2.6.0 with: - profile: correctness + profile: default diff --git a/.github/workflows/launcher.yml b/.github/workflows/launcher.yml index 255a7c72a6..d8c5840804 100644 --- a/.github/workflows/launcher.yml +++ b/.github/workflows/launcher.yml @@ -36,7 +36,7 @@ jobs: # Windows first, as the project is; Linux for Wayland and X11 users and the same tests on another system. os: [windows-latest, ubuntu-24.04] runs-on: ${{ matrix.os }} - timeout-minutes: 40 + timeout-minutes: 20 defaults: run: working-directory: launcher/native @@ -47,11 +47,27 @@ jobs: persist-credentials: false # The runners' own rustup, no third-party action: the stable toolchain with its formatter and linter. - name: Rust toolchain + id: rust-toolchain run: | rustup toolchain install stable --profile minimal --component clippy,rustfmt rustup default stable + rustc_hash=$(rustc -vV | tr -d '\r' | awk '/^commit-hash: /{print $2}') + test -n "$rustc_hash" + echo "rustc-hash=$rustc_hash" >> "$GITHUB_OUTPUT" rustc --version + - name: Cache Cargo dependencies and build + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + launcher/native/target + key: launcher-cargo-${{ runner.os }}-${{ steps.rust-toolchain.outputs.rustc-hash }}-${{ hashFiles('launcher/native/Cargo.lock') }} + restore-keys: | + launcher-cargo-${{ runner.os }}-${{ steps.rust-toolchain.outputs.rustc-hash }}- + launcher-cargo-${{ runner.os }}- - name: Format + if: matrix.os == 'ubuntu-24.04' run: cargo fmt --check - name: Lints run: cargo clippy --locked --all-targets -- -D warnings diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index e355ca32be..9d814c51e3 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -132,9 +132,10 @@ concurrency: jobs: windows: runs-on: windows-latest - # A build with a cold sccache took 18.3 min (main, 24 Nov), which left a 20-minute job under 2 min for the - # whole ctest run. The ctest step bounds each test on its own, so a hung test no longer needs this to stop it. - timeout-minutes: 35 + # Cold sccache builds can exceed 35 min when repo cache churn evicts objects. Release (without /Z7) shrinks + # object size, Cargo caching avoids rebuilding the Rust decoders, and 50 min gives headroom for cold builds. + # The ctest step bounds each test on its own, so a hung test no longer needs this to stop it. + timeout-minutes: 50 outputs: wine-artifact: ${{ steps.upload-wine-artifact.outcome }} env: @@ -237,6 +238,26 @@ jobs: Add-Content -LiteralPath $env:GITHUB_ENV -Value $envLines -Encoding utf8 } - uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 + - name: Identify Rust toolchain + id: rust-toolchain + shell: bash + run: | + rustc_hash=$(rustc -vV | tr -d '\r' | awk '/^commit-hash: /{print $2}') + test -n "$rustc_hash" + echo "rustc-hash=$rustc_hash" >> "$GITHUB_OUTPUT" + rustc --version + - name: Cache Cargo dependencies and decoder targets + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + runtime/build/xma_decoder + runtime/build/opus_decoder + key: runtime-windows-cargo-${{ steps.rust-toolchain.outputs.rustc-hash }}-${{ hashFiles('runtime/xma_decoder/Cargo.lock', 'runtime/opus_decoder/Cargo.lock') }} + restore-keys: | + runtime-windows-cargo-${{ steps.rust-toolchain.outputs.rustc-hash }}- + runtime-windows-cargo- - name: Cache Vulkan headers id: vulkan-headers-cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 @@ -274,13 +295,11 @@ jobs: VULKAN_SDK: ${{ github.workspace }}/.vulkan-headers run: >- cmake -S runtime -B runtime/build -G Ninja - -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DCMAKE_BUILD_TYPE=Release -DLEONIDA_D3D12_SHIM_TESTS=ON -DLEONIDA_REQUIRE_VULKAN=ON -DLEONIDA_REQUIRE_XMA2_DECODER=ON -DCMAKE_CXX_COMPILER_LAUNCHER=sccache - -DCMAKE_POLICY_DEFAULT_CMP0141=NEW - -DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded - name: Build run: cmake --build runtime/build - name: Verify the descriptor test shaders @@ -326,15 +345,15 @@ jobs: # --timeout: a test without a TIMEOUT of its own fails after 5 min instead of the CTest default of 25, which # is longer than the job. The slowest on Linux and macOS (xdxr_build_check) takes 50 and 106 s. - name: CPU runtime tests - run: ctest --test-dir runtime/build --output-on-failure --timeout 300 + run: ctest --test-dir runtime/build --output-on-failure --timeout 300 --parallel 4 # Runs the Windows build's tests under Wine, so a change that breaks the loader on Linux (through Wine or Proton) # shows up. The required ones are the loader and the stand-in game run end to end; the table in the job summary # shows the rest. # Two Wines: Ubuntu's own (9.0) and WineHQ's current stable, which is closer to what Proton users run. # Not on pull requests: in 188 sampled pull request runs these two jobs never failed when the Windows job had passed, - # yet they took about a quarter of the account's 20 concurrent runner slots. They run on every push to main that - # touches these paths, and on demand from the Actions tab (workflow_dispatch). Pull requests still build and test the + # yet they took about a quarter of the account's 20 concurrent runner slots. Pushes to main run winehq-stable only; + # the daily schedule and workflow_dispatch run both ubuntu and winehq-stable. Pull requests still build and test the # Windows runtime natively and upload runtime-windows for testers. wine: needs: windows @@ -345,8 +364,7 @@ jobs: strategy: fail-fast: false matrix: - wine: [ubuntu, winehq-stable] - name: wine (${{ matrix.wine }}) + wine: ${{ fromJSON(github.event_name == 'push' && '["winehq-stable"]' || '["ubuntu", "winehq-stable"]') }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -400,7 +418,7 @@ jobs: run: >- xvfb-run -a cmake -DRUNNER=wine -DLOADER="$GITHUB_WORKSPACE/runtime/build/gta6rt.exe" - -DGUEST="$GITHUB_WORKSPACE/runtime/build/fixtures/game/RelWithDebInfo/tiny_async.exe" + -DGUEST="$GITHUB_WORKSPACE/runtime/build/fixtures/game/Release/tiny_async.exe" -P runtime/test/check_loaded_async.cmake # Also runs the hand-written GPU tests (runtime/test/shaders) on Mesa's llvmpipe, a software Vulkan driver, so a @@ -430,17 +448,31 @@ jobs: path: .vulkan-headers sparse-checkout: include persist-credentials: false - - name: Install llvmpipe, llvm-mc and SPIRV-Tools + - name: Install llvmpipe, llvm-mc (LLVM 21) and SPIRV-Tools + shell: bash run: | pkgs=(libvulkan-dev mesa-vulkan-drivers vulkan-tools spirv-tools) command -v cmake >/dev/null || pkgs+=(cmake) command -v ninja >/dev/null || pkgs+=(ninja-build) command -v g++ >/dev/null || pkgs+=(g++) - [ -x /usr/lib/llvm-19/bin/llvm-mc ] || pkgs+=(llvm-19) + if [ ! -x /usr/lib/llvm-21/bin/llvm-mc ]; then + # The signing key is checked against apt.llvm.org's published fingerprint before apt trusts it. + key=$(mktemp) + curl -fsSL -o "$key" https://apt.llvm.org/llvm-snapshot.gpg.key + python3 -I scripts/check_apt_key.py "$key" 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421 + sudo gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg "$key" + echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" | sudo tee /etc/apt/sources.list.d/llvm-21.list > /dev/null + pkgs+=(llvm-21) + fi sudo apt-get update sudo apt-get install -y --no-install-recommends "${pkgs[@]}" - name: Sanity check llvm-mc amdgcn target - run: /usr/lib/llvm-19/bin/llvm-mc --version | grep -q 'amdgcn' + shell: bash + run: | + version_out=$(/usr/lib/llvm-21/bin/llvm-mc --version) + printf '%s\n' "$version_out" + grep -q 'LLVM version 21\.' <<< "$version_out" + grep -q 'amdgcn' <<< "$version_out" - name: Configure env: VULKAN_SDK: ${{ github.workspace }}/.vulkan-headers @@ -473,7 +505,7 @@ jobs: - name: GPU tests on llvmpipe run: | vulkaninfo --summary | grep -E 'deviceName.*llvmpipe' # fails the step if llvmpipe isn't there - python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-19/bin/llvm-mc --work "$RUNNER_TEMP/gpu-native" + python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-21/bin/llvm-mc --work "$RUNNER_TEMP/gpu-native" - name: Pipeline checker exit status on llvmpipe shell: bash run: | @@ -513,7 +545,7 @@ jobs: # left out: llvmpipe's LLVM backend aborts compiling them ("Cannot emit physreg copy instruction"). env: LEONIDA_W64_EMULATE: "1" - run: python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-19/bin/llvm-mc --work "$RUNNER_TEMP/gpu-w64" --filter cs_ + run: python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-21/bin/llvm-mc --work "$RUNNER_TEMP/gpu-w64" --filter cs_ - name: GPU tests on llvmpipe with the barycentric fallback # llvmpipe has no VK_KHR_fragment_shader_barycentric, so the native run skips the pixel shaders that read raw # barycentrics. Under --bary-fallback they read them from an input a pass-through geometry shader feeds @@ -524,7 +556,7 @@ jobs: LEONIDA_BARY_FALLBACK: "1" run: | log="$RUNNER_TEMP/gpu-bary.log" - python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-19/bin/llvm-mc --work "$RUNNER_TEMP/gpu-bary" | tee "$log" + python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-21/bin/llvm-mc --work "$RUNNER_TEMP/gpu-bary" | tee "$log" names=$(sed -n 's/^bary fallback GS: \(.*\)\.bary_gs\.spv$/\1/p' "$log") if [ -z "$names" ]; then echo "::error::no barycentric fallback geometry shader was built" @@ -541,7 +573,10 @@ jobs: # hosted runner is a VM whose Metal device is "Apple Paravirtual device" (MTLGPUFamilyMac2, not Apple7), so # Mesa's KosmicKrisp finds no device there; MoltenVK runs, with 32-wide subgroups. macos-26, not macos-15: Xcode # 16's libc++ has no floating-point std::from_chars (vk_pipeline_check.cpp). + # Not on pull requests: runs on pushes to main, the daily schedule, and workflow_dispatch (linux-gpu-tools covers + # GPU shaders on every pull request). macos: + if: github.event_name != 'pull_request' runs-on: macos-26 timeout-minutes: 20 env: @@ -582,8 +617,8 @@ jobs: - name: Runtime tests on MoltenVK shell: bash env: - # vk_overlapping_occlusion: since #2100 (D3D-252), https://github.com/ItsNotRexed/Leonida/issues/3796#issuecomment-7086691314 - EXPECTED_FAILURES: vk_overlapping_occlusion + # Empty: every MoltenVK runtime test passes or skips. Add a test name with its tracking PR/issue if needed. + EXPECTED_FAILURES: "" run: | set +e ctest --test-dir runtime/build --output-on-failure -j "$(sysctl -n hw.ncpu)" 2>&1 | tee "$RUNNER_TEMP/ctest.log" diff --git a/.github/workflows/xma2-decoder.yml b/.github/workflows/xma2-decoder.yml index 2cb1d5cd91..d7549a0f49 100644 --- a/.github/workflows/xma2-decoder.yml +++ b/.github/workflows/xma2-decoder.yml @@ -12,6 +12,7 @@ on: - "runtime/xma_decoder/**" - "third_party/xma/**" - ".github/workflows/xma2-decoder.yml" + workflow_dispatch: permissions: contents: read @@ -30,6 +31,25 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: Identify Rust toolchain + id: rust-toolchain + shell: bash + run: | + rustc_hash=$(rustc -vV | tr -d '\r' | awk '/^commit-hash: /{print $2}') + test -n "$rustc_hash" + echo "rustc-hash=$rustc_hash" >> "$GITHUB_OUTPUT" + rustc --version + - name: Cache Cargo dependencies and build + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ${{ runner.temp }}/leonida-xma2-target + key: xma2-decoder-cargo-${{ runner.os }}-${{ steps.rust-toolchain.outputs.rustc-hash }}-${{ hashFiles('runtime/xma_decoder/Cargo.lock') }} + restore-keys: | + xma2-decoder-cargo-${{ runner.os }}-${{ steps.rust-toolchain.outputs.rustc-hash }}- + xma2-decoder-cargo-${{ runner.os }}- - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - name: Run synthetic Rust FFI tests shell: pwsh diff --git a/docs/linux.md b/docs/linux.md index 3bc8c15508..b6be525684 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -11,8 +11,8 @@ names; the build lists anything it can't find before it starts. | Piece | On Linux | How it is checked | |---|---|---| -| `make_game.py`: check, shaders, assets, pipelines | Native | CI (`stdlib-tests-linux`, `translator-tests`, `semantic-tests`) | -| `Build.sh`, `Mods.sh` | Native (`/bin/sh`) | `tests/test_shell_launchers.py`, in the standard-library loop of `stdlib-tests-linux` | +| `make_game.py`: check, shaders, assets, pipelines | Native | CI (`linux-python-and-viewer`, `semantic-tests`) | +| `Build.sh`, `Mods.sh` | Native (`/bin/sh`) | `tests/test_shell_launchers.py`, in the standard-library loop of `linux-python-and-viewer` | | Shader translator, its tests and the GPU test tools (`vk_harness`, `vk_pipeline_check`, ...) | Native, GCC or Clang | CI (`linux-gpu-tools`: GCC, tests on llvmpipe); Clang builds them too, but no CI job uses it yet | | `rpf9dump` (asset export) | Native, .NET 8 or newer | CI builds it on Windows only (the `check` job) | | `gta6rt`, its shims and their tests | Windows program, under Wine or Proton | Cross-built with clang-cl and xwin; CI runs the Windows build under Wine on pushes to `main` | diff --git a/docs/testing.md b/docs/testing.md index ec95d82440..e84313891b 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -701,13 +701,13 @@ for every pull request that touches the runtime, the scripts or a tool the jobs lists them), and you can do the same on Linux without a GPU: ```sh -sudo apt-get install -y libvulkan-dev mesa-vulkan-drivers vulkan-tools spirv-tools llvm-19 +sudo apt-get install -y libvulkan-dev mesa-vulkan-drivers vulkan-tools spirv-tools llvm-21 cmake -S runtime -B runtime/build/linux && cmake --build runtime/build/linux --parallel -python -I scripts/run_gpu_tests.py --build runtime/build/linux --llvm-mc /usr/lib/llvm-19/bin/llvm-mc +python -I scripts/run_gpu_tests.py --build runtime/build/linux --llvm-mc /usr/lib/llvm-21/bin/llvm-mc LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux \ - --llvm-mc /usr/lib/llvm-19/bin/llvm-mc --filter cs_ + --llvm-mc /usr/lib/llvm-21/bin/llvm-mc --filter cs_ LEONIDA_BARY_FALLBACK=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux \ - --llvm-mc /usr/lib/llvm-19/bin/llvm-mc + --llvm-mc /usr/lib/llvm-21/bin/llvm-mc ``` With Mesa 25.2 (llvmpipe, LLVM 20) the first run passes 52 of 88 and skips 36, the second passes 37 of 39 and @@ -736,7 +736,7 @@ differences. ## Macs in CI The `macos` job in `.github/workflows/runtime.yml` builds the runtime on GitHub's `macos-26` arm64 runner and runs -`ctest` and `run_gpu_tests.py` on MoltenVK; `macos-python` in `ci.yml` runs the Python suites. The runner is a VM +`ctest` and `run_gpu_tests.py` on MoltenVK on pushes to `main`, the daily schedule, and `workflow_dispatch`. The runner is a VM whose Metal device is "Apple Paravirtual device" (Metal family Mac2, not Apple7): MoltenVK runs on it with 32-wide subgroups, so the wave64 and "32 lanes on request" tests skip there (about 75 of 190 in November 2026), and Mesa's KosmicKrisp finds no device. `macos-15` can't build the runtime: Xcode 16's libc++ has no floating-point diff --git a/tests/semantic/test_spirv_tools_required.py b/tests/semantic/test_spirv_tools_required.py index 2286aee177..2ddad2b204 100644 --- a/tests/semantic/test_spirv_tools_required.py +++ b/tests/semantic/test_spirv_tools_required.py @@ -3,8 +3,8 @@ Several semantic tests assemble and validate the translator's output and skip when `spirv-as` / `spirv-val` are not on PATH: test_fma_khr, test_bary_fallback, test_image_coherent and others. A GitHub runner has neither tool, so without an install step those tests report "skipped" and the job stays green. The `semantic-tests` job in -.github/workflows/ci.yml installs SPIRV-Tools on its Linux leg and sets LEONIDA_REQUIRE_SPIRV_TOOLS=1 there; this test -turns a missing or broken tool into a red job. Without the variable (a developer's machine, the Windows leg) it skips. +.github/workflows/ci.yml installs SPIRV-Tools and sets LEONIDA_REQUIRE_SPIRV_TOOLS=1; this test +turns a missing or broken tool into a red job. Without the variable (a developer's machine) it skips. tests/test_ci_registration.py checks that ci.yml keeps doing both. """ import os diff --git a/tests/test_ci_registration.py b/tests/test_ci_registration.py index c2bf4703a3..5eed7dabc2 100644 --- a/tests/test_ci_registration.py +++ b/tests/test_ci_registration.py @@ -2,9 +2,10 @@ python -I tests/test_ci_registration.py -``.github/workflows/ci.yml`` splits ``tests/test_*.py`` between two jobs with a single predicate -(``PYTEST_FILE_MARKERS``, or no ``__main__``): the standard-library loop in ``check`` runs the rest with -``python -I``, and ``translator-tests`` hands the matched files to pytest. ``tests/semantic/`` goes to +``.github/workflows/ci.yml`` splits ``tests/test_*.py`` between two runners with a single predicate +(``PYTEST_FILE_MARKERS``, or no ``__main__``): the standard-library loop in ``check`` (and the Linux stdlib +step of ``linux-python-and-viewer``) runs the rest with ``python -I``, and ``linux-python-and-viewer`` hands +the matched files to pytest. ``tests/semantic/`` goes to ``unittest discover`` and ``tests/*.cjs`` to ``node --test``. This is the test-file counterpart of ``tests/test_ctest_registration.py``: it reads the patterns from the workflow (not from a copy, so it cannot drift) and fails on the three ways a test goes missing without CI turning red -- @@ -404,9 +405,10 @@ def spirv_using_stdlib_files(root, files, rules): def stdlib_loop_jobs_with_spirv_tools(workflow): - """Jobs that `apt-get install` spirv-tools and run the standard-library loop (`python -I "$t"`).""" + """Jobs that `apt-get install` spirv-tools and run the standard-library loop.""" jobs = re.findall(r"^ ([A-Za-z0-9_-]+):\n(.*?)(?=^ [A-Za-z0-9_-]+:\n|\Z)", workflow, re.M | re.S) - return [name for name, job in jobs if re.search(r'python\s+-I\s+"\$t"', job) + return [name for name, job in jobs + if re.search(r'python3?\s+-I\s+(?:"\$t"|scripts/run_standalone_tests\.py)', job) and re.search(r"apt-get\s+install[^\n]*\bspirv-tools\b", job)] @@ -558,8 +560,8 @@ def test_the_semantic_job_installs_what_its_spirv_gated_tests_need(self): self.assertIn(expected, gated) problem = spirv_tools_problem(read(ROOT, WORKFLOW), gated) self.assertIsNone(problem, "the `semantic-tests` job in ci.yml runs tests that skip without SPIRV-Tools, but " + - str(problem) + ".\nInstall spirv-tools on the Linux leg and set LEONIDA_REQUIRE_SPIRV_TOOLS " - "to '1' there (see tests/semantic/test_spirv_tools_required.py).") + str(problem) + ".\nInstall spirv-tools and set LEONIDA_REQUIRE_SPIRV_TOOLS " + "to '1' (see tests/semantic/test_spirv_tools_required.py).") def test_a_job_runs_the_spirv_using_stdlib_files_with_spirv_tools(self): # The check job's Windows runner has no SPIRV-Tools, so these files skip their spirv-val checks there. @@ -580,10 +582,10 @@ def test_the_spirv_tools_check_flags_a_job_that_installs_nothing(self): "sudo apt-get install -y --no-install-recommends curl\n", 1) self.assertNotEqual(no_install, workflow) self.assertIn("apt-get", no_install) - # the translator-tests job above installs spirv-tools too; only the semantic job's own text may count + # the linux-python-and-viewer job above installs spirv-tools too; only the semantic job's own text may count self.assertIn("does not `apt-get install` spirv-tools", spirv_tools_problem(no_install, gated) or "") - no_switch = workflow.replace("LEONIDA_REQUIRE_SPIRV_TOOLS: ${{ runner.os == 'Linux' && '1' || '0' }}", - "LEONIDA_REQUIRE_SPIRV_TOOLS: ${{ runner.os == 'Linux' && 'yes' || 'no' }}") + no_switch = workflow.replace('LEONIDA_REQUIRE_SPIRV_TOOLS: "1"', + 'LEONIDA_REQUIRE_SPIRV_TOOLS: "0"') self.assertNotEqual(no_switch, workflow) self.assertIn("never sets LEONIDA_REQUIRE_SPIRV_TOOLS", spirv_tools_problem(no_switch, gated) or "") @@ -811,7 +813,7 @@ def test_loop_runs_past_a_failure_and_names_every_failed_file(self): def test_step_script_reads_the_check_loop(self): script = step_script(ROOT, STDLIB_STEP) - self.assertIn('python -I scripts/run_standalone_tests.py -j 2', script) + self.assertIn('python -I scripts/run_standalone_tests.py -j 4', script) self.assertIn("-name 'test_*.py'", script) diff --git a/tests/test_feature_scan.py b/tests/test_feature_scan.py index 133099bd9a..d79116f8dc 100644 --- a/tests/test_feature_scan.py +++ b/tests/test_feature_scan.py @@ -87,7 +87,7 @@ def build(root): def test_feature_scan(): - """Runs under pytest (CI's translator-tests job) and as a plain script.""" + """Runs under pytest (CI's linux-python-and-viewer job) and as a plain script.""" with tempfile.TemporaryDirectory() as tmp: sh, index = build(tmp) d = F.scan_dxbc(os.path.join(sh, "dxbc"), index) diff --git a/tests/test_vs_input_survey.py b/tests/test_vs_input_survey.py index 438bfc30ae..547686ef21 100644 --- a/tests/test_vs_input_survey.py +++ b/tests/test_vs_input_survey.py @@ -53,7 +53,7 @@ def build(root): def test_vs_input_survey(): - """Runs under pytest (CI's translator-tests job) and as a plain script.""" + """Runs under pytest (CI's linux-python-and-viewer job) and as a plain script.""" with tempfile.TemporaryDirectory() as tmp: dx = build(tmp) r = V.survey(dx) From 3209231b3d4f752c131159dc50ce17dee0b4b24a Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Sun, 29 Nov 2026 19:30:03 -0500 Subject: [PATCH 2/3] ci: satisfy jactionlint default profile (pipefail shells and dependabot cooldown) --- .github/dependabot.yml | 4 ++++ .github/workflows/runtime.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 41fd7264fb..9586204396 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,8 @@ updates: directory: / schedule: interval: weekly + cooldown: + default-days: 7 groups: actions: patterns: ["*"] @@ -17,6 +19,8 @@ updates: directory: / schedule: interval: weekly + cooldown: + default-days: 7 commit-message: prefix: deps open-pull-requests-limit: 1 diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index 9d814c51e3..cb2f687fc7 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -503,6 +503,7 @@ jobs: spirv-val --target-env vulkan1.2 runtime/build/predicated_copy.spv runtime/build/vk_predicated_copy_test - name: GPU tests on llvmpipe + shell: bash run: | vulkaninfo --summary | grep -E 'deviceName.*llvmpipe' # fails the step if llvmpipe isn't there python3 -I scripts/run_gpu_tests.py --build runtime/build --llvm-mc /usr/lib/llvm-21/bin/llvm-mc --work "$RUNNER_TEMP/gpu-native" @@ -592,6 +593,7 @@ jobs: python-version: "3.12" - uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 - name: Install MoltenVK, the Vulkan headers and loader, llvm-mc, SPIRV-Tools and glslang + shell: bash run: | brew install llvm molten-vk vulkan-headers vulkan-loader vulkan-tools spirv-tools glslang ninja LLVM_MC="$(brew --prefix llvm)/bin/llvm-mc" # keg-only: not on PATH From d2befefad70eb5de8f7e1bbdf547a971b4dabec7 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Sun, 29 Nov 2026 20:06:24 -0500 Subject: [PATCH 3/3] ci(runtime): keep windows ctest serial to avoid 4-vCPU starvation in xmem/silent_audio --- .github/workflows/runtime.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index cb2f687fc7..d286f73e50 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -344,8 +344,10 @@ jobs: if-no-files-found: error # --timeout: a test without a TIMEOUT of its own fails after 5 min instead of the CTest default of 25, which # is longer than the job. The slowest on Linux and macOS (xdxr_build_check) takes 50 and 106 s. + # Keep ctest serial on windows-latest: concurrent scheduling starves real-time/thread-timing checks + # (silent_audio, xmem) on 4-vCPU runners, while serial ctest completes in ~2 min. - name: CPU runtime tests - run: ctest --test-dir runtime/build --output-on-failure --timeout 300 --parallel 4 + run: ctest --test-dir runtime/build --output-on-failure --timeout 300 # Runs the Windows build's tests under Wine, so a change that breaks the loader on Linux (through Wine or Proton) # shows up. The required ones are the loader and the stand-in game run end to end; the table in the job summary