From ee61090b70bf85d52a980edd338ccc874e6e0a61 Mon Sep 17 00:00:00 2001
From: Dominik George <nik@naturalnet.de>
Date: Thu, 5 Dec 2019 17:22:39 +0100
Subject: [PATCH] Run pytest from CI pipeline through tox.

---
 .gitlab-ci.yml | 12 ++++++++++++
 pyproject.toml |  1 +
 tox.ini        |  3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 11d2a507e..c8c4292f4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,22 @@
 stages:
+  - test
   - build
   - deploy
 
 variables:
   GIT_SUBMODULE_STRATEGY: recursive
 
+test:
+  stage: test
+  image:
+    name: python:3.8-buster
+  before_script:
+    - apt-get -y update && apt-get -y install postgresql libpq5 libpq-dev libssl-dev
+    - pip install poetry
+  script:
+    - poetry install
+    - poetry run tox
+
 build_docker:
   stage: build
   image:
diff --git a/pyproject.toml b/pyproject.toml
index 42c46dad5..1c5e55406 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -67,6 +67,7 @@ django-stubs = "^1.1"
 pytest = "^5.3"
 pytest-django = "^3.7"
 pytest-django-testing-postgresql = "^0.1"
+tox = "^3.14"
 
 [build-system]
 requires = ["poetry>=0.12"]
diff --git a/tox.ini b/tox.ini
index 66f96199f..b2badcf67 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,10 +1,11 @@
 [tox]
 skipsdist = True
-envlist = py37
 
 [testenv]
 whitelist_externals = poetry
+    pytest
 skip_install = true
+commands = pytest
 
 [pylama]
 linters = pycodestyle,pydocstyle,pyflakes,radon
-- 
GitLab