Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0909c06

Browse files
QuLogictacaswell
authored andcommitted
Build docs with Circle CI (#8893)
* Remove documentation builds from Travis. * Enable docs build on CircleCI. * Ensure we have tags on CircleCI. This helps to provide a reasonable version number. * Attempt to use CircleCI 2.0. * Remove mencoder from doc build. It's not available on jessie, the distro on which CircleCI's docker image is based. * ci: Install doc requirements in user directory. The docker image does not appear to be running as root. * ci: Use explicit path to linkchecker. * ci: Try to remove redundancy in CircleCI config. * ci: Store doc artifacts after CircleCI build. * ci: Rename CircleCI build names to be clearer. Add 'doc-' prefix so that it will be clear on the GitHub status list what these builds are doing. * ci: Print out documentation link at end of build. * ci: Re-add documentation deploy script on CircleCI. * ci: Delete existing files before deploying docs. Otherwise, random files might be left over, such as the old gallery.html that was removed when switching to sphinx-gallery. * ci: Bundle and store sphinx-gallery artifacts also.
1 parent b781623 commit 0909c06

File tree

4 files changed

+209
-81
lines changed

4 files changed

+209
-81
lines changed

.circleci/config.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Circle CI configuration file
2+
# https://circleci.com/docs/
3+
4+
version: 2
5+
6+
7+
###########################################
8+
# Define some common steps as YAML anchors.
9+
#
10+
11+
apt-run: &apt-install
12+
name: Install apt packages
13+
command: |
14+
sudo apt-get install \
15+
inkscape \
16+
libav-tools \
17+
dvipng \
18+
pgf \
19+
lmodern \
20+
cm-super \
21+
texlive-latex-base \
22+
texlive-latex-extra \
23+
texlive-fonts-recommended \
24+
texlive-latex-recommended \
25+
texlive-xetex \
26+
graphviz \
27+
libgeos-dev \
28+
otf-freefont
29+
30+
fonts-run: &fonts-install
31+
name: Install custom fonts
32+
# We manually install Humor-Sans using the package from Ubuntu 14.10.
33+
# Unfortunately humor sans is not available in the Ubuntu version used by
34+
# CircleCI but we can manually install the deb from a later version since
35+
# it is basically just a .ttf file.
36+
command: |
37+
mkdir -p ~/.local/share/fonts
38+
wget -nc https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O ~/.local/share/fonts/Felipa-Regular.ttf || true
39+
if [ ! -f ~/.local/share/fonts/Humor-Sans.ttf ]; then
40+
wget https://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
41+
mkdir tmp
42+
dpkg -x fonts-humor-sans_1.0-1_all.deb tmp
43+
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.local/share/fonts
44+
rm -rf tmp
45+
else
46+
echo "Not downloading Humor-Sans; file already exists."
47+
fi
48+
fc-cache -f -v
49+
50+
pip-run: &pip-install
51+
# Upgrade pip and setuptools and wheel to get as clean an install as possible
52+
name: Upgrade pip, setuptools, wheel
53+
command: |
54+
pip install --upgrade --user pip
55+
pip install --upgrade --user wheel
56+
pip install --upgrade --user setuptools
57+
58+
deps-run: &deps-install
59+
name: Install Python dependencies
60+
command: |
61+
pip install --user python-dateutil numpy${NUMPY_VERSION} pyparsing!=2.1.6 cycler codecov coverage sphinx pillow
62+
pip install --user -r doc-requirements.txt
63+
64+
mpl-run: &mpl-install
65+
name: Install Matplotlib
66+
command: pip install --user -ve .
67+
68+
doc-run: &doc-build
69+
name: Build documentation
70+
command: python make.py html
71+
working_directory: doc
72+
73+
doc-bundle-run: &doc-bundle
74+
name: Bundle sphinx-gallery documentation artifacts
75+
command: tar cf doc/build/sphinx-gallery-files.tar.gz doc/api/_as_gen doc/gallery doc/tutorials
76+
when: always
77+
78+
79+
##########################################
80+
# Here is where the real jobs are defined.
81+
#
82+
83+
jobs:
84+
docs-python35:
85+
docker:
86+
- image: circleci/python:3.5
87+
steps:
88+
- checkout
89+
90+
- run: *apt-install
91+
- run: *fonts-install
92+
- run: *pip-install
93+
94+
- run: *deps-install
95+
- run: *mpl-install
96+
97+
- run: *doc-build
98+
99+
- run: *doc-bundle
100+
- store_artifacts:
101+
path: doc/build/sphinx-gallery-files.tar.gz
102+
103+
- store_artifacts:
104+
path: doc/build/html
105+
106+
- run:
107+
name: "Built documentation is available at:"
108+
command: echo "${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/doc/build/html/index.html"
109+
110+
- deploy:
111+
name: "Deploy new docs"
112+
command: ./.circleci/deploy-docs.sh
113+
114+
docs-python27:
115+
docker:
116+
- image: circleci/python:2.7
117+
steps:
118+
- checkout
119+
120+
- run: *apt-install
121+
- run: *fonts-install
122+
- run: *pip-install
123+
124+
- run:
125+
<<: *deps-install
126+
environment:
127+
NUMPY_VERSION: "==1.7.1"
128+
# Linkchecker only works with python 2.7 for the time being.
129+
# Linkchecker is currently broken with requests 2.10.0 so force an earlier version.
130+
- run: pip install --user $PRE requests==2.9.2 linkchecker
131+
- run: *mpl-install
132+
133+
- run: *doc-build
134+
135+
# We don't build the LaTeX docs here, so linkchecker will complain
136+
- run: touch doc/build/html/Matplotlib.pdf
137+
138+
# Linkchecker only works with python 2.7 for the time being
139+
- run:
140+
name: linkchecker
141+
command: ~/.local/bin/linkchecker build/html/index.html
142+
working_directory: doc
143+
144+
- run: *doc-bundle
145+
- store_artifacts:
146+
path: doc/build/sphinx-gallery-files.tar.gz
147+
148+
- store_artifacts:
149+
path: doc/build/html
150+
151+
- run:
152+
name: "Built documentation is available at:"
153+
command: echo "${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/doc/build/html/index.html"
154+
155+
156+
#########################################
157+
# Defining workflows gets us parallelism.
158+
#
159+
160+
workflows:
161+
version: 2
162+
build:
163+
jobs:
164+
- docs-python35
165+
- docs-python27

.circleci/deploy-docs.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "$CIRCLE_BRANCH" != "master" -o "$CIRCLE_PULL_REQUEST" != "" ]; then
6+
echo "Not uploading docs from non-master branch."
7+
exit
8+
fi
9+
10+
git clone [email protected]:matplotlib/devdocs.git
11+
12+
cd devdocs
13+
14+
git checkout --orphan gh-pages || true
15+
git reset --hard first_commit
16+
17+
git rm -rf .
18+
cp -R ../doc/build/html/. .
19+
touch .nojekyll
20+
21+
git config user.email "MatplotlibCircleBot@nomail"
22+
git config user.name "MatplotlibCircleBot"
23+
git config push.default simple
24+
25+
git add .
26+
git commit -m "Docs build of $CIRCLE_SHA1"
27+
28+
git push --set-upstream origin gh-pages --force

.travis.yml

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ env:
3636
- secure: RgJI7BBL8aX5FTOQe7xiXqWHMxWokd6GNUWp1NUV2mRLXPb9dI0RXqZt3UJwKTAzf1z/OtlHDmEkBoTVK81E9iUxK5npwyyjhJ8yTJmwfQtQF2n51Q1Ww9p+XSLORrOzZc7kAo6Kw6FIXN1pfctgYq2bQkrwJPRx/oPR8f6hcbY=
3737
- secure: E7OCdqhZ+PlwJcn+Hd6ns9TDJgEUXiUNEI0wu7xjxB2vBRRIKtZMbuaZjd+iKDqCKuVOJKu0ClBUYxmgmpLicTwi34CfTUYt6D4uhrU+8hBBOn1iiK51cl/aBvlUUrqaRLVhukNEBGZcyqAjXSA/Qsnp2iELEmAfOUa92ZYo1sk=
3838
- secure: "dfjNqGKzQG5bu3FnDNwLG8H/C4QoieFo4PfFmZPdM2RY7WIzukwKFNT6kiDfOrpwt+2bR7FhzjOGlDECGtlGOtYPN8XuXGjhcP4a4IfakdbDfF+D3NPIpf5VlE6776k0VpvcZBTMYJKNFIMc7QPkOwjvNJ2aXyfe3hBuGlKJzQU="
39-
- BUILD_DOCS=false
4039
- NUMPY=numpy
4140
- OPENBLAS_NUM_THREADS=1
4241
- PANDAS=
@@ -52,12 +51,8 @@ matrix:
5251
include:
5352
- python: 2.7
5453
env: MOCK=mock NUMPY=numpy==1.7.1 PANDAS=pandas NOSE=nose
55-
- python: 2.7
56-
env: NUMPY=numpy==1.7.1 BUILD_DOCS=true
5754
- python: 3.4
5855
env: PYTHON_ARGS=-OO
59-
- python: 3.5
60-
env: BUILD_DOCS=true
6156
- python: 3.6
6257
env: DELETE_FONT_CACHE=1 INSTALL_PEP8=pytest-pep8 RUN_PEP8=--pep8 PANDAS=pandas
6358
- python: "nightly"
@@ -139,10 +134,6 @@ install:
139134
echo 'wxPython is available' ||
140135
echo 'wxPython is not available'
141136
142-
if [[ $BUILD_DOCS == true ]]; then
143-
pip install $PRE -r doc-requirements.txt
144-
fi
145-
146137
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
147138
pip install $PRE \
148139
pytest \
@@ -153,24 +144,8 @@ install:
153144
pytest-xdist \
154145
$INSTALL_PEP8
155146
156-
# We manually install humor sans using the package from Ubuntu 14.10.
157-
# Unfortunatly humor sans is not availible in the Ubuntu version used by
158-
# Travis but we can manually install the deb from a later version since is
159-
# it basically just a .ttf file. The current Travis Ubuntu image is to old
160-
# to search .local/share/fonts so we store fonts in .fonts
161-
if [[ $BUILD_DOCS == true ]]; then
162-
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
163-
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
164-
mkdir -p tmp
165-
mkdir -p ~/.fonts
166-
dpkg -x fonts-humor-sans_1.0-1_all.deb tmp
167-
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.fonts
168-
cp Felipa-Regular.ttf ~/.fonts
169-
fc-cache -f -v
170-
else
171-
# Use the special local version of freetype for testing
172-
cp ci/travis/setup.cfg .
173-
fi;
147+
# Use the special local version of freetype for testing
148+
cp ci/travis/setup.cfg .
174149
- |
175150
# Install matplotlib
176151
pip install -ve .
@@ -190,7 +165,7 @@ before_cache:
190165

191166
after_failure:
192167
- |
193-
if [[ $BUILD_DOCS == false && $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' ]]; then
168+
if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' ]]; then
194169
gem install travis-artifacts
195170
cd $TRAVIS_BUILD_DIR/../tmp_test_dir
196171
tar cjf result_images.tar.bz2 result_images
@@ -201,31 +176,4 @@ after_failure:
201176
fi
202177
203178
after_success:
204-
- |
205-
if [[ $BUILD_DOCS == false ]]; then
206-
codecov -e TRAVIS_PYTHON_VERSION
207-
fi
208-
- |
209-
if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' && $BUILD_DOCS == true && $TRAVIS_PYTHON_VERSION == "3.5" && $TRAVIS_BRANCH == 'master' ]]; then
210-
cd $TRAVIS_BUILD_DIR
211-
echo "Uploading documentation"
212-
openssl aes-256-cbc -K $encrypted_cc802e084cd0_key -iv $encrypted_cc802e084cd0_iv -in ci/travis/matplotlibDeployKey.enc -out ci/travis/matplotlibDeployKey -d
213-
eval `ssh-agent -s`
214-
chmod 600 ci/travis/matplotlibDeployKey
215-
ssh-add ci/travis/matplotlibDeployKey
216-
cd ..
217-
git clone [email protected]:matplotlib/devdocs.git
218-
cd devdocs
219-
git checkout --orphan gh-pages
220-
git reset --hard first_commit
221-
cp -R ../matplotlib/doc/build/html/. .
222-
touch .nojekyll
223-
git config --global user.email "MatplotlibTravisBot@nomail"
224-
git config --global user.name "MatplotlibTravisBot"
225-
git config --global push.default simple
226-
git add .
227-
git commit -m "Docs build of $TRAVIS_COMMIT"
228-
git push --set-upstream origin gh-pages --force
229-
else
230-
echo "Will only deploy docs build from matplotlib master branch"
231-
fi
179+
- codecov -e TRAVIS_PYTHON_VERSION

ci/travis/test_script.sh

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,18 @@ set -ev
1111
# Travis VM to run out of memory (since so many copies of inkscape and
1212
# ghostscript are running at the same time).
1313

14-
if [[ $BUILD_DOCS == false ]]; then
15-
if [[ $DELETE_FONT_CACHE == 1 ]]; then
16-
rm -rf ~/.cache/matplotlib
17-
fi
18-
# Workaround for pytest-xdist flaky collection order
19-
# https://github.com/pytest-dev/pytest/issues/920
20-
# https://github.com/pytest-dev/pytest/issues/1075
21-
export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')
22-
echo PYTHONHASHSEED=$PYTHONHASHSEED
14+
if [[ $DELETE_FONT_CACHE == 1 ]]; then
15+
rm -rf ~/.cache/matplotlib
16+
fi
17+
# Workaround for pytest-xdist flaky collection order
18+
# https://github.com/pytest-dev/pytest/issues/920
19+
# https://github.com/pytest-dev/pytest/issues/1075
20+
export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')
21+
echo PYTHONHASHSEED=$PYTHONHASHSEED
2322

24-
echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
25-
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
26-
pytest $PYTEST_ARGS $RUN_PEP8
27-
else
28-
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS -m pytest $PYTEST_ARGS $RUN_PEP8
29-
fi
23+
echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
24+
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
25+
pytest $PYTEST_ARGS $RUN_PEP8
3026
else
31-
cd doc
32-
python make.py html
33-
# We don't build the LaTeX docs here, so linkchecker will complain
34-
touch build/html/Matplotlib.pdf
35-
# Linkchecker only works with python 2.7 for the time being
36-
source ~/virtualenv/python2.7/bin/activate
37-
pip install pip --upgrade
38-
# linkchecker is currently broken with requests 2.10.0 so force an earlier version
39-
pip install $PRE requests==2.9.2 linkchecker
40-
linkchecker build/html/index.html
27+
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS -m pytest $PYTEST_ARGS $RUN_PEP8
4128
fi

0 commit comments

Comments
 (0)