-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'implement_ci' into ticket-creation
- Loading branch information
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
|
@@ -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) |