File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Run Tests
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ services :
14+ postgres :
15+ image : postgres:14
16+ env :
17+ POSTGRES_USER : postgres
18+ POSTGRES_PASSWORD : postgres
19+ POSTGRES_DB : fastapi_db
20+ ports :
21+ - 5432:5432
22+ options : >-
23+ --health-cmd pg_isready
24+ --health-interval 10s
25+ --health-timeout 5s
26+ --health-retries 5
27+
28+ env :
29+ DATABASE_URL : postgresql://postgres:postgres@localhost:5432/fastapi_db
30+ PROJECT_NAME : " FastAPI with PostgreSQL"
31+ API_VERSION : " v1"
32+ PYTHONPATH : .
33+
34+ steps :
35+ - name : Checkout code
36+ uses : actions/checkout@v4
37+
38+ - name : Set up Python
39+ uses : actions/setup-python@v5
40+ with :
41+ python-version : " 3.11"
42+
43+ - name : Install dependencies
44+ run : |
45+ python -m pip install --upgrade pip
46+ pip install -r requirements.txt
47+
48+ - name : Wait for PostgreSQL to be ready
49+ run : |
50+ for i in {1..10}; do
51+ pg_isready -h localhost -p 5432 && break
52+ sleep 2
53+ done
54+
55+ - name : Run tests
56+ run : pytest
You can’t perform that action at this time.
0 commit comments