/
.gitlab-ci.yml
122 lines (109 loc) · 2.87 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
122
# Debian Buster base image with python 3.5:
#
image: python:3.5-buster
stages:
- test
- post
- deploy
# Templates and global variables.
#
variables:
BGD: "${CI_PROJECT_DIR}/env/bin/bgd"
PYTHON: "${CI_PROJECT_DIR}/env/bin/python"
TOOLS: "${CI_PROJECT_DIR}/env/bin"
.venv-template:
before_script: &install-base
- python3 -m venv env # Creates a virtual environment
cache:
paths:
- .pip
# Test stage, build and test the code.
#
unit-tests:
stage: test
extends: .venv-template
script:
- ${PYTHON} -m pip --cache-dir=.pip install --editable ".[auth,tests]"
- ${PYTHON} setup.py test
after_script:
- mkdir -p coverage/
- cp .coverage coverage/coverage."${CI_JOB_NAME}"
variables:
PYTEST_ADDOPTS: "--color=yes"
artifacts:
paths:
- coverage/
dummy-tests:
stage: test
extends: .venv-template
script:
- ${PYTHON} -m pip --cache-dir=.pip install --editable "."
- ${BGD} server start data/config/default.conf &
- sleep 5 # Allows server to boot
- ${BGD} bot dummy &
- ${BGD} cas upload-dummy
- ${BGD} execute request-dummy --wait-for-completion
e2e-tests:
stage: test
image: registry.gitlab.com/buildgrid/buildbox/buildbox-e2e:latest
script:
- BUILDGRID_SOURCE_ROOT=`pwd` end-to-end-test.sh
# Post-build stage, documentation, coverage report...
#
documentation:
stage: test
interruptible: true
extends: .venv-template
script:
- ${PYTHON} -m pip --cache-dir=.pip install --editable ".[docs]"
- apt-get update && apt-get install -y graphviz
- PATH="${PATH}:${TOOLS}" make -C docs html
after_script:
- mkdir -p documentation/
- cp -a docs/build/html/. documentation/
artifacts:
paths:
- documentation/
coverage:
stage: post
extends: .venv-template
dependencies:
- unit-tests
coverage: '/TOTAL +\d+ +\d+ +(\d+\.\d+)%/'
script:
- ${PYTHON} -m pip --cache-dir=.pip install coverage
- cd coverage/ && ls -l .
- ${PYTHON} -m coverage combine --rcfile=../.coveragerc --append coverage.*
- ${PYTHON} -m coverage html --rcfile=../.coveragerc --directory .
- ${PYTHON} -m coverage report --rcfile=../.coveragerc --show-missing
artifacts:
paths:
- coverage/
# Deployement stage, only for merges which land on master branch.
#
pages:
stage: deploy
dependencies:
- coverage
- documentation
script:
- mkdir -p public/coverage/
- cp -a coverage/* public/coverage/
- ls -la public/coverage/
- cp -a documentation/* public/
- ls -la public/
artifacts:
paths:
- public/
only:
- master
triggers:
stage: deploy
before_script:
- apt-get update && apt-get install -y curl
script:
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://gitlab.com/api/v4/projects/buildgrid%2Fbuildbox%2Fbuildbox-e2e/trigger/pipeline
variables:
GIT_STRATEGY: none
only:
- master