mirror of
https://github.com/vastsa/FileCodeBox.git
synced 2026-11-20 13:29:56 +08:00
- deps: pin uvloop 0.23.0 (non-Windows marker) and httptools 0.9.0; uvicorn's --loop/--http auto picks both up. Lockfile regenerated with constraints so only these two packages are added (no transitive version drift). - Dockerfile: expose TIMEOUT_KEEP_ALIVE (default 5, passed to uvicorn) and MALLOC_TRIM_THRESHOLD_=65536 so glibc returns freed heap to the OS after large transfers. Defaults keep previous behaviour. - ci: allow `; marker` pins in the lockfile drift check, otherwise uvloop would be silently skipped and never verified. - docs: document both environment variables (zh/en). - tests: pin the Dockerfile/requirements/lockfile runtime contract.
68 lines
2.1 KiB
YAML
68 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- dev
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
name: Lint and test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
# The hashed lockfile is the deploy artifact; install from it with
|
|
# --require-hashes so CI fails on lockfile drift, exactly like the
|
|
# Docker build does.
|
|
pip install --require-hashes -r requirements.lock.txt
|
|
pip install pytest pytest-asyncio httpx 'moto[s3,server]' mypy
|
|
|
|
- name: Ruff
|
|
run: pipx run ruff==0.16.6 check .
|
|
|
|
- name: Mypy ratchet (new type errors are rejected; fix and run
|
|
scripts/mypy_ratchet.py --regenerate to tighten the baseline)
|
|
run: python scripts/mypy_ratchet.py
|
|
|
|
- name: Verify lockfile matches requirements.txt
|
|
# Dependabot bumps requirements.txt but cannot regenerate the hashed
|
|
# lockfile; without this check a stale lockfile would silently keep
|
|
# the Docker build on old versions.
|
|
run: |
|
|
python - <<'PY'
|
|
import re, sys
|
|
pins = dict(re.findall(r'^([\w-]+)==([\w.]+)(?:\s*;[^#\n]*)?$', open('requirements.txt').read(), re.M))
|
|
lock = open('requirements.lock.txt').read()
|
|
stale = []
|
|
for name, ver in pins.items():
|
|
m = re.search(rf'(?mi)^{re.escape(name)}==([\w.]+)\b', lock)
|
|
if m is None or m.group(1) != ver:
|
|
stale.append((name, ver, m.group(1) if m else 'ABSENT'))
|
|
for name, req_ver, lock_ver in stale:
|
|
print(f'STALE LOCKFILE: {name} requirements.txt={req_ver} lock={lock_ver}')
|
|
sys.exit(1 if stale else 0)
|
|
PY
|
|
|
|
- name: Run tests
|
|
run: pytest -q
|