-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (97 loc) · 2.74 KB
/
ci.yml
File metadata and controls
115 lines (97 loc) · 2.74 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_pass
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --dev
- name: Run linting
run: uv run ruff check .
- name: Run formatting check
run: uv run ruff format --check .
- name: Run type checking
run: uv run mypy src/
- name: Run tests
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_pass
POSTGRES_SERVER: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: test_db
S3_ACCESS_KEY_ID: test_key
S3_ACCESS_KEY: test_secret
S3_BUCKET: test-bucket
REDIS_HOST: localhost
REDIS_PORT: 6379
ENVIRONMENT: testing
DEBUG: false
LOG_LEVEL: WARNING
run: |
uv run pytest src/tests/test_basic.py \
src/tests/test_config.py \
src/tests/test_utils.py \
src/tests/test_s3.py \
src/tests/test_celery.py \
-v --cov=src --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
build-docker:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
cp .env-copy .env
docker compose build fastapi
- name: Test Docker image
run: |
docker compose up -d db redis_db minio
sleep 10
docker compose run --rm fastapi python -c "from src.config import get_settings; print('Docker build successful')"