/
.gitlab-ci.yml
121 lines (107 loc) · 3.4 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
stages:
- image
- analysis
- test
- coverage
########################################################################################################################
# Docker
.image: &image
stage: image
before_script:
- docker info
script:
# Login to GitLab container registry https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#using-the-gitlab-container-registry
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
# Build image using Docker caching, see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#making-docker-in-docker-builds-faster-with-docker-layer-caching
- docker pull "$IMAGE_TAG" || true
- docker build --cache-from "$IMAGE_TAG" -t "$IMAGE_TAG" "docker/$IMAGE_NAME"
- docker push "$IMAGE_TAG"
tags:
- dind
image:ubuntu:xenial:
<<: *image
variables:
IMAGE_NAME: ubuntu:xenial
IMAGE_TAG: $CI_REGISTRY_IMAGE/$IMAGE_NAME
image:ubuntu:bionic:
<<: *image
variables:
IMAGE_NAME: ubuntu:bionic
IMAGE_TAG: $CI_REGISTRY_IMAGE/$IMAGE_NAME
########################################################################################################################
# Basic declarations
.ubuntu-xenial: &ubuntu-xenial
image: "$CI_REGISTRY/$CI_PROJECT_PATH/ubuntu:xenial"
.ubuntu-bionic: &ubuntu-bionic
image: "$CI_REGISTRY/$CI_PROJECT_PATH/ubuntu:bionic"
.install-dependencies: &install-dependencies
before_script:
- pip3 list
# Install package dependencies
- cat requirements.txt
- pip3 install -r requirements.txt $EXTRA_REQUIREMENTS
- pip3 list
.test: &test
<<: *install-dependencies
script:
- mkdir coverage
- make test-coverage
artifacts:
expire_in: 1d
paths:
- coverage/
variables:
COVERAGE_FILE: "coverage/.coverage.$CI_BUILD_ID"
EXTRA_REQUIREMENTS: "-r requirements-dev.txt coverage"
########################################################################################################################
# Individual jobs
isort:
<<: *ubuntu-bionic
stage: analysis
before_script:
- pip3 install isort
- pip3 list
script: "make check-isort"
flake8:
<<: *ubuntu-bionic
stage: analysis
before_script:
- pip3 install flake8
- pip3 list
script: "make check-flake8"
pydocstyle:
<<: *ubuntu-bionic
stage: analysis
before_script:
- pip3 install pydocstyle
- pip3 list
script: "make check-doc"
licensing:
<<: *ubuntu-bionic
stage: analysis
before_script:
# Set up SSH key for access to gitlab repositories
- install -m 700 -d $HOME/.ssh
- install -m 600 $SRC_DIR/{id_rsa,id_rsa.pub,known_hosts} $HOME/.ssh/
# Clone the licence check
- git clone git@gitlab.office.nic.cz:internal-tools/license-check.git --single-branch --depth 1
script:
- ./license-check/license-check.sh -v
variables:
SRC_DIR: /usr/local/env
test:xenial:
<<: *test
<<: *ubuntu-xenial
test:bionic:
<<: *test
<<: *ubuntu-bionic
coverage-report:
<<: *ubuntu-bionic
stage: coverage
before_script:
- pip3 install coverage
- pip3 list
script:
- coverage3 combine coverage/
- coverage3 report --include=tests.py --fail-under=100
- coverage3 report --omit=tests.py