Skip to content

Commit e5b761b

Browse files
committed
ci: Parallelize with workflows
1 parent cfa713e commit e5b761b

File tree

6 files changed

+139
-131
lines changed

6 files changed

+139
-131
lines changed

.circleci/config.yml

Lines changed: 124 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,163 @@
11
# Python CircleCI 2.0 configuration file
22
# vi: et:ts=2:sw=2
3-
#
4-
# Check https://circleci.com/docs/2.0/language-python/ for more details
5-
#
6-
version: 2
3+
4+
version: 2.0
5+
76
jobs:
8-
build:
7+
python_27:
98
docker:
10-
- image: circleci/python:3-stretch
9+
- image: circleci/python:2.7.17
10+
environment: &env
11+
VERSION: 2.16.5
12+
C_INCLUDE_PATH: /usr/local/include:/usr/include
13+
LD_LIBRARY_PATH: /usr/local/lib:/usr/lib
1114
working_directory: ~/python-mbedtls
1215
steps:
1316
- checkout
14-
15-
- run:
16-
name: Downgrade openssl for Python 3.4
17+
- run: &deps
18+
name: Install dependencies
1719
command: |
18-
sudo apt-get update
19-
sudo apt-get install libssl1.0-dev
20-
20+
command -v python
21+
sudo python -m pip install tox
22+
- run: &mbedtls
23+
name: Install mbedtls
24+
command: |
25+
sudo ./scripts/download-mbedtls.sh $VERSION /usr/local/src
26+
sudo ./scripts/install-mbedtls.sh /usr/local/src
2127
- run:
22-
name: Install pyenv
28+
name: Run tests
2329
command: |
24-
git clone https://github.com/pyenv/pyenv.git $HOME/python-mbedtls/.pyenv
25-
cat << 'EOF' >> $BASH_ENV
26-
export PYENV_ROOT="$HOME/python-mbedtls/.pyenv"
27-
export PATH="$PYENV_ROOT/bin:$PATH"
28-
EOF
29-
30-
- restore_cache:
31-
key: py27-2.7.16-v0-{{ arch }}
32-
- restore_cache:
33-
key: py34-3.4.10-v0-{{ arch }}
34-
- restore_cache:
35-
key: py35-3.5.9-v0-{{ arch }}
36-
- restore_cache:
37-
key: py36-3.6.10-v0-{{ arch }}
38-
- restore_cache:
39-
key: py37-3.7.6-v0-{{ arch }}
40-
- restore_cache:
41-
key: py38-3.8.1-v0-{{ arch }}
30+
tox -e py27
31+
- run: &keep_logs
32+
name: Save logs
33+
when: on_fail
34+
command: |
35+
mkdir -p out/log
36+
cp .tox/*/log/py*.log out/log || true
37+
- store_artifacts: &artifacts
38+
path: out
39+
destination: artifacts
4240

41+
python_34:
42+
docker:
43+
- image: circleci/python:3.4.10
44+
environment: *env
45+
working_directory: ~/python-mbedtls
46+
steps:
47+
- checkout
48+
- run: *deps
49+
- run: *mbedtls
4350
- run:
44-
name: Install Python versions
51+
name: Run tests
4552
command: |
46-
eval "$(pyenv init -)"
47-
test -d ".pyenv/versions/2.7.16" || pyenv install 2.7.16
48-
test -d ".pyenv/versions/3.4.10" || pyenv install 3.4.10
49-
test -d ".pyenv/versions/3.5.9" || pyenv install 3.5.9
50-
test -d ".pyenv/versions/3.6.10" || pyenv install 3.6.10
51-
test -d ".pyenv/versions/3.7.6" || pyenv install 3.7.6
52-
test -d ".pyenv/versions/3.8.1" || pyenv install 3.8.1
53-
54-
- save_cache:
55-
key: py27-2.7.16-v0-{{ arch }}
56-
paths:
57-
- .pyenv/versions/2.7.16
58-
- save_cache:
59-
key: py34-3.4.10-v0-{{ arch }}
60-
paths:
61-
- .pyenv/versions/3.4.10
62-
- save_cache:
63-
key: py35-3.5.9-v0-{{ arch }}
64-
paths:
65-
- .pyenv/versions/3.5.9
66-
- save_cache:
67-
key: py36-3.6.10-v0-{{ arch }}
68-
paths:
69-
- .pyenv/versions/3.6.10
70-
- save_cache:
71-
key: py37-3.7.6-v0-{{ arch }}
72-
paths:
73-
- .pyenv/versions/3.7.6
74-
- save_cache:
75-
key: py38-3.8.1-v0-{{ arch }}
76-
paths:
77-
- .pyenv/versions/3.8.1
53+
tox -e py34
54+
- run: *keep_logs
55+
- store_artifacts: *artifacts
7856

57+
python_35:
58+
docker:
59+
- image: circleci/python:3.5.9
60+
environment: *env
61+
working_directory: ~/python-mbedtls
62+
steps:
63+
- checkout
64+
- run: *deps
65+
- run: *mbedtls
7966
- run:
80-
name: Install mbedtls
67+
name: Run tests
8168
command: |
82-
VERSION=2.16.5
83-
DESTDIR=$HOME/lib/$VERSION
84-
sudo apt-get install cmake
85-
sudo ./scripts/download-mbedtls.sh $VERSION $DESTDIR/src
86-
sudo ./scripts/install-mbedtls.sh $DESTDIR/src $DESTDIR
87-
cat << EOF >> $BASH_ENV
88-
export VERSION=$VERSION
89-
export DESTDIR=$DESTDIR
90-
export LD_LIBRARY_PATH=$DESTDIR/lib
91-
export C_INCLUDE_PATH=$DESTDIR/include
92-
export TOX_PARALLEL_NO_SPINNER=1
93-
EOF
69+
tox -e py35
70+
- run: *keep_logs
71+
- store_artifacts: *artifacts
9472

73+
python_36:
74+
docker:
75+
- image: circleci/python:3.6.10
76+
environment: *env
77+
working_directory: ~/python-mbedtls
78+
steps:
79+
- checkout
80+
- run: *deps
81+
- run: *mbedtls
9582
- run:
96-
name: Create environment
83+
name: Run tests
9784
command: |
98-
python -m venv venv
99-
. venv/bin/activate
100-
pip install -r requirements/circleci.txt
85+
tox -e py36
86+
- run: *keep_logs
87+
- store_artifacts: *artifacts
10188

89+
python_37:
90+
docker:
91+
- image: circleci/python:3.7.6
92+
environment: *env
93+
working_directory: ~/python-mbedtls
94+
steps:
95+
- checkout
96+
- run: *deps
97+
- run: *mbedtls
10298
- run:
10399
name: Run tests
104100
command: |
105-
eval "$(pyenv init -)"
106-
pyenv shell 2.7.16 3.4.10 3.5.9 3.6.10 3.7.6 3.8.1
107-
. venv/bin/activate
108-
tox --parallel auto -e py27,py34,py35,py36,py37-coveralls,py38
101+
tox -e py37-coveralls
102+
- run:
103+
name: Run doctest
104+
command: |
105+
sudo python -m pip install tox-run-command
109106
tox -e py37 --run-command "{envpython} -m doctest {toxinidir}/README.rst"
110-
111107
- run:
112108
name: Build API documentation
113109
command: |
114110
eval "$(pyenv init -)"
115-
pyenv shell 3.7.6
116-
. venv/bin/activate
117111
tox -e py37-docs
118-
119112
- run:
120113
name: Save docs
121114
when: on_success
122115
command: |
123116
mkdir -p out/
124117
cp -R .tox/docs_out out/docs
118+
- run: *keep_logs
119+
- store_artifacts: *artifacts
120+
121+
python_38:
122+
docker:
123+
- image: circleci/python:3.8.2
124+
environment: *env
125+
working_directory: ~/python-mbedtls
126+
steps:
127+
- checkout
128+
- run: *deps
129+
- run: *mbedtls
130+
- run:
131+
name: Run tests
132+
command: |
133+
tox -e py38
134+
- run: *keep_logs
135+
- store_artifacts: *artifacts
125136

137+
python_39:
138+
docker:
139+
- image: circleci/python:3.9-rc
140+
environment: *env
141+
working_directory: ~/python-mbedtls
142+
steps:
143+
- checkout
144+
- run: *deps
145+
- run: *mbedtls
126146
- run:
127-
name: Save logs
128-
when: on_fail
147+
name: Run tests
129148
command: |
130-
mkdir -p out/log
131-
cp .tox/*/log/py*.log out/log || true
149+
tox -e py39
150+
- run: *keep_logs
151+
- store_artifacts: *artifacts
132152

