From 3128173893ad1221bea69c5ebfae9fbd448d7168 Mon Sep 17 00:00:00 2001 From: Rich Wareham <rjw57@cam.ac.uk> Date: Mon, 4 Mar 2019 15:25:39 +0000 Subject: [PATCH] add GitLab CI configuration Add our standard GitLab CI configuration and tweak the project to be CI friendly: * A simple Dockerfile is added which builds an image which can run tox. * The tox.ini is updated to save JUnit reports where our CI expects to find them and to add coverage XML reports. * Remove the Circle CI badge from the README. We have GitLab CI badges set up for the entire UIS group in GitLab so we don't need any additional configuration. --- .gitlab-ci.yml | 14 ++++++++++++++ Dockerfile | 7 +++++++ README.md | 2 -- tox.ini | 7 +++++-- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..7f17273 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +# This file pulls in the GitLab AutoDevOps configuration via an include +# directive and then overrides bits. The rationale for this is we'd like this +# file to eventually have zero local overrides so that we can use the AutoDevOps +# pipeline as-is. + +include: + # Bring in the AutoDevOps template from GitLab. + # It can be viewed at: + # https://gitlab.com/gitlab-org/gitlab-ee/blob/master/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml + - template: Auto-DevOps.gitlab-ci.yml + + # Overrides to AutoDevOps for testing + - project: 'uis/devops/continuous-delivery/ci-templates' + file: '/auto-devops/tox-tests.yml' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..94c6e5c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +# The docker image built from this Dockerfile is intended only to run the test +# suite and to build the documentation. Installation of this project should be +# performed via pip. +FROM registry.gitlab.developers.cam.ac.uk/uis/devops/infra/dockerimages/python:3.6-alpine +ADD ./ /usr/src/app/ +WORKDIR /usr/src/app +RUN pip install tox && pip install -e . diff --git a/README.md b/README.md index 0addc29..6382cbc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # University of Cambridge Salary On-cost Calculation -[](https://circleci.com/gh/uisautomation/pidash-ucamstaffoncosts) - This repository contains a Python module which calculates total on-costs associated with employing staff members in the University of Cambridge. The total on-costs value calculated by this module reflects the expenditure which diff --git a/tox.ini b/tox.ini index 614741d..2f84c57 100644 --- a/tox.ini +++ b/tox.ini @@ -16,11 +16,14 @@ deps= passenv= # Allow people to override the coverage report location should they so wish. COVERAGE_FILE +# Location of the coverage.xml file + COVERAGE_XML_FILE whitelist_externals=mkdir commands= - mkdir -p "{[_vars]build_root}/test-results/nosetests" - coverage run -m nose --with-doctest --with-xunit --xunit-file={[_vars]build_root}/test-results/nosetests/results.xml {posargs} + mkdir -p "{[_vars]build_root}/{envname}" + coverage run -m nose --with-doctest --with-xunit --xunit-file={[_vars]build_root}/{envname}/junit.xml {posargs} coverage html --directory {[_vars]build_root}/htmlcov/ + coverage xml -o {env:COVERAGE_XML_FILE:{[_vars]build_root}/{envname}/coverage.xml} coverage report # Build documentation -- GitLab