Skip to content

Commit

Permalink
refactor(ci): split Selenium tests into separate job
Browse files Browse the repository at this point in the history
This prepares the ground for Selenium tests to be run in a Matrix strategy with
multiple different configurations (with JS, without JS, Firefox, Chrome, etc).
  • Loading branch information
Restioson committed Nov 6, 2024
1 parent 61c3f07 commit 7815149
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 38 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,51 @@ jobs:
cp .env.testing app/.env
cd app/
mkdir -p static_files
python manage.py test
python manage.py test --exclude-tag=selenium
env:
DJANGO_SETTINGS_MODULE: app.settings
DATABASE_URL: postgres://sadilar:sadilar@localhost:5432/test_db
- name: Manager Check
run: |
cd app/
python manage.py check
selenium:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: sadilar
POSTGRES_PASSWORD: sadilar
POSTGRES_DB: test_db_1
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
sudo apt-get install -y gettext
- name: Create logging folder
run: |
sudo mkdir -p /logging
sudo chown runner:runner /logging
- name: Run Selenium Tests
run: |
cp .env.testing app/.env
cd app/
mkdir -p static_files
python manage.py test --tag=selenium
env:
DJANGO_SETTINGS_MODULE: app.settings
DATABASE_URL: postgres://sadilar:sadilar@localhost:5432/test_db
lighthouse:
runs-on: ubuntu-latest # operating system your code will run on
services:
Expand Down
2 changes: 2 additions & 0 deletions app/general/tests/test_frontend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test import tag
from selenium.common import TimeoutException
from selenium.webdriver.chrome.webdriver import Options, WebDriver
from selenium.webdriver.common.by import By
Expand All @@ -8,6 +9,7 @@
WAIT_TIMEOUT = 5


@tag("selenium")
class TestFrontend(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
Expand Down

0 comments on commit 7815149

Please sign in to comment.