-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
161 lines (135 loc) · 3.25 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# This file controls the GitLab CI pipeline for the `ShellLogger`
# project. See here for the keyword reference:
# https://docs.gitlab.com/ee/ci/yaml/.
#image: alpine:latest
#variables:
#HTTP_PROXY: http://wwwproxy.sandia.gov:80
#HTTPS_PROXY: http://wwwproxy.sandia.gov:80
#NO_PROXY: 127.0.0.1,localhost,.sandia.gov,/var/run/docker.sock
# Set up a global cache to pass information across stages.
cache: &global_cache
key: "${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
paths:
- tests/htmlcov/
- venv-clean-python/
policy: pull-push
# Set up the pipeline stages.
stages:
- prepare
- test
- deploy
- examples
- documentation
- publish
- finish
# Run this before every job.
before_script:
- |-
export LSB_RELEASE=$(which lsb_release)
if [ -x ${LSB_RELEASE} ]; then
${LSB_RELEASE} -a
fi
- |-
if [ -d "venv-clean-python" ]; then
source venv-clean-python/bin/activate
else
echo "Virtual Environment 'venv-clean-python' was not found"
exit 1
fi
echo "-----"
echo "VIRTUAL_ENV = ${VIRTUAL_ENV:?}"
echo "-----"
# Run this after every job.
after_script:
- |-
if [ ! -z ${VIRTUAL_ENV} ]; then
deactivate
fi
# Create the virtual environment, install the requirements, and save the
# environment to the cache.
Install Requirements:
stage: prepare
timeout: 10m
before_script:
- python3 -m venv venv-clean-python
cache:
<<: *global_cache
when: on_success
script:
- source venv-clean-python/bin/activate
# Remove shelllogger if it's been installed.
- python3 -m pip uninstall -y shelllogger
# Install required packages.
- python3 -m pip install wheel
-r requirements.txt
-r tests/requirements.txt
-r doc/requirements.txt
# Execute the unit tests.
pytest:
stage: test
needs: ["Install Requirements"]
timeout: 5m
cache:
<<: *global_cache
script:
- python3 -m pytest
--cov=src.shelllogger
--cov-config=.coveragerc
--cov-report=html
--cov-report=term
--cov-report=xml
--full-trace
tests/
coverage: '/TOTAL\s*[0-9]*\s*[0-9]*\s*[0-9]*\s*[0-9]*\s*(\d+%)/'
artifacts:
reports:
cobertura: tests/coverage.xml
junit: tests/coverage.xml
# Test building a distribution.
Build Distribution:
stage: deploy
needs: ["Install Requirements"]
timeout: 5m
cache:
<<: *global_cache
policy: pull
script:
- python3 -m pip wheel --no-deps -w dist .
artifacts:
name: "shelllogger-dist"
paths:
- dist/shelllogger*.whl
expire_in: 6 weeks
# Test installation of the package.
Install Package:
stage: deploy
needs: ["Install Requirements"]
timeout: 5m
cache:
<<: *global_cache
script:
- python3 -m pip install .
# Publish coverage data (if on the main branch).
Pages:
stage: publish
needs: ["pytest"]
timeout: 5m
cache:
<<: *global_cache
policy: pull
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
script:
- mkdir -p public
- mv tests/htmlcov public/.
artifacts:
paths:
- public
# Test that uninstalling from a virtual environment works.
Uninstall Package:
stage: finish
timeout: 5m
cache:
<<: *global_cache
script:
- python3 -m pip uninstall -y shelllogger