Skip to content
Open
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
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git
.env
.env.*
!.env.example
__pycache__
.pytest_cache
.venv
*.db
*.sqlite
*.log
node_modules
tests/ui/screenshots
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# python scripts/deploy.py automatically generates the four passwords and JWT key.
SECRET_KEY=change-me-generate-a-random-64-character-key
MYSQL_PASSWORD=change-me
MYSQL_ROOT_PASSWORD=change-me
REDIS_PASSWORD=change-me
RABBITMQ_PASS=change-me
ADMIN_USERNAME=admin
ADMIN_PASSWORD=change-me
GATEWAY_BIND=127.0.0.1
GATEWAY_PORT=8000
CORS_ORIGINS=http://localhost:8000,http://127.0.0.1:8000
LLM_API_KEY=
LLM_BASE_URL=https://api.deepseek.com
LLM_MODEL=deepseek-chat
MAX_OUTBOX_LENGTH=10000
MQ_MAX_RETRIES=3
MQ_RETRY_DELAY_MS=5000
66 changes: 66 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Backend checks
on:
pull_request:
push:
branches: [main, feat/one-click-reliable-seckill]
permissions:
contents: read
jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- run: pip install -r requirements-dev.txt
- run: python -m pytest -q
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm run test:scenarios
integration:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python scripts/deploy.py up
- run: python scripts/deploy.py test
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci
- run: npx playwright install --with-deps chromium
- name: Browser visualization and live observation
run: npm run test:ui
- name: Save visualization screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: visualization-screenshots
path: tests/ui/screenshots/
if-no-files-found: ignore
- name: Restore after service restart
run: |
docker compose restart order seckill
docker compose up -d --wait --wait-timeout 120
python scripts/deploy.py test
- name: Broker outage preserves reservations
run: |
docker compose stop rabbitmq
docker compose --profile test run --no-deps --rm -e BROKER_FAULT_STAGE=outage tests python -m pytest -q tests/test_faults.py
- name: Broker recovery drains outbox
run: |
docker compose start rabbitmq
docker compose up -d --wait --wait-timeout 120
docker compose --profile test run --no-deps --rm -e BROKER_FAULT_STAGE=recovery tests python -m pytest -q tests/test_faults.py
- name: Logs on failure
if: failure()
run: docker compose logs --no-color --tail 100
- name: Cleanup
if: always()
run: docker compose down --volumes
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ mysql_data/
# OS
.DS_Store
Thumbs.db
.pytest_cache/
.env.tmp-*
*.sqlite
*.log
node_modules/
tests/ui/screenshots/
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.12-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && useradd --uid 10001 --create-home app
COPY common ./common
COPY services ./services
COPY scripts ./scripts
COPY tests ./tests
COPY pytest.ini requirements-dev.txt ./
USER app
CMD ["python", "-m", "uvicorn", "services.gateway.main:app", "--host", "0.0.0.0", "--port", "8000", "--no-proxy-headers"]

FROM runtime AS test
USER root
RUN pip install --no-cache-dir -r requirements-dev.txt
USER app
Loading
Loading