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 Jun 26, 2023
1 parent 38580c1 commit e9a4692
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 36 deletions.
126 changes: 93 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,93 @@ env:
IMAGE_NAME: maykinmedia/open-inwoner

jobs:
tests:
name: Run the Django test suite
#
# Unit and integration tests
#
# tests:
# name: Run the Django test suite
# runs-on: ubuntu-latest

# 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

# elasticsearch:
# image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
# env:
# discovery.type: single-node
# ES_JAVA_OPTS: '-Xms512m -Xmx512m'
# ports:
# - 9200:9200
# - 9300:9300

# 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'

# - name: Run tests
# run: |
# python src/manage.py collectstatic --noinput --link
# coverage run \
# --concurrency=multiprocessing \
# src/manage.py test src \
# --parallel \
# --exclude-tag=elastic \
# --exclude-tag=e2e

# env:
# DJANGO_SETTINGS_MODULE: open_inwoner.conf.ci
# SECRET_KEY: dummy
# DB_USER: postgres
# DB_PASSWORD: ''

# - name: Publish coverage report
# uses: codecov/codecov-action@v3
# 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
POSTGRES_INITDB_ARGS: --no-sync
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options:
# 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

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
env:
discovery.type: single-node
ES_JAVA_OPTS: '-Xms512m -Xmx512m'
ports:
- 9200:9200
- 9300:9300

steps:
- uses: actions/checkout@v3
- name: Set up backend environment
Expand All @@ -52,33 +113,32 @@ jobs:
setup-node: 'yes'
npm-ci-flags: '--legacy-peer-deps'

- name: Install additional dependencies (playwright)
run: |
playwright install
playwright install msedge
playwright install-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 tests
- name: Run testsuite
run: |
python src/manage.py collectstatic --noinput --link
coverage run \
--concurrency=multiprocessing \
src/manage.py test src \
--parallel \
--exclude-tag=elastic
coverage run src/manage.py test src --tag=elastic
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 }}

- name: Publish coverage report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

#
# Docker
#
docker:
needs: tests

Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/accounts/tests/test_action_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.files.uploadedfile import SimpleUploadedFile
from django.test import override_settings
from django.test import override_settings, skip, tag
from django.urls import reverse
from django.utils.translation import gettext as _

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


@skip("debug")
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class ActionsPlaywrightTests(PlaywrightSyncLiveServerTestCase):
@classmethod
Expand Down
2 changes: 1 addition & 1 deletion 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
3 changes: 2 additions & 1 deletion 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

0 comments on commit e9a4692

Please sign in to comment.