Skip to content

Commit

Permalink
[#1570] create separate ci job for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Aug 11, 2023
1 parent b0f6c9a commit 29cd3f9
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 26 deletions.
1 change: 1 addition & 0 deletions .coverage.fedora.1089256.271783

Large diffs are not rendered by default.

77 changes: 70 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ env:
IMAGE_NAME: maykinmedia/open-inwoner

jobs:
#
# Unit and integration tests
#
tests:
name: Run the Django test suite
runs-on: ubuntu-latest
Expand All @@ -23,7 +26,6 @@ jobs:
image: postgis/postgis:10-2.5
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB_ARGS: --no-sync
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
Expand Down Expand Up @@ -52,21 +54,18 @@ jobs:
setup-node: 'yes'
npm-ci-flags: '--legacy-peer-deps'

- name: Install additional dependencies (playwright)
run: |
playwright install
playwright install msedge
playwright install-deps
- name: Run tests
run: |
python src/manage.py collectstatic --noinput --link
coverage run \
--concurrency=multiprocessing \
--parallel-mode \
src/manage.py test src \
--parallel \
--exclude-tag=e2e \
--exclude-tag=elastic
coverage run src/manage.py test src --tag=elastic
coverage combine
env:
DJANGO_SETTINGS_MODULE: open_inwoner.conf.ci
Expand All @@ -79,6 +78,70 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

#
# End-to-end tests
#
e2etests:
runs-on: ubuntu-latest
strategy:
matrix:
browser:
- chromium
- firefox
- webkit
- msedge

name: End-to-end tests, ${{ matrix.browser }}

services:
postgres:
image: postgis/postgis:10-2.5
env:
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# Needed because the postgres container does not provide a healthcheck
options:
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
--name postgres
steps:
- uses: actions/checkout@v3
- name: Set up backend environment
uses: maykinmedia/setup-django-backend@v1
with:
apt-packages: 'libxml2-dev libxmlsec1-dev libxmlsec1-openssl gettext postgresql-client libgdal-dev gdal-bin'
python-version: '3.9'
optimize-postgres: 'yes'
pg-service: 'postgres'
setup-node: 'yes'
npm-ci-flags: '--legacy-peer-deps'

# See https://playwright.dev/python/docs/ci#caching-browsers
- name: Cache Playwright browser
id: cache-browser
uses: actions/cache@v3
with:
path: /home/runner/.cache/ms-playwright
key:
${{ runner.os }}-${{ matrix.browser }}-playwright-${{ hashFiles('requirements/ci.txt') }}

- name: Install playwright deps
run: playwright install --with-deps ${{ matrix.browser }}

- name: Run testsuite
run: |
python src/manage.py collectstatic --noinput --link
src/manage.py test src --tag=e2e
env:
DJANGO_SETTINGS_MODULE: open_inwoner.conf.ci
SECRET_KEY: dummy
DB_USER: postgres
DB_PASSWORD: ''
E2E_DRIVER: ${{ matrix.browser }}

#
# Docker
#
docker:
needs: tests

Expand Down
5 changes: 1 addition & 4 deletions src/open_inwoner/accounts/tests/test_action_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.contrib.messages import get_messages
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import override_settings
from django.test import override_settings, tag
from django.urls import reverse
from django.utils.translation import gettext as _

Expand Down Expand Up @@ -314,10 +314,7 @@ def test_action_status_not_your_action(self):
self.assertEqual(response.status_code, 404)


<<<<<<< HEAD
@tag("e2e")
=======
>>>>>>> 3cf095c4 ([#1570] remove multi-browser support for playwright tests)
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
@patch("open_inwoner.configurations.models.SiteConfiguration.get_solo")
class ActionsPlaywrightTests(PlaywrightSyncLiveServerTestCase):
Expand Down
5 changes: 1 addition & 4 deletions src/open_inwoner/accounts/tests/test_inbox_page.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import skip

from django.test import override_settings
from django.test import override_settings, tag
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _

Expand Down Expand Up @@ -230,10 +230,7 @@ def test_file_cannot_be_uploaded_when_sharing_disabled(self):
)


<<<<<<< HEAD
@tag("e2e")
=======
>>>>>>> 3cf095c4 ([#1570] remove multi-browser support for playwright tests)
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class InboxPagePlaywrightTests(PlaywrightSyncLiveServerTestCase):
@classmethod
Expand Down
7 changes: 0 additions & 7 deletions src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
DOCUMENTEN_ROOT,
ZAKEN_ROOT,
)
<<<<<<< HEAD
from open_inwoner.utils.test import (
ClearCachesMixin,
DisableRequestLogMixin,
Expand All @@ -43,12 +42,6 @@


@tag("e2e")
=======
from open_inwoner.utils.test import ClearCachesMixin, paginated_response
from open_inwoner.utils.tests.playwright import PlaywrightSyncLiveServerTestCase


>>>>>>> 3cf095c4 ([#1570] remove multi-browser support for playwright tests)
@requests_mock.Mocker()
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class CasesPlaywrightTests(
Expand Down
6 changes: 2 additions & 4 deletions src/open_inwoner/plans/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.messages import get_messages
from django.core import mail
from django.test import override_settings
from django.test import override_settings, tag
from django.urls import reverse
from django.utils.translation import ugettext as _

Expand Down Expand Up @@ -675,6 +675,7 @@ def test_plan_action_status_not_your_action(self):
self.assertEqual(response.status_code, 404)


@tag("e2e")
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class PlanBegeleiderListViewTests(WebTest):
def setUp(self):
Expand Down Expand Up @@ -1136,10 +1137,7 @@ def test_plan_contact_new_count(self):
self.assertEqual(len(links), 1)


<<<<<<< HEAD
@tag("e2e")
=======
>>>>>>> 3cf095c4 ([#1570] remove multi-browser support for playwright tests)
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class PlanActionStatusPlaywrightTests(ActionsPlaywrightTests):
def setUp(self) -> None:
Expand Down

0 comments on commit 29cd3f9

Please sign in to comment.