From a76477e74729f70b826b3971a757d71d5eb74b13 Mon Sep 17 00:00:00 2001 From: Michael Waskom Date: Sun, 31 May 2020 18:05:15 -0400 Subject: [PATCH] Test docs during CI (#2109) * Excecute gallery scripts and fail on errors * Revert change to github ci workflow * Test doc build with intentionally broken notebook * Revert broken notebook * Use MPLBACKEND environment variable * Reorganize testing-related files * Specify qt version for travis * Don't test backend rcParam --- .github/workflows/ci.yaml | 4 ++-- .travis.yml | 19 +++++++++---------- ci/check_gallery.py | 14 ++++++++++++++ {testing => ci}/deps_latest.txt | 0 {testing => ci}/deps_minimal.txt | 0 {testing => ci}/deps_pinned.txt | 0 {testing => ci}/getmsfonts.sh | 0 {testing => ci}/utils.txt | 0 doc/tutorial/distributions.ipynb | 2 +- seaborn/tests/test_rcmod.py | 4 ++++ testing/matplotlibrc_agg | 1 - testing/matplotlibrc_qtagg | 1 - 12 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 ci/check_gallery.py rename {testing => ci}/deps_latest.txt (100%) rename {testing => ci}/deps_minimal.txt (100%) rename {testing => ci}/deps_pinned.txt (100%) rename {testing => ci}/getmsfonts.sh (100%) rename {testing => ci}/utils.txt (100%) delete mode 100644 testing/matplotlibrc_agg delete mode 100644 testing/matplotlibrc_qtagg diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4a3081c3a3..1b31609e41 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ env: jobs: - checks: + build-docs: runs-on: ubuntu-latest steps: @@ -24,7 +24,7 @@ jobs: - name: Install seaborn run: | python -m pip install --upgrade pip - pip install `cat testing/deps_latest.txt testing/utils.txt` + pip install `cat ci/deps_latest.txt ci/utils.txt` pip install . - name: Install doc tools diff --git a/.travis.yml b/.travis.yml index 03042ef25c..3978d0ed56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,17 @@ services: env: - - PYTHON=3.6 DEPS=pinned BACKEND=agg DOCTESTS=true - - PYTHON=3.6 DEPS=latest BACKEND=agg DOCTESTS=true - - PYTHON=3.7 DEPS=latest BACKEND=agg DOCTESTS=true - - PYTHON=3.8 DEPS=latest BACKEND=agg DOCTESTS=true - - PYTHON=3.8 DEPS=latest BACKEND=qtagg DOCTESTS=true - - PYTHON=3.8 DEPS=minimal BACKEND=agg DOCTESTS=false + - PYTHON=3.6 DEPS=pinned MPLBACKEND=agg DOCTESTS=true + - PYTHON=3.6 DEPS=latest MPLBACKEND=agg DOCTESTS=true + - PYTHON=3.7 DEPS=latest MPLBACKEND=agg DOCTESTS=true + - PYTHON=3.8 DEPS=latest MPLBACKEND=agg DOCTESTS=true + - PYTHON=3.8 DEPS=latest MPLBACKEND=qt5agg DOCTESTS=true + - PYTHON=3.8 DEPS=minimal MPLBACKEND=agg DOCTESTS=false before_install: - sudo apt-get update -yq - - sudo sh testing/getmsfonts.sh + - sudo sh ci/getmsfonts.sh - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" @@ -32,14 +32,13 @@ before_install: install: - conda create -n testenv pip python=$PYTHON - source activate testenv - - cat testing/deps_${DEPS}.txt testing/utils.txt > deps.txt + - cat ci/deps_${DEPS}.txt ci/utils.txt > deps.txt - conda install --file deps.txt - pip install . before_script: - - cp testing/matplotlibrc_${BACKEND} matplotlibrc - - if [ $BACKEND == "qtagg" ]; then + - if [ $MPLBACKEND == "qtagg" ]; then export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start; sleep 3; diff --git a/ci/check_gallery.py b/ci/check_gallery.py new file mode 100644 index 0000000000..60db2e12c6 --- /dev/null +++ b/ci/check_gallery.py @@ -0,0 +1,14 @@ +"""Execute the scripts that comprise the example gallery in the online docs.""" +from glob import glob +import matplotlib.pyplot as plt + +if __name__ == "__main__": + + fnames = sorted(glob("examples/*.py")) + + for fname in fnames: + + print(f"- {fname}") + with open(fname) as fid: + exec(fid.read()) + plt.close("all") diff --git a/testing/deps_latest.txt b/ci/deps_latest.txt similarity index 100% rename from testing/deps_latest.txt rename to ci/deps_latest.txt diff --git a/testing/deps_minimal.txt b/ci/deps_minimal.txt similarity index 100% rename from testing/deps_minimal.txt rename to ci/deps_minimal.txt diff --git a/testing/deps_pinned.txt b/ci/deps_pinned.txt similarity index 100% rename from testing/deps_pinned.txt rename to ci/deps_pinned.txt diff --git a/testing/getmsfonts.sh b/ci/getmsfonts.sh similarity index 100% rename from testing/getmsfonts.sh rename to ci/getmsfonts.sh diff --git a/testing/utils.txt b/ci/utils.txt similarity index 100% rename from testing/utils.txt rename to ci/utils.txt diff --git a/doc/tutorial/distributions.ipynb b/doc/tutorial/distributions.ipynb index fc64a95c04..844a4f1e89 100644 --- a/doc/tutorial/distributions.ipynb +++ b/doc/tutorial/distributions.ipynb @@ -475,7 +475,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.2" + "version": "3.7.4" } }, "nbformat": 4, diff --git a/seaborn/tests/test_rcmod.py b/seaborn/tests/test_rcmod.py index eb6110272e..e975ca612e 100644 --- a/seaborn/tests/test_rcmod.py +++ b/seaborn/tests/test_rcmod.py @@ -19,6 +19,10 @@ def flatten_list(self, orig_list): def assert_rc_params(self, params): for k, v in params.items(): + # Various subtle issues in matplotlib lead to unexpected + # values for the backend rcParam, which isn't relevant here + if k == "backend": + continue if isinstance(v, np.ndarray): npt.assert_array_equal(mpl.rcParams[k], v) else: diff --git a/testing/matplotlibrc_agg b/testing/matplotlibrc_agg deleted file mode 100644 index 88a8365733..0000000000 --- a/testing/matplotlibrc_agg +++ /dev/null @@ -1 +0,0 @@ -backend: Agg diff --git a/testing/matplotlibrc_qtagg b/testing/matplotlibrc_qtagg deleted file mode 100644 index 957624030e..0000000000 --- a/testing/matplotlibrc_qtagg +++ /dev/null @@ -1 +0,0 @@ -backend: Qt5Agg