Skip to content

Commit 4c83fc9

Browse files
committed
ci: Parallelize and speed up using workflows
- Partial support for Python 3.9 - Speed-up similar builds with ccache - Remove tox.ini file and tox dependencies
1 parent 24c2e22 commit 4c83fc9

File tree

10 files changed

+160
-222
lines changed

10 files changed

+160
-222
lines changed

.circleci/config.yml

+132-106
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,161 @@
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+
CC: /usr/lib/ccache/cc
13+
C_INCLUDE_PATH: /usr/local/include:/usr/include
14+
LD_LIBRARY_PATH: /usr/local/lib:/usr/lib
1115
working_directory: ~/python-mbedtls
12-
steps:
16+
steps: &steps
1317
- checkout
14-
15-
- run:
16-
name: Downgrade openssl for Python 3.4
18+
- run: &deps
19+
name: Install dependencies
1720
command: |
18-
sudo apt-get update
19-
sudo apt-get install libssl1.0-dev
20-
21-
- run:
22-
name: Install pyenv
21+
sudo apt-get -qq update
22+
sudo apt-get -qq install ccache
23+
echo "export PATH=/usr/lib/ccache:$PATH" >> $BASH_ENV
24+
- run: &python_version
25+
name: Display current Python
26+
command: python -VV | tee python_version
27+
- restore_cache: &restore_cache_ccache
28+
keys:
29+
- ccache--v0--{{ checksum "python_version" }}
30+
- run: &mbedtls
31+
name: Install mbedtls
2332
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
33+
sudo ./scripts/download-mbedtls.sh $VERSION /usr/local/src
34+
sudo ./scripts/install-mbedtls.sh /usr/local/src
35+
- run: &install
36+
name: Install library
37+
command: |
38+
python setup.py bdist_wheel
39+
python -m pip install --user --upgrade dist/*.whl
40+
- save_cache: &save_cache_ccache
41+
key: ccache--v0--{{ checksum "python_version" }}--{{ .BuildNum }}
42+
paths:
43+
- /home/circleci/.ccache
44+
- run: &tests
45+
name: Run tests
46+
command: |
47+
python -m pip install --user -r requirements/tests.txt
48+
python -m pytest
49+
- store_artifacts: &artifacts
50+
path: out
51+
destination: artifacts
2952

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 }}
53+
python_34:
54+
docker:
55+
- image: circleci/python:3.4.10
56+
environment: *env
57+
working_directory: ~/python-mbedtls
58+
steps: *steps
59+
60+
python_35:
61+
docker:
62+
- image: circleci/python:3.5.9
63+
environment: *env
64+
working_directory: ~/python-mbedtls
65+
steps: *steps
66+
67+
python_36:
68+
docker:
69+
- image: circleci/python:3.6.10
70+
environment: *env
71+
working_directory: ~/python-mbedtls
72+
steps: *steps
73+
74+
python_37:
75+
docker:
76+
- image: circleci/python:3.7.6
77+
environment: *env
78+
working_directory: ~/python-mbedtls
79+
steps: *steps
80+
81+
python_38:
82+
docker:
83+
- image: circleci/python:3.8.2
84+
environment: *env
85+
working_directory: ~/python-mbedtls
86+
steps: *steps
4287

88+
python_39:
89+
docker:
90+
- image: circleci/python:3.9-rc
91+
environment: *env
92+
working_directory: ~/python-mbedtls
93+
steps: *steps
94+
95+
python_extra:
96+
docker:
97+
- image: circleci/python:3.7.6
98+
environment: *env
99+
working_directory: ~/python-mbedtls
100+
steps:
101+
- checkout
102+
- run: *deps
103+
- run: *python_version
104+
- restore_cache:
105+
keys:
106+
- ccache--v0--{{ checksum "python_version" }}--cov
107+
- run: *mbedtls
43108
- run:
44-
name: Install Python versions
109+
name: Install library
45110
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
111+
python setup.py --with-coverage build_ext --inplace
74112
- save_cache:
75-
key: py38-3.8.1-v0-{{ arch }}
113+
key: ccache--v0--{{ checksum "python_version" }}--cov--{{ .BuildNum }}
76114
paths:
77-
- .pyenv/versions/3.8.1
78-
115+
- /home/circleci/.ccache
79116
- run:
80-
name: Install mbedtls
117+
name: Run tests
81118
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
94-
119+
python -m pip install --user -r requirements/tests.txt
120+
python -m pip install --user cython pytest-black pytest-cov
121+
PYTHONPATH=$(pwd)/src/:$PYTHONPATH
122+
export PYTHONPATH
123+
python -m pytest --black --cov=src/ tests/
95124
- run:
96-
name: Create environment
125+
name: Coverage
97126
command: |
98-
python -m venv venv
99-
. venv/bin/activate
100-
pip install -r requirements/circleci.txt
101-
127+
python -m pip install --user coveralls
128+
PYTHONPATH=$(pwd)/src/:$PYTHONPATH
129+
export PYTHONPATH
130+
python -m coveralls
102131
- run:
103-
name: Run tests
132+
name: Run doctest
104133
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
109-
tox -e py37 --run-command "{envpython} -m doctest {toxinidir}/README.rst"
110-
134+
PYTHONPATH=$(pwd)/src/:$PYTHONPATH
135+
export PYTHONPATH
136+
python -m doctest README.rst
111137
- run:
112138
name: Build API documentation
113139
command: |
114-
eval "$(pyenv init -)"
115-
pyenv shell 3.7.6
116-
. venv/bin/activate
117-
tox -e py37-docs
118-
140+
python -m pip install --user sphinx sphinx_rtd_theme
141+
sphinx-build docs/source docs_out/ --color -W -bhtml
119142
- run:
120143
name: Save docs
121144
when: on_success
122145
command: |
123146
mkdir -p out/
124-
cp -R .tox/docs_out out/docs
125-
126-
- run:
127-
name: Save logs
128-
when: on_fail
129-
command: |
130-
mkdir -p out/log
131-
cp .tox/*/log/py*.log out/log || true
147+
cp -R docs_out out/docs
148+
- store_artifacts: *artifacts
132149

