Skip to content

Commit ddb9636

Browse files
committed
wip
1 parent 4f0bb5a commit ddb9636

File tree

1 file changed

+187
-123
lines changed

1 file changed

+187
-123
lines changed

.circleci/config.yml

Lines changed: 187 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
version: 2.1
22

3+
orbs:
4+
ocean: dwave/[email protected]
5+
6+
environment:
7+
PIP_PROGRESS_BAR: 'off'
8+
39
jobs:
410
test-linux:
511
parameters:
@@ -8,60 +14,72 @@ jobs:
814
dimod-version:
915
type: string
1016

11-
docker:
12-
- image: circleci/python:<< parameters.python-version >>
17+
executor:
18+
name: ocean/python
19+
python-version: << parameters.python-version >>
1320

1421
steps:
1522
- checkout
1623

17-
- restore_cache: &restore-cache-env
18-
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
19-
20-
- run: &create-virtualenv
21-
name: Create virtual environment
22-
command: |
23-
python -m venv env
24-
25-
- run: &install-requirements
26-
name: Install requirements
27-
command: |
28-
. env/bin/activate
29-
pip install -U pip
30-
pip install -r requirements.txt -r tests/requirements.txt
31-
pip install wheel twine
32-
33-
- run:
34-
name: Install appropriate dimod version
35-
command: |
36-
. env/bin/activate
37-
if [[ "<< parameters.dimod-version >>" ]]; then
38-
pip install 'dimod<< parameters.dimod-version >>'
39-
else
40-
pip uninstall dimod -y
41-
fi
42-
43-
- save_cache: &save-cache-env
44-
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
45-
paths:
46-
- env
47-
48-
- run: &build-package
49-
name: Build package
50-
command: env/bin/python setup.py sdist bdist_wheel
51-
52-
- run: &install-package
53-
name: Install package
54-
command: env/bin/pip install .
55-
56-
- run: &run-python-tests
57-
name: Run Python tests
58-
command: env/bin/coverage run -m unittest discover
59-
60-
- run: &upload-python-code-coverage
61-
name: Upload code coverage
62-
command: |
63-
. env/bin/activate
64-
codecov # calls `coverage xml`, so we must activate venv
24+
- ocean/pip-install:
25+
requirements: requirements.txt tests/requirements.txt
26+
packages: .
27+
28+
- ocean/pip-install:
29+
cache: false
30+
packages: dimod<< parameters.dimod-version >>
31+
32+
- ocean/coverage-run-unittest:
33+
upload-coverage: true
34+
35+
# - restore_cache: &restore-cache-env
36+
# key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
37+
38+
# - run: &create-virtualenv
39+
# name: Create virtual environment
40+
# command: |
41+
# python -m venv env
42+
43+
# - run: &install-requirements
44+
# name: Install requirements
45+
# command: |
46+
# . env/bin/activate
47+
# pip install -U pip
48+
# pip install -r requirements.txt -r tests/requirements.txt
49+
# pip install wheel twine
50+
51+
# - run:
52+
# name: Install appropriate dimod version
53+
# command: |
54+
# . env/bin/activate
55+
# if [[ "<< parameters.dimod-version >>" ]]; then
56+
# pip install 'dimod<< parameters.dimod-version >>'
57+
# else
58+
# pip uninstall dimod -y
59+
# fi
60+
61+
# - save_cache: &save-cache-env
62+
# key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
63+
# paths:
64+
# - env
65+
66+
# - run: &build-package
67+
# name: Build package
68+
# command: env/bin/python setup.py sdist bdist_wheel
69+
70+
# - run: &install-package
71+
# name: Install package
72+
# command: env/bin/pip install .
73+
74+
# - run: &run-python-tests
75+
# name: Run Python tests
76+
# command: env/bin/coverage run -m unittest discover
77+
78+
# - run: &upload-python-code-coverage
79+
# name: Upload code coverage
80+
# command: |
81+
# . env/bin/activate
82+
# codecov # calls `coverage xml`, so we must activate venv
6583

