|
| 1 | +# Circle CI configuration file |
| 2 | +# https://circleci.com/docs/ |
| 3 | + |
| 4 | +version: 2.1 |
| 5 | + |
| 6 | + |
| 7 | +####################################### |
| 8 | +# Define some common steps as commands. |
| 9 | +# |
| 10 | + |
| 11 | +commands: |
| 12 | + check-skip: |
| 13 | + steps: |
| 14 | + - run: |
| 15 | + name: Check-skip |
| 16 | + command: | |
| 17 | + export git_log=$(git log --max-count=1 --pretty=format:"%B" | tr "\n" " ") |
| 18 | + echo "Got commit message:" |
| 19 | + echo "${git_log}" |
| 20 | + if [[ -v CIRCLE_PULL_REQUEST ]] && ([[ "$git_log" == *"[skip circle]"* ]] || [[ "$git_log" == *"[circle skip]"* ]]); then |
| 21 | + echo "Skip detected, exiting job ${CIRCLE_JOB} for PR ${CIRCLE_PULL_REQUEST}." |
| 22 | + circleci-agent step halt; |
| 23 | + fi |
| 24 | +
|
| 25 | + merge: |
| 26 | + steps: |
| 27 | + - run: |
| 28 | + name: Merge with upstream |
| 29 | + command: | |
| 30 | + if ! git remote -v | grep upstream; then |
| 31 | + git remote add upstream https://github.com/matplotlib/matplotlib.git |
| 32 | + fi |
| 33 | + git fetch upstream |
| 34 | + if [[ "$CIRCLE_BRANCH" != "main" ]] && \ |
| 35 | + [[ "$CIRCLE_PR_NUMBER" != "" ]]; then |
| 36 | + echo "Merging ${CIRCLE_PR_NUMBER}" |
| 37 | + git pull --ff-only upstream "refs/pull/${CIRCLE_PR_NUMBER}/merge" |
| 38 | + fi |
| 39 | +
|
| 40 | + apt-install: |
| 41 | + steps: |
| 42 | + - run: |
| 43 | + name: Install apt packages |
| 44 | + command: | |
| 45 | + sudo apt-get -qq update |
| 46 | + sudo apt-get install -yy --no-install-recommends \ |
| 47 | + cm-super \ |
| 48 | + dvipng \ |
| 49 | + ffmpeg \ |
| 50 | + fonts-crosextra-carlito \ |
| 51 | + fonts-freefont-otf \ |
| 52 | + fonts-humor-sans \ |
| 53 | + fonts-noto-cjk \ |
| 54 | + fonts-wqy-zenhei \ |
| 55 | + graphviz \ |
| 56 | + inkscape \ |
| 57 | + lmodern \ |
| 58 | + ninja-build \ |
| 59 | + optipng \ |
| 60 | + texlive-fonts-recommended \ |
| 61 | + texlive-latex-base \ |
| 62 | + texlive-latex-extra \ |
| 63 | + texlive-latex-recommended \ |
| 64 | + texlive-pictures \ |
| 65 | + texlive-xetex |
| 66 | +
|
| 67 | + fonts-install: |
| 68 | + steps: |
| 69 | + - restore_cache: |
| 70 | + key: fonts-2 |
| 71 | + - run: |
| 72 | + name: Install custom fonts |
| 73 | + command: | |
| 74 | + mkdir -p ~/.local/share/fonts |
| 75 | + wget -nc https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O ~/.local/share/fonts/Felipa-Regular.ttf || true |
| 76 | + fc-cache -f -v |
| 77 | + - save_cache: |
| 78 | + key: fonts-2 |
| 79 | + paths: |
| 80 | + - ~/.local/share/fonts/ |
| 81 | + |
| 82 | + pip-install: |
| 83 | + description: Upgrade pip and setuptools and wheel to get as clean an install as possible |
| 84 | + steps: |
| 85 | + - run: |
| 86 | + name: Upgrade pip, setuptools, wheel |
| 87 | + command: | |
| 88 | + python -m pip install --upgrade --user pip |
| 89 | + python -m pip install --upgrade --user wheel |
| 90 | + python -m pip install --upgrade --user 'setuptools!=60.6.0' |
| 91 | +
|
| 92 | + doc-deps-install: |
| 93 | + parameters: |
| 94 | + numpy_version: |
| 95 | + type: string |
| 96 | + default: "" |
| 97 | + steps: |
| 98 | + - run: |
| 99 | + name: Install Python dependencies |
| 100 | + command: | |
| 101 | + python -m pip install --user meson-python pybind11 |
| 102 | + python -m pip install --user \ |
| 103 | + numpy<< parameters.numpy_version >> \ |
| 104 | + -r requirements/doc/doc-requirements.txt |
| 105 | + python -m pip install --no-deps --user \ |
| 106 | + git+https://github.com/matplotlib/mpl-sphinx-theme.git |
| 107 | +
|
| 108 | + mpl-install: |
| 109 | + steps: |
| 110 | + - run: |
| 111 | + name: Install Matplotlib |
| 112 | + command: | |
| 113 | + if [[ "$CIRCLE_BRANCH" == v*-doc ]]; then |
| 114 | + # The v*-doc branches must build against the specified release. |
| 115 | + version=${CIRCLE_BRANCH%-doc} |
| 116 | + version=${version#v} |
| 117 | + python -m pip install matplotlib==${version} |
| 118 | + else |
| 119 | + python -m pip install --user --verbose \ |
| 120 | + --no-build-isolation --editable .[dev] |
| 121 | + fi |
| 122 | + - save_cache: |
| 123 | + key: build-deps-2 |
| 124 | + paths: |
| 125 | + - subprojects/packagecache |
| 126 | + |
| 127 | + doc-build: |
| 128 | + steps: |
| 129 | + - restore_cache: |
| 130 | + keys: |
| 131 | + - sphinx-env-v1-{{ .BuildNum }}-{{ .Environment.CIRCLE_JOB }} |
| 132 | + - sphinx-env-v1-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}-{{ .Environment.CIRCLE_JOB }} |
| 133 | + - run: |
| 134 | + name: Build documentation |
| 135 | + command: | |
| 136 | + # Set epoch to date of latest tag. |
| 137 | + export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))" |
| 138 | + # Set release mode only when deploying to devdocs. |
| 139 | + if [ "$CIRCLE_PROJECT_USERNAME" = "matplotlib" ] && \ |
| 140 | + [ "$CIRCLE_BRANCH" = "main" ] && \ |
| 141 | + [ "$CIRCLE_PR_NUMBER" = "" ]; then |
| 142 | + export RELEASE_TAG='-t release' |
| 143 | + fi |
| 144 | + mkdir -p logs |
| 145 | + make html O="-T $RELEASE_TAG -j4 -w /tmp/sphinxerrorswarnings.log" |
| 146 | + rm -r build/html/_sources |
| 147 | + working_directory: doc |
| 148 | + - save_cache: |
| 149 | + key: sphinx-env-v1-{{ .BuildNum }}-{{ .Environment.CIRCLE_JOB }} |
| 150 | + paths: |
| 151 | + - doc/build/doctrees |
| 152 | + |
| 153 | + doc-show-errors-warnings: |
| 154 | + steps: |
| 155 | + - run: |
| 156 | + name: Extract possible build errors and warnings |
| 157 | + command: | |
| 158 | + (grep "WARNING\|ERROR" /tmp/sphinxerrorswarnings.log || |
| 159 | + echo "No errors or warnings") |
| 160 | + # Save logs as an artifact, and convert from absolute paths to |
| 161 | + # repository-relative paths. |
| 162 | + sed "s~$PWD/~~" /tmp/sphinxerrorswarnings.log > \ |
| 163 | + doc/logs/sphinx-errors-warnings.log |
| 164 | + when: always |
| 165 | + - store_artifacts: |
| 166 | + path: doc/logs/sphinx-errors-warnings.log |
| 167 | + |
| 168 | + doc-show-deprecations: |
| 169 | + steps: |
| 170 | + - run: |
| 171 | + name: Extract possible deprecation warnings in examples and tutorials |
| 172 | + command: | |
| 173 | + (grep -rl DeprecationWarning doc/build/html/gallery || |
| 174 | + echo "No deprecation warnings in gallery") |
| 175 | + (grep -rl DeprecationWarning doc/build/html/plot_types || |
| 176 | + echo "No deprecation warnings in plot_types") |
| 177 | + (grep -rl DeprecationWarning doc/build/html/tutorials || |
| 178 | + echo "No deprecation warnings in tutorials") |
| 179 | + # Save deprecations that are from this absolute directory, and |
| 180 | + # convert to repository-relative paths. |
| 181 | + (grep -Ero --no-filename "$PWD/.+DeprecationWarning.+$" \ |
| 182 | + doc/build/html/{gallery,plot_types,tutorials} || echo) | \ |
| 183 | + sed "s~$PWD/~~" > doc/logs/sphinx-deprecations.log |
| 184 | + when: always |
| 185 | + - store_artifacts: |
| 186 | + path: doc/logs/sphinx-deprecations.log |
| 187 | + |
| 188 | + doc-bundle: |
| 189 | + steps: |
| 190 | + - run: |
| 191 | + name: Bundle sphinx-gallery documentation artifacts |
| 192 | + command: > |
| 193 | + tar cf doc/build/sphinx-gallery-files.tar.gz |
| 194 | + doc/api/_as_gen |
| 195 | + doc/gallery |
| 196 | + doc/plot_types |
| 197 | + doc/tutorials |
| 198 | + when: always |
| 199 | + - store_artifacts: |
| 200 | + path: doc/build/sphinx-gallery-files.tar.gz |
| 201 | + |
| 202 | + |
| 203 | +########################################## |
| 204 | +# Here is where the real jobs are defined. |
| 205 | +# |
| 206 | + |
| 207 | +jobs: |
| 208 | + docs-python39: |
| 209 | + docker: |
| 210 | + - image: cimg/python:3.9 |
| 211 | + resource_class: large |
| 212 | + steps: |
| 213 | + - checkout |
| 214 | + - check-skip |
| 215 | + - merge |
| 216 | + |
| 217 | + - apt-install |
| 218 | + - fonts-install |
| 219 | + - pip-install |
| 220 | + |
| 221 | + - doc-deps-install |
| 222 | + - mpl-install |
| 223 | + |
| 224 | + - doc-build |
| 225 | + - doc-show-errors-warnings |
| 226 | + - doc-show-deprecations |
| 227 | + |
| 228 | + - doc-bundle |
| 229 | + |
| 230 | + - store_artifacts: |
| 231 | + path: doc/build/html |
| 232 | + - store_test_results: |
| 233 | + path: doc/build/test-results |
| 234 | + |
| 235 | + - add_ssh_keys: |
| 236 | + fingerprints: |
| 237 | + - "be:c3:c1:d8:fb:a1:0e:37:71:72:d7:a3:40:13:8f:14" |
| 238 | + |
| 239 | + - deploy: |
| 240 | + name: "Deploy new docs" |
| 241 | + command: ./.circleci/deploy-docs.sh |
| 242 | + |
| 243 | +######################################### |
| 244 | +# Defining workflows gets us parallelism. |
| 245 | +# |
| 246 | + |
| 247 | +workflows: |
| 248 | + version: 2 |
| 249 | + build: |
| 250 | + jobs: |
| 251 | + # NOTE: If you rename this job, then you must update the `if` condition |
| 252 | + # and `circleci-jobs` option in `.github/workflows/circleci.yml`. |
| 253 | + - docs-python39 |
0 commit comments