forked from djeck1432/spotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (88 loc) · 3.02 KB
/
integration-tests.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
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
name: Integration Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
DB_PORT: 5432
DB_NAME: spotnet
DB_USER: postgres
DB_PASSWORD: password
DB_HOST: db
STARKNET_NODE_URL: http://51.195.57.196:6060/v0_7
REDIS_HOST: redis
REDIS_PORT: 6379
ENV_VERSION: DEV
jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Create .env file
run: |
cat << EOF > /home/runner/work/spotnet/spotnet/.env
ENV_VERSION=DEV
STARKNET_NODE_URL=${{ env.STARKNET_NODE_URL }}
DB_USER=${{ env.DB_USER }}
DB_PASSWORD=${{ env.DB_PASSWORD }}
DB_NAME=${{ env.DB_NAME }}
DB_HOST=${{ env.DB_HOST }}
DB_PORT=${{ env.DB_PORT }}
REDIS_HOST=${{ env.REDIS_HOST }}
REDIS_PORT=${{ env.REDIS_PORT }}
EOF
- name: Build and Start Containers
run: |
docker compose -f docker-compose.dev.yaml up -d --build
echo "Waiting for containers to be ready..."
sleep 30
- name: Install Test Dependencies in Container
run: |
docker exec backend_dev pip install pytest pytest-cov
docker exec backend_dev pip freeze # Debug: show installed packages
- name: Wait for Backend Service
timeout-minutes: 5
run: |
while ! curl -s http://localhost:8000/health > /dev/null; do
echo "Waiting for backend service..."
sleep 30
# Check if the container is still running before logging
if ! docker ps | grep -q backend; then
echo "Backend container is not running!"
docker compose -f docker-compose.dev.yaml logs backend || true
exit 1
fi
# Log the backend service status for debugging purposes.
docker compose -f docker-compose.dev.yaml logs backend || true
done
- name: Apply Migrations
run: |
docker exec backend_dev alembic -c web_app/alembic.ini upgrade head || {
echo "Migration failed. Showing backend logs:"
docker compose -f docker-compose.dev.yaml logs backend || true
exit 1
}
- name: Run Integration Tests with Coverage
run: |
docker compose exec backend bash -c "cd /app && python -m pytest web_app/test_integration/ -v"
- name: Clean Up
if: always()
run: |
docker compose -f docker-compose.dev.yaml logs > docker-logs.txt || true
docker compose -f docker-compose.dev.yaml down -v
- name: Upload Docker Logs on Failure
if: failure()
uses: actions/upload-artifact@v3
with:
name: docker-logs
path: docker-logs.txt