133-
- store_artifacts:
134-
path: out
135-
destination: artifacts
153+
workflows:
154+
version: 2
155+
build:
156+
jobs:
157+
- python_39
158+
- python_38
159+
# - python_37 # ok
160+
# - python_36 # ok
161+
# - python_35 # ok
162+
# - python_34 # ok
163+
# - python_27 # ok

requirements/circleci.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements/circleci.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

scripts/download-mbedtls.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
set -ex
55

6-
if [ $# -eq 1 ] || [ $# -eq 2 ]; then
6+
if [ $# -eq 2 ]; then
77
version="$1"
8-
destdir="${2:-/usr/local/src}"
8+
destdir="$2"
99
case $destdir in
1010
/*) ;;
1111
*) destdir="$PWD/$destdir";;
@@ -14,7 +14,7 @@ else
1414
cat <<-EOF
1515
1616
usage:
17-
$0 VERSION [DESTDIR]
17+
$0 VERSION DESTDIR
1818
1919
Download a local copy mbedtls at VERSION.
2020

scripts/install-mbedtls.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33

44
set -ex
55

6-
if [ $# -le 1 ]; then
6+
if [ $# -eq 1 ] || [ $# -eq 2 ]; then
7+
srcdir="$1"
8+
destdir="${2:-/usr/local}"
9+
case $destdir in
10+
/*) ;;
11+
*) destdir="$PWD/$destdir";;
12+
esac
13+
else
714
cat <<-EOF
815
916
usage:
1017
$0 SRCDIR [DESTDIR]
11-
18+
1219
Install a mbedtls from the sources in SRCDIR to DESTDIR.
1320
1421
EOF
1522
exit 1
16-
else
17-
srcdir="$1"
18-
destdir="${2:-/usr/local}"
19-
case $destdir in
20-
/*) ;;
21-
*) destdir="$PWD/$destdir";;
22-
esac
2323
fi
2424

2525

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ basepython =
99
py36: python3.6
1010
py37: python3.7
1111
py38: python3.8
12+
py39: python3.9
1213
envdir =
1314
py27: {toxworkdir}/py27
1415
py34: {toxworkdir}/py34
1516
py35: {toxworkdir}/py35
1617
py36: {toxworkdir}/py36
1718
py37: {toxworkdir}/py37
1819
py38: {toxworkdir}/py38
20+
py39: {toxworkdir}/py39
1921
deps =
2022
-r requirements.txt
2123
-r requirements/tests.txt
@@ -27,7 +29,7 @@ passenv =
2729
C_INCLUDE_PATH
2830
commands =
2931
py{27,34,35}: {envpython} -m pytest --basetemp={envtmpdir} {posargs}
30-
py{36,37,38}: {envpython} -m pytest --basetemp={envtmpdir} --black {posargs}
32+
py{36,37,38,39}: {envpython} -m pytest --basetemp={envtmpdir} --black {posargs}
3133

3234
[testenv:py37-coverage]
3335
setenv = PYTHONPATH = {toxinidir}/src

0 commit comments

Comments
 (0)