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
5 changes: 5 additions & 0 deletions .github/chatmodes/Enter.chatmode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
description: 'Description of the custom chat mode.'
tools: []
---
Define the purpose of this chat mode and how AI should behave: response style, available tools, focus areas, and any mode-specific instructions or constraints.
85 changes: 85 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: 🧪 Run tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
# Keep Dockerfile runtime Python (3.12.6) and also test against 3.11
python-version: ["3.12.6", "3.11"]

steps:
# --- Checkout code ---
- name: Checkout repository
uses: actions/checkout@v4

# --- Setup Python ---
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

# --- Install uv (as in Dockerfile) and sync dependencies with uv ---
- name: Install project and dev/test deps
working-directory: order_service
run: |
python -m pip install --upgrade pip setuptools wheel
# Install test & dev tools required for CI runs (matches order_service dependency-groups:dev)
python -m pip install httpx pytest pytest-asyncio pytest-cov ruff black mypy types-python-dateutil
# Install project in editable mode with all deps (-e for source mapping in coverage)
python -m pip install -e .

- name: Cache pip
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.cache/pypoetry
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('order_service/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-

# --- Run pytest with coverage (via uv to match runtime) ---
- name: Run tests (pytest via uv)
working-directory: order_service
env:
PYTHONPATH: ./
run: |
mkdir -p test-reports
uv run pytest -v --maxfail=1 --disable-warnings \
--junitxml=test-reports/junit-${{ matrix.python-version }}.xml \
--cov=src --cov-report=xml:test-reports/coverage-${{ matrix.python-version }}.xml --cov-report=term-missing --cov-fail-under=80 || true

- name: Fail if tests failed
if: always()
run: |
# If any junit reports contain failures, exit non-zero
set -e
grep -R "failures=\|errors=" test-reports || true
# Let the job fail based on exit code from pytest above
if [ -f test-reports/junit-${{ matrix.python-version }}.xml ]; then
# simple check: look for failures attribute > 0
failures=$(xmllint --xpath 'string(//testsuite/@failures)' test-reports/junit-${{ matrix.python-version }}.xml || echo 0)
errors=$(xmllint --xpath 'string(//testsuite/@errors)' test-reports/junit-${{ matrix.python-version }}.xml || echo 0)
if [ "${failures}" != "0" ] || [ "${errors}" != "0" ]; then
echo "Tests reported failures or errors (failures=${failures}, errors=${errors})"
exit 1
fi
fi

# --- (Optional) Upload coverage report artifact ---
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.python-version }}
path: order_service/test-reports
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# ────────────────────────────────
# Python / Build Artifacts
# ────────────────────────────────
__pycache__/
*.py[cod]
*.pyo
*.pyd
*.so
*.egg
*.egg-info/
.eggs/
dist/
build/
pip-wheel-metadata/
.installed.cfg

# ────────────────────────────────
# Environment / Dependency Managers
# ────────────────────────────────
.venv/
venv/
env/
ENV/
.uv/
.venv-*/
poetry.lock
uv.lock
Pipfile
Pipfile.lock

# ────────────────────────────────
# IDE / Editor Configs
# ────────────────────────────────
.vscode/
.idea/
*.swp
*.swo
*.bak

# ────────────────────────────────
# Logs / Temp Files
# ────────────────────────────────
*.log
*.tmp
*.temp
*.out
nohup.out
coverage.xml
htmlcov/
.cache/
.pytest_cache/
.tox/
.mypy_cache/
ruff_cache/
.dmypy.json
.pyre/
pytestdebug.log

# ────────────────────────────────
# Databases / Runtime Files
# ────────────────────────────────
*.db
*.sqlite3
*.sqlite
alembic.ini
alembic/versions/*.pyc
alembic/versions/__pycache__/
alembic/versions/*.log

# ────────────────────────────────
# Docker / Compose
# ────────────────────────────────
# (игнорим build-артефакты, но не Dockerfile)
**/__pycache__/
**/.pytest_cache/
**/.mypy_cache/
**/Dockerfile.old
**/docker-compose.override.yml
**/.dockerignore
docker-compose.override.yml
.docker/
tmp/

# ────────────────────────────────
# Environment Files / Secrets
# ────────────────────────────────
.env
.env.*
!.env.example # но пример конфигурации оставляем в репозитории
*.pem
*.key
*.crt
*.csr
*.pub
secrets/
**/secrets.yaml
**/secrets.json

# ────────────────────────────────
# Coverage / Reports
# ────────────────────────────────
.coverage
coverage.json
cov_html/
reports/
logs/
test-results.xml

# ────────────────────────────────
# Jupyter / Notebooks (если вдруг)
# ────────────────────────────────
.ipynb_checkpoints/
*.ipynb

# ────────────────────────────────
# OS Specific / Misc
# ────────────────────────────────
.DS_Store
Thumbs.db
desktop.ini
*.orig
*.rej

# ────────────────────────────────
# Project specific (AsyncFlow)
# ────────────────────────────────
# Игнорим локальные данные сервисов
order_service/data/
billing_service/data/
notification_service/data/

# Игнорим локальные RabbitMQ volume data
rabbitmq_data/
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
repos:
# ---- Ruff (линтер + форматтер) ----
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
hooks:
- id: ruff
name: ruff (all services)
args: [--fix]
- id: ruff-format
name: ruff format (all services)

# ---- Black (форматирование, если хочешь строгий стиль) ----
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
name: black (all services)
language_version: python3.12
additional_dependencies: [black>=24.8.0]

# ---- Mypy (типизация) ----
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
name: mypy (all services)
language_version: python3.12
additional_dependencies:
- pydantic>=2.7,<3
- pydantic-settings>=2.3,<3
- sqlalchemy>=2.0,<3
- aio-pika>=9,<10
- fastapi>=0.115,<1
# проверяем все сервисы разом
args: [
"--pretty",
"--show-error-codes",
"--namespace-packages",
"order_service/src",
"billing_service/src",
"notification_service/src",
]

# ---- Pytest (опционально: быстрые тесты) ----
- repo: local
hooks:
- id: pytest
name: pytest (order_service)
entry: uv run pytest -q --maxfail=1 --disable-warnings -x
language: system
pass_filenames: false
always_run: true
stages: [commit]
Loading
Loading