-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (39 loc) · 1.35 KB
/
Copy pathtest.yml
File metadata and controls
50 lines (39 loc) · 1.35 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
name: Build and test web application and database
on:
push:
branches:
- main
- 'feature/*'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry==1.8.1
poetry install --no-root
- name: Run docker compose and wait until web server is up
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASS: ${{ secrets.DB_PASS }}
POSTGRES_PASSWORD: ${{ secrets.DB_PASS }}
run: |
docker compose up --build -d
docker compose logs db
timeout 60 bash -c 'until docker compose exec db pg_isready; do sleep 1; done'
timeout 60 bash -c 'until curl -s http://localhost:8000/health || curl -s http://localhost:8000; do sleep 1; done'
- name: Run API tests
run: poetry run pytest tests/test_api.py
- name: Run database tests
run: docker compose exec web poetry run pytest tests/test_database.py
- name: Stop and remove container
run: docker compose down