This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
185 lines (152 loc) · 3.93 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Gitlab CI/CD Driver Script
#
# Useful Links:
# - CI/CD Lint : https://gitlab-ex.sandia.gov/trilinos-devops-consolidation/code/ConfigParserEnhanced/-/ci/lint
# - Gitlab YAML: https://docs.gitlab.com/ee/ci/yaml/
#
# Set up a global cache to pass info 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 pipeline stages
stages:
- prepare
- test
- deploy
- examples
- documentation
- publish
- cleanup
# Script to run 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 "-----"
# Script to run after every job
after_script:
- |-
if [ ! -z ${VIRTUAL_ENV} ]; then
deactivate
fi
# Create venv, install requirements, save cache
install_requirements:
stage: prepare
timeout: 10m
#artifacts:
# untracked: true
before_script:
- python3 -m venv venv-clean-python
cache:
<<: *global_cache
when: on_success
script:
#- echo "CI_COMMIT_REF_SLUG = ${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
- source venv-clean-python/bin/activate
# Remove configparserenhanced if it's been installed
- python3 -m pip uninstall -y configparserenhanced
# Pull required packages
- python3 -m pip install wheel -r requirements.txt -r requirements-test.txt -r doc/requirements.txt
# Execute unit tests
pytest:
stage: test
timeout: 5m
script:
- python3 -m pytest --cov=configparserenhanced --cov-report=term --cov-report=html --cov-config=.coveragerc
coverage: '/TOTAL\s*\d+\s+\d+\s+\d+\s+\d+\s+(\d+%)/'
cache:
<<: *global_cache
# Test distribution building
build_dist:
stage: deploy
timeout: 5m
cache:
<<: *global_cache
policy: pull
script:
- python3 -m pip wheel --no-deps -w dist .
artifacts:
name: "configparserenhanced-dist"
paths:
- dist/configparserenhanced*.whl
expire_in: 6 weeks
# Test installation of package
install:
stage: deploy
timeout: 5m
cache:
<<: *global_cache
script:
- python3 -m pip install .
# Test example(s)
examples:
stage: examples
timeout: 5m
cache:
<<: *global_cache
policy: pull
script:
- cd examples
- python3 ./ConfigParserEnhanced-example-01.py
# Generate documentation
sphinx-documentation:
stage: documentation
timeout: 5m
cache:
<<: *global_cache
script:
- cd doc/
- bash make_html_docs.sh
# Publish coverage data (if on main branch)
publish coverage:
stage: publish
timeout: 5m
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
cache:
<<: *global_cache
policy: pull
script:
- rm -rf /home/josbrau/html_files/ConfigParserEnhanced/coverage
- mkdir -p /home/josbrau/html_files/ConfigParserEnhanced/coverage
- mv tests/htmlcov/* /home/josbrau/html_files/ConfigParserEnhanced/coverage/
# Publish documentation (if on main branch)
publish docs:
stage: publish
timeout: 5m
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
cache:
<<: *global_cache
policy: pull
script:
- cd doc/
- bash make_html_docs.sh
- rm -rf /home/josbrau/html_files/ConfigParserEnhanced/doc
- mkdir -p /home/josbrau/html_files/ConfigParserEnhanced/doc
- mv html/* /home/josbrau/html_files/ConfigParserEnhanced/doc/
# Test uninstall from venv works
uninstall:
stage: cleanup
timeout: 5m
cache:
<<: *global_cache
script:
- python3 -m pip uninstall -y configparserenhanced
# - python3 -m pip uninstall -y -r requirements.txt
# >>> In a virtual environment, this won't work if there are no entries in
# >>> the requirements.txt file.