-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (47 loc) · 1.67 KB
/
ci.yml
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
name: Run Giga Unit Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build custom Postgres image
run: |
docker build -t custom-postgres -f ci_config/Dockerfile.postgres .
if docker ps -q --filter "ancestor=postgres:latest" | grep -q .; then
docker stop $(docker ps -q --filter "ancestor=postgres:latest")
fi
docker run --name pg-container -d -p 5432:5432 \
-e POSTGRES_DB=giga_test \
-e POSTGRES_USER=postgres \
-e POSTGRES_HOST_AUTH_METHOD=trust \
custom-postgres
- name: Wait for PostgreSQL to be ready (1/2)
run: |
timeout 30s bash -c '
until docker exec pg-container pg_isready -U postgres; do
echo "Waiting for PostgreSQL to be ready..."
sleep 2
done
'
- name: Wait for PostgreSQL to be ready (2/2)
run: |
until psql -h localhost -U postgres -c "\l"; do
echo "Waiting for PostgreSQL to accept connections..."
sleep 2
done
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install Playwright browsers
run: playwright install
- name: Create database if it doesn't exist
run: psql -h localhost -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'giga_test'" | grep -q 1 || psql -h localhost -U postgres -c "CREATE DATABASE giga_test;"
- name: Run tests
run: pytest