-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (75 loc) · 2.58 KB
/
ci.yml
File metadata and controls
91 lines (75 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: CI Pipeline
# Триггеры для CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
steps:
# 1️⃣ Checkout проекта
- name: Checkout repository
uses: actions/checkout@v4
# 2️⃣ Настройка Python и кеширование pip
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
# 3️⃣ Установка UV и зависимостей
- name: Install UV
run: |
python -m pip install --upgrade pip
pip install uv
# 4️⃣ Кешируем virtualenv UV для ускорения повторных запусков
- name: Cache UV virtualenv
uses: actions/cache@v4
with:
path: |
.venv
~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
# 5️⃣ Синхронизация зависимостей проекта через UV
- name: Sync dependencies
run: uv sync
# 6️⃣ Pre-commit checks (форматирование, линтеры и проверки безопасности)
- name: Run Pre-commit checks
uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
- name: Clear pre-commit cache
run: pre-commit clean
# 7️⃣ Статическая проверка типизации
- name: Run Mypy
run: uv run mypy src/
# 8️⃣ Линтер
- name: Run Ruff
run: uv run ruff check src/
# 9️⃣ Тесты проекта
- name: Run Tests
env:
ENV: test
MAIL_USERNAME: test@example.com
MAIL_PASSWORD: testpass
run: uv run pytest -v --disable-warnings --maxfail=1
# 🔒 10️⃣ Аудит безопасности зависимостей
# - name: Dependency security audit (pip-audit)
# run: uv run pip-audit --format=columns
# - name: Static security scan (Bandit)
# run: uv run bandit -r src -ll
# - name: Safety scan
# run: uv run safety scan
# 12️⃣ Сохраняем кэш pytest при падении тестов
- name: Upload pytest cache
if: failure()
uses: actions/upload-artifact@v4
with:
name: pytest-cache
path: .pytest_cache/