mirror of
https://github.com/cft0808/edict.git
synced 2026-09-03 07:17:16 +08:00
ci: 添加 edict-backend CI job (PostgreSQL + Redis + Alembic)
新增 edict-backend job: - PostgreSQL 16 + Redis 7 Service Containers - 安装 edict/backend/requirements.txt 依赖 - edict/backend 下所有 .py 语法检查 - 运行 Alembic 数据库迁移验证 - 验证 FastAPI 应用可正常导入
This commit is contained in:
56
.github/workflows/ci.yml
vendored
56
.github/workflows/ci.yml
vendored
@@ -65,3 +65,59 @@ jobs:
|
||||
tags: edict:test
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
edict-backend:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_DB: edict
|
||||
POSTGRES_USER: edict
|
||||
POSTGRES_PASSWORD: edict_dev_2024
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U edict"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- 6379:6379
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
env:
|
||||
DATABASE_URL: postgresql+asyncpg://edict:edict_dev_2024@localhost:5432/edict
|
||||
REDIS_URL: redis://localhost:6379/0
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
cache: 'pip'
|
||||
cache-dependency-path: edict/backend/requirements.txt
|
||||
|
||||
- name: Install backend dependencies
|
||||
run: pip install -r edict/backend/requirements.txt
|
||||
|
||||
- name: Syntax check (py_compile)
|
||||
run: |
|
||||
find edict/backend -name '*.py' | while read f; do
|
||||
echo " checking $f"
|
||||
python3 -m py_compile "$f"
|
||||
done
|
||||
|
||||
- name: Run Alembic migrations
|
||||
working-directory: edict
|
||||
run: python -m alembic upgrade head
|
||||
|
||||
- name: Verify FastAPI app imports
|
||||
working-directory: edict/backend
|
||||
run: python -c "from app.main import app; print(f'FastAPI app loaded: {len(app.routes)} routes')"
|
||||
|
||||
Reference in New Issue
Block a user