-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (62 loc) · 1.81 KB
/
backend_test.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
name: Backend Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
ports:
- 5432:5432
env:
POSTGRES_DB: bittan_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=30
steps:
- name: Setup postgres etc/hosts
run: |
echo "127.0.0.1 postgres" | sudo tee -a /etc/hosts
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.13
- name: Install dependencies
working-directory: ./backend/bittan
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Run tests
working-directory: ./backend/bittan
run: |
timeout=30
start_time=$SECONDS
ssh -o "StrictHostKeyChecking no" -R 80:localhost:8000 [email protected] > localhost.log 2>&1 &
PID=$!
while true; do
sleep 1
echo "Checking if localhost is up..."
if grep -qP 'https://[a-f0-9]+\.lhr\.life' "localhost.log"; then
break
fi
if (( SECONDS - start_time >= timeout )); then
echo "Timeout reached. Exiting."
exit 1
fi
done
url=$(grep -oP 'https://[a-f0-9]+\.lhr\.life' "localhost.log")
export APPLICATION_URL=$url
python3 manage.py test ./bittan/tests --exclude-tag=no_ci
kill $PID