forked from mahmoudsamy7729/fastapi-saas-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (94 loc) · 3.73 KB
/
ci.yml
File metadata and controls
114 lines (94 loc) · 3.73 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
name: CI (FastAPI • PR only)
on:
pull_request:
branches: [ main ] # add others like: 'develop'
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_pass
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U test_user"
--health-interval=5s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync
- name: Prepare environment file
run: |
cp .env.example .env
echo "APP_NAME=FastAPI-Test" >> .env
echo "APP_ENV=test" >> .env
echo "APP_DEBUG=False" >> .env
echo "APP_URL=http://localhost:8000" >> .env
# Database
echo "DATABASE_URL=postgresql+asyncpg://test_user:test_pass@localhost:5432/test_db" >> .env
echo "SYNC_DATABASE_URL=postgresql+psycopg://test_user:test_pass@localhost:5432/test_db" >> .env
echo "TEST_DATABASE_URL=postgresql+asyncpg://test_user:test_pass@localhost:5432/test_db" >> .env
# JWT (dummy values)
echo "ALGORITHM=HS256" >> .env
echo "ACCESS_SECRET_KEY=secret" >> .env
echo "ACCESS_TOKEN_EXPIRE=30" >> .env
echo "REFRESH_SECRET_KEY=secret" >> .env
echo "REFRESH_TOKEN_EXPIRE=60" >> .env
echo "VALIDATION_SECRET_KEY=secret" >> .env
echo "VALIDATION_TOKEN_EXPIRE=10" >> .env
# Mail (dummy values)
echo "SMTP_HOST=${{ secrets.SMTP_HOST }}" >> .env
echo "SMTP_PORT=${{ secrets.SMTP_PORT }}" >> .env
echo "SMTP_USER=${{ secrets.SMTP_USER }}" >> .env
echo "SMTP_PASSWORD=${{ secrets.SMTP_PASSWORD }}" >> .env
# Social login (dummy values)
echo "GOOGLE_CLIENT_ID=dummy" >> .env
echo "GOOGLE_CLIENT_SECRET=dummy" >> .env
echo "GOOGLE_REDIRECT_URI=http://localhost" >> .env
echo "GOOGLE_AUTH_URL=http://localhost" >> .env
echo "GOOGLE_TOKEN_URL=http://localhost" >> .env
echo "GOOGLE_USERINFO_URL=http://localhost" >> .env
echo "GITHUB_CLIENT_ID=dummy" >> .env
echo "GITHUB_CLIENT_SECRET=dummy" >> .env
echo "GITHUB_REDIRECT_URI=http://localhost" >> .env
echo "GITHUB_AUTHORIZE_URL=http://localhost" >> .env
echo "GITHUB_TOKEN_URL=http://localhost" >> .env
echo "GITHUB_USER_API=http://localhost" >> .env
echo "GITHUB_EMAILS=http://localhost" >> .env
echo "REDIS_URL=http://localhost" >> .env
echo "CELERY_WORKER_URL=http://localhost" >> .env
echo "CELERY_BEAT_URL=http://localhost" >> .env
echo "STRIPE_PUBLIC_KEY=dummy" >> .env
echo "STRIPE_SECRET_KEY=dummy" >> .env
echo "STRIPE_WEBHOOK_SECRET=dummy" >> .env
echo "AI_PROVIDER=dummy" >> .env
echo "GROQ_API_KEY=dummy" >> .env
echo "GROQ_BASE_URL=dummy" >> .env
echo "AI_MODEL=dummy" >> .env
- name: Run tests
env:
ENV: test
run: uv run pytest -q --maxfail=1 --disable-warnings
- name: Upload coverage HTML
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov