From 18e3b2a36f9661727e8c21981d2f3cb6400c9955 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 20 Apr 2020 23:43:23 -0400 Subject: [PATCH 1/4] Circle: Convert config into re-usable command style. This allows embedding multiple steps into a command. --- .circleci/config.yml | 201 +++++++++++++++++++++++-------------------- 1 file changed, 109 insertions(+), 92 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 87388469caba..6d9f3430abcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,76 +4,95 @@ version: 2.1 -########################################### -# Define some common steps as YAML anchors. +####################################### +# Define some common steps as commands. # -apt-run: &apt-install - name: Install apt packages - command: | - sudo apt -qq update - sudo apt install -y \ - inkscape \ - ffmpeg \ - dvipng \ - lmodern \ - cm-super \ - texlive-latex-base \ - texlive-latex-extra \ - texlive-fonts-recommended \ - texlive-latex-recommended \ - texlive-pictures \ - texlive-xetex \ - graphviz \ - fonts-crosextra-carlito \ - fonts-freefont-otf \ - fonts-humor-sans \ - optipng - -fonts-run: &fonts-install - name: Install custom fonts - 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 - fc-cache -f -v - save_cache: - key: fonts-2 - paths: - - ~/.local/share/fonts/ - restore_cache: - key: fonts-2 - -pip-run: &pip-install - # Upgrade pip and setuptools and wheel to get as clean an install as possible - name: Upgrade pip, setuptools, wheel - command: | - python -mpip install --upgrade --user pip - python -mpip install --upgrade --user wheel - python -mpip install --upgrade --user setuptools - -deps-run: &deps-install - name: Install Python dependencies - command: | - python -mpip install --user numpy${NUMPY_VERSION} codecov coverage - python -mpip install --user -r requirements/doc/doc-requirements.txt - -mpl-run: &mpl-install - name: Install Matplotlib - command: python -mpip install --user -ve . - -doc-run: &doc-build - name: Build documentation - command: | - # Set epoch to date of latest tag. - export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))" - make html O=-T - rm -r build/html/_sources - 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 +commands: + apt-install: + steps: + - run: + name: Install apt packages + command: | + sudo apt -qq update + sudo apt install -y \ + inkscape \ + ffmpeg \ + dvipng \ + lmodern \ + cm-super \ + texlive-latex-base \ + texlive-latex-extra \ + texlive-fonts-recommended \ + texlive-latex-recommended \ + texlive-pictures \ + texlive-xetex \ + graphviz \ + fonts-crosextra-carlito \ + fonts-freefont-otf \ + fonts-humor-sans \ + optipng + + fonts-install: + steps: + - run: + name: Install custom fonts + 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 + fc-cache -f -v + save_cache: + key: fonts-2 + paths: + - ~/.local/share/fonts/ + restore_cache: + key: fonts-2 + + pip-install: + description: Upgrade pip and setuptools and wheel to get as clean an install as possible + steps: + - run: + name: Upgrade pip, setuptools, wheel + command: | + python -mpip install --upgrade --user pip + python -mpip install --upgrade --user wheel + python -mpip install --upgrade --user setuptools + + deps-install: + parameters: + numpy_version: + type: string + default: "" + steps: + - run: + name: Install Python dependencies + command: | + python -mpip install --user numpy<< parameters.numpy_version >> codecov coverage + python -mpip install --user -r requirements/doc/doc-requirements.txt + + mpl-install: + steps: + - run: + name: Install Matplotlib + command: python -mpip install --user -ve . + + doc-build: + steps: + - run: + name: Build documentation + command: | + # Set epoch to date of latest tag. + export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))" + make html O=-T + rm -r build/html/_sources + working_directory: doc + + doc-bundle: + steps: + - run: + 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 ########################################## @@ -87,18 +106,16 @@ jobs: steps: - checkout - - run: *apt-install - - run: *fonts-install - - run: *pip-install - - run: - <<: *deps-install - environment: - NUMPY_VERSION: "==1.13.0" - - run: *mpl-install + - apt-install + - fonts-install + - pip-install + - deps-install: + numpy_version: "==1.13.0" + - mpl-install - - run: *doc-build + - doc-build - - run: *doc-bundle + - doc-bundle - store_artifacts: path: doc/build/sphinx-gallery-files.tar.gz @@ -111,16 +128,16 @@ jobs: steps: - checkout - - run: *apt-install - - run: *fonts-install - - run: *pip-install + - apt-install + - fonts-install + - pip-install - - run: *deps-install - - run: *mpl-install + - deps-install + - mpl-install - - run: *doc-build + - doc-build - - run: *doc-bundle + - doc-bundle - store_artifacts: path: doc/build/sphinx-gallery-files.tar.gz @@ -133,16 +150,16 @@ jobs: steps: - checkout - - run: *apt-install - - run: *fonts-install - - run: *pip-install + - apt-install + - fonts-install + - pip-install - - run: *deps-install - - run: *mpl-install + - deps-install + - mpl-install - - run: *doc-build + - doc-build - - run: *doc-bundle + - doc-bundle - store_artifacts: path: doc/build/sphinx-gallery-files.tar.gz From ca1c5d9f2119fafd5da8703ea0caafb7c342159e Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 17 Apr 2020 21:14:45 -0400 Subject: [PATCH 2/4] Fix caching of fonts in CircleCI builds. The `save_cache` and `restore_cache` entries need to be separate steps, not keys on the `run` step. --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d9f3430abcf..4f8b59221646 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,18 +35,18 @@ commands: fonts-install: steps: + - restore_cache: + key: fonts-2 - run: name: Install custom fonts 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 fc-cache -f -v - save_cache: - key: fonts-2 - paths: - - ~/.local/share/fonts/ - restore_cache: - key: fonts-2 + - save_cache: + key: fonts-2 + paths: + - ~/.local/share/fonts/ pip-install: description: Upgrade pip and setuptools and wheel to get as clean an install as possible From e9a1733afe06f9bf1b861821a70a99aa62b9daea Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 20 Apr 2020 23:47:17 -0400 Subject: [PATCH 3/4] Circle: Remove redundant store_artifacts steps. With re-usable commands, we can put those steps onto the command instead of in each job. --- .circleci/config.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f8b59221646..735742575a37 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -93,6 +93,8 @@ commands: 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 + - store_artifacts: + path: doc/build/sphinx-gallery-files.tar.gz ########################################## @@ -116,8 +118,6 @@ jobs: - doc-build - doc-bundle - - store_artifacts: - path: doc/build/sphinx-gallery-files.tar.gz - store_artifacts: path: doc/build/html @@ -138,8 +138,6 @@ jobs: - doc-build - doc-bundle - - store_artifacts: - path: doc/build/sphinx-gallery-files.tar.gz - store_artifacts: path: doc/build/html @@ -160,8 +158,6 @@ jobs: - doc-build - doc-bundle - - store_artifacts: - path: doc/build/sphinx-gallery-files.tar.gz - store_artifacts: path: doc/build/html From 4d656a5d97f594ee5744f1e961221e32328048c8 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 21 Apr 2020 00:25:08 -0400 Subject: [PATCH 4/4] Cache built doctrees on CircleCI. This probably doesn't save much time, but will save the intersphinx files in a cache that will hopefully reduce download errors. --- .circleci/config.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 735742575a37..f0201de420c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,6 +78,10 @@ commands: doc-build: steps: + - restore_cache: + keys: + - sphinx-env-v1-{{ .BuildNum }}-{{ .Environment.CIRCLE_JOB }} + - sphinx-env-v1-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}-{{ .Environment.CIRCLE_JOB }} - run: name: Build documentation command: | @@ -86,6 +90,10 @@ commands: make html O=-T rm -r build/html/_sources working_directory: doc + - save_cache: + key: sphinx-env-v1-{{ .BuildNum }}-{{ .Environment.CIRCLE_JOB }} + paths: + - doc/build/doctrees doc-bundle: steps: