Files
ComfyUI-Lora-Manager/.github/workflows/backend-tests.yml
T
Will Miao fadad1b507 ci(backend): run the test suite on Windows too (#1146)
The backend suite only ever ran on ubuntu-latest, which is why #1146 shipped:
every configured model root counted twice, the duplicate shadowed the live root
as unreachable, and models deleted from disk were never pruned again. That whole
class of bug depends on `os.sep`/`os.name`, so a Linux-only matrix cannot see it.

* New `pytest-windows` job on `windows-latest` running the same suite. No
  coverage upload: the Linux job keeps producing that artifact.
* Informational for now (`continue-on-error: true`) so pre-existing Windows
  failures surface in the Actions UI without blocking merges; the flag comes off
  once the suite is Windows-clean.
* The symlink probe reports instead of aborting: `os.symlink` needs Developer
  Mode or an elevated shell on Windows, and a runner without it should still show
  the real test results.
2026-10-12 08:43:06 +08:00

153 lines
4.5 KiB
YAML

name: Backend Tests
on:
push:
branches:
- main
- master
paths:
- 'py/**'
- 'standalone.py'
- 'tests/**'
- 'requirements.txt'
- 'requirements-dev.txt'
- 'pyproject.toml'
- 'pytest.ini'
- '.github/workflows/backend-tests.yml'
pull_request:
paths:
- 'py/**'
- 'standalone.py'
- 'tests/**'
- 'requirements.txt'
- 'requirements-dev.txt'
- 'pyproject.toml'
- 'pytest.ini'
- '.github/workflows/backend-tests.yml'
jobs:
pytest:
name: Run pytest with coverage
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Verify symlink support
run: |
python - <<'PY'
import os
import pathlib
import tempfile
root = pathlib.Path(tempfile.mkdtemp(prefix="lm-symlink-check-"))
target = root / "target"
target.mkdir()
link = root / "link"
try:
link.symlink_to(target, target_is_directory=True)
except OSError as exc:
raise SystemExit(f"Failed to create directory symlink in CI: {exc}")
is_link = os.path.islink(link)
is_dir = os.path.isdir(link)
realpath = os.path.realpath(link)
print(f"islink={is_link} isdir={is_dir} realpath={realpath}")
if not (is_link and is_dir and realpath == str(target)):
raise SystemExit("Directory symlink is not functioning correctly in CI; aborting.")
PY
- name: Run pytest with coverage
env:
COVERAGE_FILE: coverage/backend/.coverage
run: |
mkdir -p coverage/backend
python -m pytest \
--cov=py \
--cov=standalone \
--cov-report=term-missing \
--cov-report=xml:coverage/backend/coverage.xml \
--cov-report=html:coverage/backend/html \
--cov-report=json:coverage/backend/coverage.json
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-coverage
path: coverage/backend
if-no-files-found: warn
pytest-windows:
# Windows-only regressions cannot be caught by the Linux job: model roots,
# sidecars and symlink handling all branch on `os.sep`/`os.name`. Issue #1146
# (every configured root counted twice and shadowed as unreachable) shipped
# because the suite only ever ran on Ubuntu.
#
# Informational for now: the flag comes off once the suite is Windows-clean.
name: Run pytest on Windows (informational)
runs-on: windows-latest
continue-on-error: true
timeout-minutes: 45
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Report symlink support
# Symlinked model roots are part of the suite; os.symlink needs Developer
# Mode (or an elevated shell) on Windows. Reported, not enforced, so a
# runner without it still shows the real test results.
continue-on-error: true
run: |
python - <<'PY'
import os
import pathlib
import tempfile
root = pathlib.Path(tempfile.mkdtemp(prefix="lm-symlink-check-"))
target = root / "target"
target.mkdir()
link = root / "link"
try:
link.symlink_to(target, target_is_directory=True)
except OSError as exc:
print(f"symlinks unavailable: {exc}")
else:
print(
f"islink={os.path.islink(link)} isdir={os.path.isdir(link)} "
f"realpath={os.path.realpath(link)}"
)
PY
shell: bash
- name: Run pytest
run: python -m pytest -q