|
1 |
| -# Use the latest 2.1 version of CircleCI pipeline process engine. |
2 |
| -# See: https://circleci.com/docs/2.0/configuration-reference |
3 | 1 | version: 2.1
|
4 | 2 |
|
5 |
| -# Define a job to be invoked later in a workflow. |
6 |
| -# See: https://circleci.com/docs/2.0/configuration-reference/#jobs |
7 | 3 | jobs:
|
8 |
| - say-hello: |
9 |
| - # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. |
10 |
| - # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor |
11 |
| - docker: |
12 |
| - - image: cimg/base:stable |
13 |
| - # Add steps to the job |
14 |
| - # See: https://circleci.com/docs/2.0/configuration-reference/#steps |
15 |
| - steps: |
16 |
| - - checkout |
17 |
| - - run: |
18 |
| - name: "Say hello" |
19 |
| - command: "echo Hello, World!" |
| 4 | + build_doc: |
| 5 | + docker: |
| 6 | + - image: cimg/base:stable-20.04 |
| 7 | + steps: |
| 8 | + - restore_cache: |
| 9 | + name: Restore .git |
| 10 | + keys: |
| 11 | + - source-cache-graphs |
| 12 | + - checkout |
| 13 | + - run: |
| 14 | + name: Complete checkout |
| 15 | + command: | |
| 16 | + if ! git remote -v | grep upstream; then |
| 17 | + git remote add upstream https://github.com/py-why/dodiscover.git |
| 18 | + fi |
| 19 | + git remote set-url upstream https://github.com/py-why/dodiscover.git |
| 20 | + git fetch upstream |
| 21 | + - save_cache: |
| 22 | + name: Save .git |
| 23 | + key: source-cache-graphs |
| 24 | + paths: |
| 25 | + - ".git" |
| 26 | + - run: |
| 27 | + name: Check-skip |
| 28 | + command: | |
| 29 | + set -e |
| 30 | + export COMMIT_MESSAGE=$(git log --format=oneline -n 1); |
| 31 | + if [[ -v CIRCLE_PULL_REQUEST ]] && ([[ "$COMMIT_MESSAGE" == *"[skip circle]"* ]] || [[ "$COMMIT_MESSAGE" == *"[circle skip]"* ]]); then |
| 32 | + echo "Skip detected, exiting job ${CIRCLE_JOB} for PR ${CIRCLE_PULL_REQUEST}." |
| 33 | + circleci-agent step halt; |
| 34 | + fi |
| 35 | + - run: |
| 36 | + name: Merge with upstream |
| 37 | + command: | |
| 38 | + echo $(git log -1 --pretty=%B) | tee gitlog.txt |
| 39 | + echo ${CI_PULL_REQUEST//*pull\//} | tee merge.txt |
| 40 | + if [[ $(cat merge.txt) != "" ]]; then |
| 41 | + echo "Merging $(cat merge.txt)"; |
| 42 | + git pull --ff-only upstream "refs/pull/$(cat merge.txt)/merge"; |
| 43 | + fi |
| 44 | + - run: |
| 45 | + name: Set BASH_ENV |
| 46 | + command: | |
| 47 | + set -e |
| 48 | + sudo apt install -qq graphviz optipng python3.8-venv python3-venv libxft2 |
| 49 | + python3.8 -m venv ~/python_env |
| 50 | + echo "set -e" >> $BASH_ENV |
| 51 | + echo "export OPENBLAS_NUM_THREADS=4" >> $BASH_ENV |
| 52 | + echo "export XDG_RUNTIME_DIR=/tmp/runtime-circleci" >> $BASH_ENV |
| 53 | + echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV |
| 54 | + echo "export DISPLAY=:99" >> $BASH_ENV |
| 55 | + echo "source ~/python_env/bin/activate" >> $BASH_ENV |
| 56 | + mkdir -p ~/.local/bin |
| 57 | + ln -s ~/python_env/bin/python ~/.local/bin/python |
| 58 | + echo "BASH_ENV:" |
| 59 | + cat $BASH_ENV |
| 60 | + - run: |
| 61 | + name: Setup pandoc |
| 62 | + command: sudo apt update && sudo apt install -y pandoc optipng |
| 63 | + - restore_cache: |
| 64 | + name: Restore pip cache |
| 65 | + keys: |
| 66 | + - pip-cache |
| 67 | + - restore_cache: |
| 68 | + name: Restore install-bin-cache |
| 69 | + keys: |
| 70 | + - user-install-bin-cache |
| 71 | + - run: |
| 72 | + name: Get Python running and install dependencies |
| 73 | + command: | |
| 74 | + python -m pip install --progress-bar off --upgrade pip setuptools wheel poetry |
| 75 | + poetry install |
| 76 | + - save_cache: |
| 77 | + name: Save pip cache |
| 78 | + key: pip-cache |
| 79 | + paths: |
| 80 | + - ~/.cache/pip |
| 81 | + - save_cache: |
| 82 | + name: Save install-bin-cache |
| 83 | + key: user-install-bin-cache |
| 84 | + paths: |
| 85 | + - ~/.local/lib/python3.8/site-packages |
| 86 | + - ~/.local/bin |
| 87 | + - run: |
| 88 | + name: Check pip package versions |
| 89 | + command: pip freeze |
| 90 | + - run: |
| 91 | + name: Check installation |
| 92 | + command: | |
| 93 | + LIBGL_DEBUG=verbose python -c "import matplotlib.pyplot as plt; plt.figure()" |
| 94 | + python -c "import dodiscover;" |
| 95 | + python -c "import numpy; numpy.show_config()" |
| 96 | + - run: |
| 97 | + name: Build documentation |
| 98 | + command: | |
| 99 | + cd doc |
| 100 | + make html |
| 101 | + # Save the example test results |
| 102 | + - store_test_results: |
| 103 | + path: doc/_build/test-results |
| 104 | + - store_artifacts: |
| 105 | + path: doc/_build/test-results |
| 106 | + destination: test-results |
| 107 | + # Save the SG RST |
| 108 | + - store_artifacts: |
| 109 | + path: doc/auto_examples.zip |
| 110 | + - store_artifacts: |
| 111 | + path: doc/generated.zip |
| 112 | + # Save the outputs |
| 113 | + - store_artifacts: |
| 114 | + path: doc/_build/html/ |
| 115 | + destination: dev |
| 116 | + - store_artifacts: |
| 117 | + path: doc/_build/html_stable/ |
| 118 | + destination: stable |
| 119 | + - persist_to_workspace: |
| 120 | + root: doc/_build |
| 121 | + paths: |
| 122 | + - html |
| 123 | + - html_stable |
| 124 | + |
| 125 | + linkcheck: |
| 126 | + parameters: |
| 127 | + scheduled: |
| 128 | + type: string |
| 129 | + default: "false" |
| 130 | + docker: |
| 131 | + - image: cimg/python:3.9.2 |
| 132 | + steps: |
| 133 | + - restore_cache: |
| 134 | + keys: |
| 135 | + - source-cache-graphs |
| 136 | + - checkout |
| 137 | + - run: |
| 138 | + name: Check-skip |
| 139 | + command: | |
| 140 | + export COMMIT_MESSAGE=$(git log --format=oneline -n 1); |
| 141 | + if [[ "$COMMIT_MESSAGE" != *"[circle linkcheck]"* ]] && [ "<< parameters.scheduled >>" != "true" ]; then |
| 142 | + echo "Skip detected, exiting job ${CIRCLE_JOB}." |
| 143 | + circleci-agent step halt; |
| 144 | + fi |
| 145 | + - run: |
| 146 | + name: Set BASH_ENV |
| 147 | + command: | |
| 148 | + set -e |
| 149 | + echo "set -e" >> $BASH_ENV |
| 150 | + echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV |
| 151 | + - restore_cache: |
| 152 | + keys: |
| 153 | + - pip-cache |
| 154 | + - run: |
| 155 | + name: Get Python running |
| 156 | + command: | |
| 157 | + python -m pip install --progress-bar off --upgrade pip setuptools wheel |
| 158 | + python -m pip install --progress-bar off .[doc] |
| 159 | + - run: |
| 160 | + name: make linkcheck |
| 161 | + command: | |
| 162 | + make -C doc linkcheck |
| 163 | + - run: |
| 164 | + name: make linkcheck-grep |
| 165 | + when: always |
| 166 | + command: | |
| 167 | + make -C doc linkcheck-grep |
| 168 | + - store_artifacts: |
| 169 | + path: doc/_build/linkcheck |
| 170 | + destination: linkcheck |
| 171 | + |
| 172 | + deploy: |
| 173 | + docker: |
| 174 | + - image: cimg/node:lts |
| 175 | + steps: |
| 176 | + - checkout |
| 177 | + |
| 178 | + - attach_workspace: |
| 179 | + at: doc/_build |
| 180 | + - run: |
| 181 | + name: Set BASH_ENV |
| 182 | + command: | |
| 183 | + set -e |
| 184 | + echo "set -e" >> $BASH_ENV |
| 185 | + # Don't try to deploy if nothing is there or not on the right branch |
| 186 | + - run: |
| 187 | + name: Check docs |
| 188 | + command: | |
| 189 | + if [ ! -f doc/_build/html/index.html ] && [ ! -f doc/_build/html_stable/index.html ]; then |
| 190 | + echo "No files found to upload (build: ${CIRCLE_BRANCH})."; |
| 191 | + circleci-agent step halt; |
| 192 | + fi; |
| 193 | + - run: |
| 194 | + name: Install and configure dependencies |
| 195 | + # do not update gh-pages above 3.0.0 |
| 196 | + # see: https://github.com/tschaub/gh-pages/issues/354 |
| 197 | + command: | |
| 198 | + npm install gh-pages@3.0 |
| 199 | + git config --global user.email "circle@pywhy.com" |
| 200 | + git config --global user.name "Circle Ci" |
| 201 | + - add_ssh_keys: |
| 202 | + fingerprints: |
| 203 | + - "b5:1e:a1:6d:8d:48:f2:8f:dd:bd:2d:66:a9:30:fe:b9" |
| 204 | + - run: |
| 205 | + # push built doc into the `dev` directory on the `gh-pages` branch |
| 206 | + name: Deploy doc to gh-pages branch |
| 207 | + command: | |
| 208 | + if [ "${CIRCLE_BRANCH}" == "main" ]; then |
| 209 | + echo "Deploying dev doc for ${CIRCLE_BRANCH}."; |
| 210 | + node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist doc/_build/html --dest ./dev |
| 211 | + else |
| 212 | + echo "Deploying stable doc for ${CIRCLE_BRANCH}."; |
| 213 | + node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist doc/_build/html_stable --dest ./stable |
| 214 | + fi; |
20 | 215 |
|
21 |
| -# Invoke jobs via workflows |
22 |
| -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows |
23 | 216 | workflows:
|
24 |
| - say-hello-workflow: |
| 217 | + default: |
| 218 | + jobs: |
| 219 | + - build_doc: |
| 220 | + name: build_doc |
| 221 | + - linkcheck: |
| 222 | + name: linkcheck |
| 223 | + - deploy: |
| 224 | + requires: |
| 225 | + - build_doc |
| 226 | + filters: |
| 227 | + branches: |
| 228 | + only: |
| 229 | + - main |
| 230 | + - maint/0.2 |
| 231 | + |
| 232 | + main: |
| 233 | + jobs: |
| 234 | + - build_doc: |
| 235 | + name: build_doc_main |
| 236 | + - deploy: |
| 237 | + name: deploy_main |
| 238 | + requires: |
| 239 | + - build_doc_main |
| 240 | + triggers: |
| 241 | + - schedule: |
| 242 | + # "At 00:00" (once a day) should be enough "0 0 * * *", |
| 243 | + # But for testing at first, let's do once an hour (6 AM GMT) |
| 244 | + cron: "0 6 * * *" |
| 245 | + filters: |
| 246 | + branches: |
| 247 | + only: |
| 248 | + - main |
| 249 | + |
| 250 | + weekly: |
25 | 251 | jobs:
|
26 |
| - - say-hello |
| 252 | + - linkcheck: |
| 253 | + name: linkcheck_weekly |
| 254 | + scheduled: "true" |
| 255 | + triggers: |
| 256 | + - schedule: |
| 257 | + # "At 00:00 on Sunday" should be often enough |
| 258 | + cron: "0 0 * * 0" |
| 259 | + filters: |
| 260 | + branches: |
| 261 | + only: |
| 262 | + - main |
0 commit comments