133-
- store_artifacts:
134-
path: out
135-
destination: artifacts
150+
workflows:
151+
version: 2
152+
build:
153+
jobs:
154+
- python_extra
155+
# - python_39 # Requires Python 3.0
156+
- python_38
157+
- python_37
158+
- python_36
159+
- python_35
160+
- python_34
161+
- python_27

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[next]
2+
3+
* tls: Partial support Python 3.9
4+
15
[1.1.0] - 2020-02-22
26

37
* tls: Add support to PSK for (D)TLS

requirements/circleci.in

-2
This file was deleted.

requirements/circleci.txt

-20
This file was deleted.

requirements/tests.in

-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
coverage < 5.0 # For Python 3.4
2-
cython
31
pytest < 5.0.0 # For Python < 3.5
4-
pytest-cov
5-
pytest-repeat
62
readme_renderer
73

84
docutils < 0.16 # via readme_renderer; for Python 3.4
95
importlib-metadata < 1.2.0 # via pluggy, pytest; for Python 3.4
106
more-itertools < 6.0.0 # via pytest, zipp; for Python < 3.5
11-
pygments < 2.4.0 # via readme-renderer; for Python 3.4
127
zipp < 2.0.0 # via importlib-metadata; for Python < 3.6

requirements/tests.txt

+7-11
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,17 @@
77
atomicwrites==1.3.0 # via pytest
88
attrs==19.3.0 # via pytest
99
bleach==3.1.1 # via readme-renderer
10-
coverage==4.5.4 # via -r requirements/tests.in (line 1), pytest-cov
11-
cython==0.29.15 # via -r requirements/tests.in (line 2)
12-
docutils==0.15.2 # via -r requirements/tests.in (line 8), readme-renderer
13-
importlib-metadata==1.1.3 # via -r requirements/tests.in (line 9), pluggy, pytest
14-
more-itertools==5.0.0 # via -r requirements/tests.in (line 10), pytest
10+
docutils==0.15.2 # via -r requirements/tests.in, readme-renderer
11+
importlib-metadata==1.1.3 # via -r requirements/tests.in
12+
more-itertools==5.0.0 # via -r requirements/tests.in, pytest
1513
packaging==20.1 # via pytest
1614
pluggy==0.13.1 # via pytest
1715
py==1.8.1 # via pytest
18-
pygments==2.3.1 # via -r requirements/tests.in (line 11), readme-renderer
16+
pygments==2.3.1 # via readme-renderer
1917
pyparsing==2.4.6 # via packaging
20-
pytest-cov==2.8.1 # via -r requirements/tests.in (line 4)
21-
pytest-repeat==0.8.0 # via -r requirements/tests.in (line 5)
22-
pytest==4.6.9 # via -r requirements/tests.in (line 3), pytest-cov, pytest-repeat
23-
readme-renderer==24.0 # via -r requirements/tests.in (line 6)
18+
pytest==4.6.9 # via -r requirements/tests.in
19+
readme-renderer==24.0 # via -r requirements/tests.in
2420
six==1.14.0 # via bleach, more-itertools, packaging, pytest, readme-renderer
2521
wcwidth==0.1.8 # via pytest
2622
webencodings==0.5.1 # via bleach
27-
zipp==1.2.0 # via -r requirements/tests.in (line 12), importlib-metadata
23+
zipp==1.2.0 # via -r requirements/tests.in, importlib-metadata

scripts/download-mbedtls.sh

+3-3
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

+9-9
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

0 commit comments

Comments
 (0)