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

Skip to content

Build docs with Circle CI #8893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Circle CI configuration file
# https://circleci.com/docs/

version: 2


###########################################
# Define some common steps as YAML anchors.
#

apt-run: &apt-install
name: Install apt packages
command: |
sudo apt-get install \
inkscape \
libav-tools \
dvipng \
pgf \
lmodern \
cm-super \
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-latex-recommended \
texlive-xetex \
graphviz \
libgeos-dev \
otf-freefont

fonts-run: &fonts-install
name: Install custom fonts
# We manually install Humor-Sans using the package from Ubuntu 14.10.
# Unfortunately humor sans is not available in the Ubuntu version used by
# CircleCI but we can manually install the deb from a later version since
# it is basically just a .ttf file.
command: |
mkdir -p ~/.local/share/fonts
wget -nc https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O ~/.local/share/fonts/Felipa-Regular.ttf || true
if [ ! -f ~/.local/share/fonts/Humor-Sans.ttf ]; then
wget https://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
mkdir tmp
dpkg -x fonts-humor-sans_1.0-1_all.deb tmp
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.local/share/fonts
rm -rf tmp
else
echo "Not downloading Humor-Sans; file already exists."
fi
fc-cache -f -v

pip-run: &pip-install
# Upgrade pip and setuptools and wheel to get as clean an install as possible
name: Upgrade pip, setuptools, wheel
command: |
pip install --upgrade --user pip
pip install --upgrade --user wheel
pip install --upgrade --user setuptools

deps-run: &deps-install
name: Install Python dependencies
command: |
pip install --user python-dateutil numpy${NUMPY_VERSION} pyparsing!=2.1.6 cycler codecov coverage sphinx pillow
pip install --user -r doc-requirements.txt

mpl-run: &mpl-install
name: Install Matplotlib
command: pip install --user -ve .

doc-run: &doc-build
name: Build documentation
command: python make.py html
working_directory: doc

doc-bundle-run: &doc-bundle
name: Bundle sphinx-gallery documentation artifacts
command: tar cf doc/build/sphinx-gallery-files.tar.gz doc/api/_as_gen doc/gallery doc/tutorials
when: always


##########################################
# Here is where the real jobs are defined.
#

jobs:
docs-python35:
docker:
- image: circleci/python:3.5
steps:
- checkout

- run: *apt-install
- run: *fonts-install
- run: *pip-install

- run: *deps-install
- run: *mpl-install

- run: *doc-build

- run: *doc-bundle
- store_artifacts:
path: doc/build/sphinx-gallery-files.tar.gz

- store_artifacts:
path: doc/build/html

- run:
name: "Built documentation is available at:"
command: echo "${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/doc/build/html/index.html"

- deploy:
name: "Deploy new docs"
command: ./.circleci/deploy-docs.sh

docs-python27:
docker:
- image: circleci/python:2.7
steps:
- checkout

- run: *apt-install
- run: *fonts-install
- run: *pip-install

- run:
<<: *deps-install
environment:
NUMPY_VERSION: "==1.7.1"
# Linkchecker only works with python 2.7 for the time being.
# Linkchecker is currently broken with requests 2.10.0 so force an earlier version.
- run: pip install --user $PRE requests==2.9.2 linkchecker
- run: *mpl-install

- run: *doc-build

# We don't build the LaTeX docs here, so linkchecker will complain
- run: touch doc/build/html/Matplotlib.pdf

# Linkchecker only works with python 2.7 for the time being
- run:
name: linkchecker
command: ~/.local/bin/linkchecker build/html/index.html
working_directory: doc

- run: *doc-bundle
- store_artifacts:
path: doc/build/sphinx-gallery-files.tar.gz

- store_artifacts:
path: doc/build/html

- run:
name: "Built documentation is available at:"
command: echo "${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/doc/build/html/index.html"


#########################################
# Defining workflows gets us parallelism.
#

workflows:
version: 2
build:
jobs:
- docs-python35
- docs-python27
28 changes: 28 additions & 0 deletions .circleci/deploy-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

if [ "$CIRCLE_BRANCH" != "master" -o "$CIRCLE_PULL_REQUEST" != "" ]; then
echo "Not uploading docs from non-master branch."
exit
fi

git clone [email protected]:matplotlib/devdocs.git

cd devdocs

git checkout --orphan gh-pages || true
git reset --hard first_commit

git rm -rf .
cp -R ../doc/build/html/. .
touch .nojekyll

git config user.email "MatplotlibCircleBot@nomail"
git config user.name "MatplotlibCircleBot"
git config push.default simple

git add .
git commit -m "Docs build of $CIRCLE_SHA1"

