/
config.yml
263 lines (237 loc) · 7 KB
/
config.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
version: 2
jobs:
build:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Install setup.py"
command: |
python3.7 -m venv .venv;
. .venv/bin/activate
pip install -U pip
pip install -e .[tests]
- save_cache: &save_cache
key: v5-{{ .Branch }}-{{ checksum "setup.py" }}
paths:
- ~/project/.venv
- ~/.cache/pip
check_linting:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Check Linting"
command: |
. .venv/bin/activate
flake8 vortexasdk tests docs
check_types:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Check Types"
command: |
. .venv/bin/activate
mypy vortexasdk tests docs
check_formatting:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Check Formatting"
command: |
. .venv/bin/activate
black --check vortexasdk tests
test-documentation:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Run doctests"
command: |
. .venv/bin/activate
# This should be done in tox, but i can't work out how to run doctests in tox hence we're also running it here for now.
pytest -v --doctest-modules --ignore=tests
- run:
name: "Confirm that the check_setup script works"
command: |
. .venv/bin/activate
python -m vortexasdk.check_setup
- run:
name: "Build docs"
command: |
. .venv/bin/activate
mkdir -p ./_build/pydocmd/examples
python docs/autogen.py
pydocmd build
run-examples:
working_directory: ~/project
docker:
- image: cimg/python:3.7
resource_class: large
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Run all examples"
command: |
set -xe
. .venv/bin/activate
for f in docs/examples/*.py; do cp -v -- "$f" "$f-example.py"; done
cp docs/examples/*-example.py .
for f in *-example.py; do python "$f"; done
rm docs/examples/*-example.py
rm *-example.py
- run:
name: "Create mybinder virtual environment"
command: |
# mybinder currently does not install the extras_require in setup.py
# to replicate the mybinder environment, we install only the packages that mybinder installs
# For more details, see https://mybinder.readthedocs.io/en/latest/using/config_files.html#setup-py-install-python-packages
python3.7 -m venv .mybinder_venv;
. .mybinder_venv/bin/activate
pip install -U pip
pip install -e .[binder]
- run:
name: "Run all mybinder try-me-out notebooks"
command: |
. .mybinder_venv/bin/activate
jupyter nbconvert --to notebook --execute docs/examples/try_me_out/*.ipynb
- run:
name: "Run all mybinder academy notebooks"
command: |
. .mybinder_venv/bin/activate
jupyter nbconvert --to notebook --execute docs/examples/academy/*.ipynb
test:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Run all tests"
command: |
. .venv/bin/activate
pip install tox
tox --verbose
check-release-version:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- run:
name: "Check proposed release version is valid next semver"
command: |
. .venv/bin/activate
python scripts/validate_proposed_package_version.py
deploy:
working_directory: ~/project
docker:
- image: cimg/python:3.7
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v5-{{ .Branch }}-{{ checksum "setup.py" }}
- add_ssh_keys:
fingerprints:
- "b7:35:38:7a:76:62:44:82:28:93:77:f1:9c:f1:35:8c"
- run:
name: "Deploy new documentation to github pages"
command: |
. .venv/bin/activate
mkdir -p ./_build/pydocmd/examples
python docs/autogen.py
pydocmd build
pydocmd gh-deploy
- run:
name: "Deploy package to pypi"
command: |
. .venv/bin/activate
pip install -e .[deploy]
rm -rf dist
python setup.py sdist bdist_wheel
python -m twine upload -u $TWINE_USERNAME -p $TWINE_PASSWORD dist/*
- run:
name: "Tag the release with git"
command: |
. .venv/bin/activate
TAG=$(python setup.py --version)
git config --global user.email "developers@vortexa.com"
git config --global user.name "CircleCI"
git tag -a $TAG -m "New tag $TAG"
git push --tags
workflows:
version: 2
build-deploy:
jobs:
- build
- check_types:
requires:
- build
- check_linting:
requires:
- build
- check_formatting:
requires:
- build
- test:
requires:
- build
- test-documentation:
requires:
- build
- run-examples:
requires:
- build
- check-release-version:
requires:
- build
- deploy:
filters:
branches:
only:
- master
requires:
- test
- test-documentation
- run-examples
- check_types
- check_linting
- check_formatting
- check-release-version