Files
Will Miao 7670b31296 fix(i18n): resolve the page-title key without a partial literal
t('header.navigation.' ~ current_page) made the static i18n scanner
collect the bare prefix 'header.navigation.' as a key of its own, so
test_static_sources_only_use_existing_translations failed on main and
took both backend jobs down with it.

Resolve the key through a variable (t(page_title_key)), the same shape
the search placeholder already uses, keeping the literal prefix out of
the t() call. Rendered output is unchanged for every page.

Also add templates/** and locales/** to the backend workflow paths:
those are the inputs the i18n tests read, so a template- or locale-only
change could previously skip the very job that validates it.
2026-10-29 21:23:00 +08:00

157 lines
4.6 KiB
YAML

name: Backend Tests
on:
push:
branches:
- main
- master
paths:
- 'py/**'
- 'standalone.py'
- 'tests/**'
- 'templates/**'
- 'locales/**'
- 'requirements.txt'
- 'requirements-dev.txt'
- 'pyproject.toml'
- 'pytest.ini'
- '.github/workflows/backend-tests.yml'
pull_request:
paths:
- 'py/**'
- 'standalone.py'
- 'tests/**'
- 'templates/**'
- 'locales/**'
- '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