git push --set-upstream origin gh-pages --force
60 changes: 4 additions & 56 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ env:
- secure: RgJI7BBL8aX5FTOQe7xiXqWHMxWokd6GNUWp1NUV2mRLXPb9dI0RXqZt3UJwKTAzf1z/OtlHDmEkBoTVK81E9iUxK5npwyyjhJ8yTJmwfQtQF2n51Q1Ww9p+XSLORrOzZc7kAo6Kw6FIXN1pfctgYq2bQkrwJPRx/oPR8f6hcbY=
- secure: E7OCdqhZ+PlwJcn+Hd6ns9TDJgEUXiUNEI0wu7xjxB2vBRRIKtZMbuaZjd+iKDqCKuVOJKu0ClBUYxmgmpLicTwi34CfTUYt6D4uhrU+8hBBOn1iiK51cl/aBvlUUrqaRLVhukNEBGZcyqAjXSA/Qsnp2iELEmAfOUa92ZYo1sk=
- secure: "dfjNqGKzQG5bu3FnDNwLG8H/C4QoieFo4PfFmZPdM2RY7WIzukwKFNT6kiDfOrpwt+2bR7FhzjOGlDECGtlGOtYPN8XuXGjhcP4a4IfakdbDfF+D3NPIpf5VlE6776k0VpvcZBTMYJKNFIMc7QPkOwjvNJ2aXyfe3hBuGlKJzQU="
- BUILD_DOCS=false
- NUMPY=numpy
- OPENBLAS_NUM_THREADS=1
- PANDAS=
Expand All @@ -52,12 +51,8 @@ matrix:
include:
- python: 2.7
env: MOCK=mock NUMPY=numpy==1.7.1 PANDAS=pandas NOSE=nose
- python: 2.7
env: NUMPY=numpy==1.7.1 BUILD_DOCS=true
- python: 3.4
env: PYTHON_ARGS=-OO
- python: 3.5
env: BUILD_DOCS=true
- python: 3.6
env: DELETE_FONT_CACHE=1 INSTALL_PEP8=pytest-pep8 RUN_PEP8=--pep8 PANDAS=pandas
- python: "nightly"
Expand Down Expand Up @@ -139,10 +134,6 @@ install:
echo 'wxPython is available' ||
echo 'wxPython is not available'

if [[ $BUILD_DOCS == true ]]; then
pip install $PRE -r doc-requirements.txt
fi

# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
pip install $PRE \
pytest \
Expand All @@ -153,24 +144,8 @@ install:
pytest-xdist \
$INSTALL_PEP8

# We manually install humor sans using the package from Ubuntu 14.10.
# Unfortunatly humor sans is not availible in the Ubuntu version used by
# Travis but we can manually install the deb from a later version since is
# it basically just a .ttf file. The current Travis Ubuntu image is to old
# to search .local/share/fonts so we store fonts in .fonts
if [[ $BUILD_DOCS == true ]]; then
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
mkdir -p tmp
mkdir -p ~/.fonts
dpkg -x fonts-humor-sans_1.0-1_all.deb tmp
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.fonts
cp Felipa-Regular.ttf ~/.fonts
fc-cache -f -v
else
# Use the special local version of freetype for testing
cp ci/travis/setup.cfg .
fi;
# Use the special local version of freetype for testing
cp ci/travis/setup.cfg .
- |
# Install matplotlib
pip install -ve .
Expand All @@ -190,7 +165,7 @@ before_cache:

after_failure:
- |
if [[ $BUILD_DOCS == false && $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' ]]; then
if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' ]]; then
gem install travis-artifacts
cd $TRAVIS_BUILD_DIR/../tmp_test_dir
tar cjf result_images.tar.bz2 result_images
Expand All @@ -201,31 +176,4 @@ after_failure:
fi

after_success:
- |
if [[ $BUILD_DOCS == false ]]; then
codecov -e TRAVIS_PYTHON_VERSION
fi
- |
if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_REPO_SLUG == 'matplotlib/matplotlib' && $BUILD_DOCS == true && $TRAVIS_PYTHON_VERSION == "3.5" && $TRAVIS_BRANCH == 'master' ]]; then
cd $TRAVIS_BUILD_DIR
echo "Uploading documentation"
openssl aes-256-cbc -K $encrypted_cc802e084cd0_key -iv $encrypted_cc802e084cd0_iv -in ci/travis/matplotlibDeployKey.enc -out ci/travis/matplotlibDeployKey -d
eval `ssh-agent -s`
chmod 600 ci/travis/matplotlibDeployKey
ssh-add ci/travis/matplotlibDeployKey
cd ..
git clone [email protected]:matplotlib/devdocs.git
cd devdocs
git checkout --orphan gh-pages
git reset --hard first_commit
cp -R ../matplotlib/doc/build/html/. .
touch .nojekyll
git config --global user.email "MatplotlibTravisBot@nomail"
git config --global user.name "MatplotlibTravisBot"
git config --global push.default simple
git add .
git commit -m "Docs build of $TRAVIS_COMMIT"
git push --set-upstream origin gh-pages --force
else
echo "Will only deploy docs build from matplotlib master branch"
fi
- codecov -e TRAVIS_PYTHON_VERSION
37 changes: 12 additions & 25 deletions ci/travis/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,18 @@ set -ev
# Travis VM to run out of memory (since so many copies of inkscape and
# ghostscript are running at the same time).

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

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