mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 22:08:40 +00:00
The standard-library test loop invokes every tests/test_*.py before Build rpf9dump, so this file's only test skipped for lack of RPF9DUMP_DLL and no later step ran it. Add the step next to the other rpf9dump-dependent tests.
176 lines
7.6 KiB
YAML
176 lines
7.6 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
# Each non-PR run has its own group so a queued push or dispatch cannot replace it.
|
|
group: ci-${{ github.event_name }}-${{ github.event.pull_request.number || 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: the link checker walks every tracked
|
|
# Markdown file, and the i18n index checks docs/i18n/README.md. Both are standard library only.
|
|
- name: Check documentation when only documentation changed
|
|
if: steps.paths.outputs.docs-only == 'true'
|
|
run: |
|
|
python3 -I tests/test_docs_links.py
|
|
python3 -I tests/test_i18n_index.py
|
|
|
|
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:
|
|
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: |
|
|
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) # pytest-based files run in the translator-tests job
|
|
- 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
|
|
- 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: |
|
|
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg
|
|
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:
|
|
os: [windows-latest, ubuntu-latest]
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Translator semantic tests
|
|
run: python -m unittest discover -s tests/semantic -v
|
|
|
|
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
|
|
- 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
|