Skip to content

fix(lint): silence F401/F841 in test files #11

fix(lint): silence F401/F841 in test files

fix(lint): silence F401/F841 in test files #11

Workflow file for this run

name: CI
on:
push:
branches: [main, codex/**]
pull_request:
branches: [main]
jobs:
backend-lint-test:
name: Backend lint & test
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
env:
LLM_PROVIDER: deepseek
JWT_SECRET: ci-test-secret-not-for-production
DATABASE_URL: sqlite:///./data/test.db
REDIS_URL: redis://localhost:6379/0
services:
redis:
image: redis:7-alpine
ports: ["6379:6379"]
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: backend/requirements.txt
- name: Install deps
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install "pydantic[email]"
- name: Lint (ruff)
run: |
# 只 lint 我们新加的 tests/, app/ 的历史 lint 警告留给后续单独 PR 处理
ruff check tests/
- name: Run unit tests + coverage
run: |
mkdir -p data
pytest -v --cov=app --cov-report=term-missing --cov-report=xml --cov-report=html --junitxml=test-results.xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v4
with:
files: ./backend/coverage.xml
flags: backend
fail_ci_if_error: false
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-test-results
path: |
backend/test-results.xml
backend/htmlcov/
if-no-files-found: ignore
frontend-build:
name: Frontend build
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
# 没 lock 文件时不要 cache, 否则 setup-node 会因找不到路径而报错
- name: Install deps
run: npm install
- name: Build
run: npm run build
docker-build:
name: Docker build (backend)
runs-on: ubuntu-latest
needs: backend-lint-test
steps:
- uses: actions/checkout@v4
- name: Build backend image
run: docker build -t unikb-backend:ci ./backend