From 7b06989a1e8546502454ec9533288720e45363eb Mon Sep 17 00:00:00 2001
From: Mart van Santen <mart@greenhost.nl>
Date: Thu, 25 Nov 2021 08:08:13 +0100
Subject: [PATCH] Add testing framework for app

---
 .gitlab-ci.yml | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d21f7e0..3dc8bbf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,8 +9,33 @@ stages:
   - application-test
   - integration-test
 
+login_test:
+  image: python:3.9
+  stage: unittest
+  needs: []
+  variables:
+    HYDRA_ADMIN_URL: http://localhost/ignored
+    KRATOS_PUBLIC_URL: http://localhost/ignored
+    PUBLIC_URL: http://localhost/ignored
+  cache:
+    paths:
+      - "$CI_PROJECT_DIR/pip-cache"
+    key: "$CI_PROJECT_ID"
+    before_script:
+      - cd login
+      - python -V
+      - pip install -r requirements.txt
+    script:
+      - pytest -v --cov=login --cov-report=term --cov-report=xml tests
+    artifacts:
+      reports:
+        cobertura: login/coverage.xml
+    coverage: '/^TOTAL.+?(\d+\%)$/'
+
 login:
   stage: build
+  needs:
+    - "login_test"
   variables:
     KANIKO_CONTEXT: "login"
     KANIKO_BUILD_IMAGENAME: $CI_JOB_NAME
-- 
GitLab