Skip to content

Commit

Permalink
Merge branch 'implement_ci' into ticket-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrimari committed Dec 8, 2024
2 parents 9cdb3ad + 77c3f15 commit 71e14a4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
75 changes: 75 additions & 0 deletions .github/workflows/backend_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 serveo.net > serveo.log 2>&1 &
PID=$!
while true; do
sleep 1
echo "Checking if Serveo is up..."
if grep -q 'HTTP' "serveo.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]+\.serveo\.net' "serveo.log")
export APPLICATION_URL=$url
python3 manage.py test ./bittan/tests --exclude-tag=no_ci
kill $PID
4 changes: 3 additions & 1 deletion backend/bittan/bittan/tests/mail/test_mail.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.test import TestCase
from django.test import TestCase, tag
from bittan.mail import send_mail, make_qr_image
from bittan.mail import MailError, InvalidRecieverAddressError

@tag("no_ci")
class SendMailTest(TestCase):

def setUp(self):
Expand Down Expand Up @@ -30,6 +31,7 @@ def test_make_qr_image(self):
self.assertEqual(type(qr), bytes)
self.assertGreater(len(qr), 1)

@tag("no_ci")
def test_send_qr_in_mail(self):
qr = make_qr_image("This is some content!")
send_mail("[email protected]", "QR Test", "This test mail contains a QR code.", qr)

0 comments on commit 71e14a4

Please sign in to comment.