Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "pip"
directory: "/backend"
schedule:
interval: "weekly"
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ jobs:
- uses: astral-sh/setup-uv@v5

- name: 安装依赖
run: uv sync
run: uv sync --all-groups

- name: 代码风格检查(ruff)
run: uv run ruff check .

- name: 单元测试(pytest)
run: uv run pytest -q

- name: 启动后端并检查健康接口
run: |
Expand Down
3 changes: 2 additions & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from contextlib import asynccontextmanager
from typing import Annotated

from fastapi import Depends, FastAPI
from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -36,7 +37,7 @@ def health():


@app.get("/api/tasks")
def list_tasks(db: Session = Depends(get_db)):
def list_tasks(db: Annotated[Session, Depends(get_db)]):
rows = db.scalars(
select(Task).order_by(Task.id.desc()).limit(50)
).all()
Expand Down
10 changes: 10 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ dependencies = [
"sqlalchemy>=2.0",
"pydantic-settings>=2.6",
]

[dependency-groups]
dev = [
"ruff>=0.8",
"pytest>=8.3",
"httpx>=0.28",
]

[tool.pytest.ini_options]
pythonpath = ["."]
17 changes: 17 additions & 0 deletions backend/tests/test_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from fastapi.testclient import TestClient

from app.main import app


def test_health() -> None:
with TestClient(app) as client:
response = client.get("/api/health")
assert response.status_code == 200
assert response.json()["status"] == "ok"


def test_tasks_empty() -> None:
with TestClient(app) as client:
response = client.get("/api/tasks")
assert response.status_code == 200
assert response.json() == []
128 changes: 128 additions & 0 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading