mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 23:38:37 +00:00
ci.yml (5 steps), runtime.yml (3) and xma2-decoder.yml (1) left the GITHUB_TOKEN in .git/config for the rest of the job. No step in those jobs runs an authenticated git command, so the token was never needed there. The other 8 checkout steps already set the flag. CI-SECURITY-CREDENTIALS
312 lines
14 KiB
YAML
312 lines
14 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
# Coalesce superseded pending pushes per branch without canceling an active main build.
|
|
group: ci-${{ github.event_name }}-${{ github.event.pull_request.number || (github.event_name == 'push' && github.ref) || github.run_id }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
env:
|
|
PYTEST_FILE_MARKERS: '^import pytest|^ *HAVE_NUMPY ='
|
|
|
|
jobs:
|
|
change-scope:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
outputs:
|
|
docs-only: ${{ steps.paths.outputs.docs-only }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
- name: Check whether only documentation changed
|
|
id: paths
|
|
shell: pwsh
|
|
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.
|
|
# 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
|
|
# tracked files. tests/test_ci_registration.py fails when a tests/test_docs_*.py is not run here.
|
|
- name: Check documentation when only documentation changed
|
|
if: steps.paths.outputs.docs-only == 'true'
|
|
run: |
|
|
for t in tests/test_docs_*.py tests/test_i18n_index.py; do
|
|
echo "== $t"
|
|
python3 -I "$t" || exit 1
|
|
done
|
|
|
|
check:
|
|
needs: change-scope
|
|
if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }}
|
|
runs-on: windows-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
with:
|
|
python-version: "3.12"
|
|
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
|
|
with:
|
|
dotnet-version: "8.0.x"
|
|
cache: true
|
|
cache-dependency-path: "**/packages.lock.json"
|
|
- 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
|
|
- name: Tests (standard library only, no game data)
|
|
shell: bash
|
|
run: |
|
|
# Run every file, then fail: stopping at the first failure would hide the files after it.
|
|
failed=()
|
|
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" || failed+=("$t")
|
|
done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort) # pytest-based files run in the translator-tests job
|
|
if (( ${#failed[@]} )); then
|
|
for t in "${failed[@]}"; do echo "::error file=$t::$t failed"; done
|
|
exit 1
|
|
fi
|
|
- name: Build rpf9dump
|
|
run: dotnet build tools/rpf9dump/rpf9dump.csproj -c Release
|
|
- name: Test TTPF export retry
|
|
env:
|
|
RPF9DUMP_DLL: tools/rpf9dump/bin/Release/net8.0/rpf9dump.dll
|
|
run: python -I tests/test_ttpf_export_resume.py
|
|
# The standard-library loop above runs this file before rpf9dump is built, where it skips for lack of the DLL.
|
|
- name: Test rpf9dump exit codes
|
|
env:
|
|
RPF9DUMP_DLL: tools/rpf9dump/bin/Release/net8.0/rpf9dump.dll
|
|
run: python -I tests/test_rpf9dump_exit_codes.py
|
|
- name: Build the calibrated BCPack reader and test the texture pipeline
|
|
env:
|
|
RPF9DUMP_DLL: tools/rpf9dump/bin/Release/net8.0/rpf9dump.dll
|
|
shell: bash
|
|
run: |
|
|
python -m pip install -c tests/requirements.txt numpy
|
|
CARGO_HOME="$(mktemp -d)" cargo build --release --locked --offline --manifest-path tools/bcpack_calibration/Cargo.toml
|
|
python -I -c "import sys; sys.path.insert(0, 'tools'); import calibrated_texture; calibrated_texture.native()"
|
|
python -I tests/test_calibrated_texture.py
|
|
python -I tests/test_ttpf_assets.py
|
|
- name: Test rpf9dump diagnostics
|
|
run: dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release
|
|
translator-tests:
|
|
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:
|
|
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: Install llvm-mc (LLVM 21) and spirv-tools
|
|
shell: bash
|
|
run: |
|
|
# 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
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends llvm-21 spirv-tools
|
|
pip install -r tests/requirements.txt
|
|
LLVM_MC=/usr/lib/llvm-21/bin/llvm-mc
|
|
echo "LLVM_MC=$LLVM_MC" >> "$GITHUB_ENV"
|
|
version_out=$("$LLVM_MC" --version)
|
|
printf '%s\n' "$version_out"
|
|
grep -q 'LLVM version 21\.' <<< "$version_out"
|
|
grep -q 'amdgcn' <<< "$version_out"
|
|
- name: Translator tests
|
|
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
|
|
semantic-tests:
|
|
needs: change-scope
|
|
if: ${{ !cancelled() && needs.change-scope.outputs.docs-only != 'true' }}
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 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)
|
|
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
|
|
|
|
viewer-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:
|
|
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: Install SPIRV-Tools and numpy
|
|
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)
|