6684
test-macos:
6785
parameters:
@@ -76,83 +94,99 @@ jobs:
7694
steps:
7795
- checkout
7896

79-
# install `python-version` and cache it
80-
- run: &brew-install-pyenv
81-
name: Install pyenv
82-
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pyenv
83-
84-
- restore_cache: &restore-cache-pyenv
85-
keys:
86-
- v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-<< parameters.xcode >>
87-
88-
- when:
89-
# backport https://github.com/python/cpython/pull/21113 to support macOS 11 when building py36
90-
# see also: https://github.com/pyenv/pyenv/issues/1737.
91-
condition:
92-
matches:
93-
pattern: "^3\\.6.*$"
94-
value: << parameters.python-version >>
95-
steps:
96-
- run:
97-
name: Install Python 3.6 with a patch for macOS 11
98-
command: |
99-
curl -LO https://github.com/python/cpython/commit/8ea6353.patch
100-
pyenv install << parameters.python-version>> -s -p < 8ea6353.patch
101-
102-
- run: &pyenv-install-python
103-
name: Install python
104-
command: pyenv install << parameters.python-version >> -s
105-
106-
- run: &pyenv-set-system-python
107-
name: Set system python
108-
command: |
109-
echo -e '\n\n# Initialize pyenv' >> ~/.bash_profile
110-
echo 'eval "$(pyenv init --path 2>/dev/null || true)"' >> ~/.bash_profile
111-
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
112-
pyenv global << parameters.python-version >>
97+
- ocean/brew-install-pyenv
98+
99+
- ocean/pyenv-install-python:
100+
python-version: << parameters.python-version >>
101+
cache-key-prefix: << parameters.xcode >>
102+
103+
- ocean/pip-install:
104+
requirements: requirements.txt tests/requirements.txt
105+
packages: .
106+
107+
- ocean/coverage-run-unittest
108+
109+
# # install `python-version` and cache it
110+
# - run: &brew-install-pyenv
111+
# name: Install pyenv
112+
# command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pyenv
113113

114-
- save_cache: &save-cache-pyenv
115-
key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-<< parameters.xcode >>
116-
paths:
117-
- ~/.pyenv
114+
# - restore_cache: &restore-cache-pyenv
115+
# keys:
116+
# - v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-<< parameters.xcode >>
118117

119-
# install dependencies and cache them
120-
- restore_cache: *restore-cache-env
118+
# - when:
119+
# # backport https://github.com/python/cpython/pull/21113 to support macOS 11 when building py36
120+
# # see also: https://github.com/pyenv/pyenv/issues/1737.
121+
# condition:
122+
# matches:
123+
# pattern: "^3\\.6.*$"
124+
# value: << parameters.python-version >>
125+
# steps:
126+
# - run:
127+
# name: Install Python 3.6 with a patch for macOS 11
128+
# command: |
129+
# curl -LO https://github.com/python/cpython/commit/8ea6353.patch
130+
# pyenv install << parameters.python-version>> -s -p < 8ea6353.patch
121131

122-
- run: *create-virtualenv
132+
# - run: &pyenv-install-python
133+
# name: Install python
134+
# command: pyenv install << parameters.python-version >> -s
123135

124-
- run: *install-requirements
136+
# - run: &pyenv-set-system-python
137+
# name: Set system python
138+
# command: |
139+
# echo -e '\n\n# Initialize pyenv' >> ~/.bash_profile
140+
# echo 'eval "$(pyenv init --path 2>/dev/null || true)"' >> ~/.bash_profile
141+
# echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
142+
# pyenv global << parameters.python-version >>
125143

126-
- save_cache: *save-cache-env
144+
# - save_cache: &save-cache-pyenv
145+
# key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-<< parameters.xcode >>
146+
# paths:
147+
# - ~/.pyenv
127148

