From 819abe255efec343a42373864dad4c4ae5c29490 Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Thu, 5 Jan 2017 15:23:35 +0100
Subject: [PATCH] setup generating and uploading coverage reports

---
 .gitlab-ci.yml | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6bc4541d..de7383d4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -57,7 +57,10 @@ build documentation:
 run tests:
   stage: test
   script:
-    - py.test --cov=kwant --flakes kwant
+    - py.test --cov=kwant --cov-report term --cov-report html --flakes kwant
+  artifacts:
+    paths:
+      - htmlcov
 
 check for broken links in doc:
   stage: test
@@ -65,6 +68,22 @@ check for broken links in doc:
     - make -C doc linkcheck
   allow_failure: true
 
+
+upload coverage:
+  stage: deploy
+  only:
+    - branches@kwant/kwant
+  environment:
+    name: coverage/$CI_BUILD_REF_NAME
+    url: https://kwant-project.org/coverage/$CI_BUILD_REF_SLUG
+  before_script:
+    - mkdir -p ~/.ssh && ssh-keyscan kwant-project.org >> ~/.ssh/known_hosts
+    - echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
+  script:
+    - rsync -rlv --delete htmlcov/* kwant@kwant-project.org:coverage/$CI_BUILD_REF_SLUG
+  after_script:
+    - rm -rf ~/.ssh
+
 upload documentation to the test server:
   stage: deploy
   only:
-- 
GitLab