128-
- run: *install-package
149+
# # install dependencies and cache them
150+
# - restore_cache: *restore-cache-env
129151

130-
- run: *run-python-tests
152+
# - run: *create-virtualenv
153+
154+
# - run: *install-requirements
155+
156+
# - save_cache: *save-cache-env
157+
158+
# - run: *install-package
159+
160+
# - run: *run-python-tests
131161

132162
test-docs:
133-
docker:
134-
- image: circleci/python:3.7
163+
executor:
164+
name: ocean/python
165+
python-version: "3.7"
135166

136167
steps:
137168
- checkout
138169

139-
- restore_cache:
140-
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "docs/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
170+
- ocean/pip-install:
171+
requirements: requirements.txt tests/requirements.txt docs/requirements.txt
141172

142-
- run: *create-virtualenv
173+
# - restore_cache:
174+
# key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "docs/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
143175

144-
- run: *install-requirements
176+
# - run: *create-virtualenv
145177

146-
- run:
147-
name: Install docs requirements
148-
command: env/bin/pip install -r docs/requirements.txt
178+
# - run: *install-requirements
149179

150-
- save_cache:
151-
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "docs/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
152-
paths:
153-
- env
180+
# - run:
181+
# name: Install docs requirements
182+
# command: env/bin/pip install -r docs/requirements.txt
154183

155-
- run: *install-package
184+
# - save_cache:
185+
# key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "docs/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
186+
# paths:
187+
# - env
188+
189+
# - run: *install-package
156190

157191
- run:
158192
name: Build docs
@@ -175,29 +209,52 @@ jobs:
175209
. env/bin/activate
176210
make -C docs/ linkcheck
177211
178-
pypi-deploy:
179-
docker:
180-
- image: circleci/python:3.9
212+
build-dist:
213+
executor:
214+
name: ocean/python
215+
python-version: "3.9"
181216

182217
steps:
183218
- checkout
184219

185-
- restore_cache: *restore-cache-env
220+
- ocean/pip-install:
221+
requirements: requirements.txt
222+
packages: wheel
223+
cache: false
186224

187-
- run: *create-virtualenv
225+
- ocean/build-dist:
226+
dist-type: sdist bdist_wheel
188227

189-
- run: *install-requirements
228+
- store_artifacts:
229+
path: dist
190230

191-
- save_cache: *save-cache-env
231+
- persist_to_workspace:
232+
root: dist
233+
paths: .
192234

193-
- run: *build-package
235+
# pypi-deploy:
236+
# docker:
237+
# - image: circleci/python:3.9
194238

195-
- store_artifacts:
196-
path: ./dist
239+
# steps:
240+
# - checkout
197241

198-
- run:
199-
name: Upload package to PyPI
200-
command: env/bin/twine upload -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" --skip-existing ./dist/*
242+
# - restore_cache: *restore-cache-env
243+
244+
# - run: *create-virtualenv
245+
246+
# - run: *install-requirements
247+
248+
# - save_cache: *save-cache-env
249+
250+
# - run: *build-package
251+
252+
# - store_artifacts:
253+
# path: ./dist
254+
255+
# - run:
256+
# name: Upload package to PyPI
257+
# command: env/bin/twine upload -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" --skip-existing ./dist/*
201258

202259

203260
workflows:
@@ -227,7 +284,14 @@ workflows:
227284

228285
deploy:
229286
jobs:
230-
- pypi-deploy:
287+
- build-dist:
288+
filters: &always-run # required because it's indirectly required by the deploy job that runs on tags only
289+
tags:
290+
only: /.*/
291+
292+
- ocean/pypi-deploy:
293+
requires:
294+
- build-dist
231295
filters:
232296
tags:
233297
only: /^[0-9]+(\.[0-9]+)*((\.dev|rc)([0-9]+)?)?$/

0 commit comments

Comments
 (0)