|
| 1 | +# Python CircleCI 2.0 configuration file |
| 2 | +# |
| 3 | +# Check https://circleci.com/docs/2.0/language-python/ for more details |
| 4 | +# |
| 5 | +version: 2.1 |
| 6 | + |
| 7 | +commands: |
| 8 | + attach_built_js: |
| 9 | + steps: |
| 10 | + - attach_workspace: |
| 11 | + at: npm-build |
| 12 | + - run: cp -r npm-build/dist hiplot/static/built |
| 13 | + |
| 14 | +jobs: |
| 15 | + mypy_pytest: |
| 16 | + docker: |
| 17 | + # specify the version you desire here |
| 18 | + - image: circleci/python:3.6 |
| 19 | + |
| 20 | + working_directory: ~/repo |
| 21 | + |
| 22 | + steps: |
| 23 | + - checkout |
| 24 | + - attach_workspace: |
| 25 | + at: hiplot/static |
| 26 | + - restore_cache: |
| 27 | + keys: |
| 28 | + - v2-mypy_pytest-dependencies-{{ checksum "requirements/main.txt" }}-{{ checksum "requirements/dev.txt" }} |
| 29 | + - run: |
| 30 | + name: install dependencies |
| 31 | + command: | |
| 32 | + python3 -m venv venv |
| 33 | + . venv/bin/activate |
| 34 | + pip install .[dev] |
| 35 | + - save_cache: |
| 36 | + paths: |
| 37 | + - ./venv |
| 38 | + key: v2-mypy_pytest-dependencies-{{ checksum "requirements/main.txt" }}-{{ checksum "requirements/dev.txt" }} |
| 39 | + - run: |
| 40 | + name: "Run mypy" |
| 41 | + when: always |
| 42 | + command: | |
| 43 | + . venv/bin/activate |
| 44 | + mypy --strict --implicit-reexport hiplot |
| 45 | + - run: |
| 46 | + name: Run tests |
| 47 | + when: always |
| 48 | + command: | |
| 49 | + . venv/bin/activate |
| 50 | + pytest hiplot --durations=10 |
| 51 | +
|
| 52 | + npm-build: |
| 53 | + docker: |
| 54 | + - image: node:8.10.0 |
| 55 | + steps: |
| 56 | + - checkout |
| 57 | + - run: npm install |
| 58 | + - run: mkdir -p npm-build/dist npm-build/dist-dev dist |
| 59 | + - run: npm run build-dev |
| 60 | + - run: mv dist/* npm-build/dist-dev/ |
| 61 | + - run: npm run build |
| 62 | + - run: npx tsc |
| 63 | + - run: mv dist/* npm-build/dist/ && mkdir -p hiplot/static/built/ && cp npm-build/dist/hiplot.bundle.js hiplot/static/built/ |
| 64 | + - store_artifacts: |
| 65 | + when: always |
| 66 | + path: npm-build |
| 67 | + - persist_to_workspace: |
| 68 | + root: npm-build |
| 69 | + paths: |
| 70 | + - dist |
| 71 | + - dist-dev |
| 72 | + - persist_to_workspace: |
| 73 | + root: hiplot/static |
| 74 | + paths: |
| 75 | + - built |
| 76 | + |
| 77 | + npm-deploy: |
| 78 | + docker: |
| 79 | + - image: node:8.10.0 |
| 80 | + steps: |
| 81 | + - checkout |
| 82 | + - attach_workspace: |
| 83 | + at: npm-build |
| 84 | + - run: |
| 85 | + name: Gather package files |
| 86 | + command: | |
| 87 | + mkdir pack |
| 88 | + sed -i "s/\"version\": \"0.0.0\",/\"version\": \"$CIRCLE_TAG\",/" package.json |
| 89 | + cp -r package.json tsconfig.json webpack.config.js README.md LICENSE src pack/ |
| 90 | + mv npm-build/dist pack/ |
| 91 | + rm pack/dist/hiplot-* # Leftover from setup.py |
| 92 | + - run: |
| 93 | + name: Authenticate with registry |
| 94 | + command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc |
| 95 | + - run: |
| 96 | + name: Publish |
| 97 | + command: cd pack && npm publish |
| 98 | + - store_artifacts: |
| 99 | + when: always |
| 100 | + path: pack |
| 101 | + |
| 102 | + browser_ci: |
| 103 | + docker: |
| 104 | + - image: selenium/standalone-chrome |
| 105 | + working_directory: ~/repo |
| 106 | + steps: |
| 107 | + - checkout |
| 108 | + - attach_built_js |
| 109 | + - restore_cache: |
| 110 | + keys: |
| 111 | + - v2-browser_ci-dependencies-{{ checksum "requirements/main.txt" }}-{{ checksum "requirements/dev.txt" }} |
| 112 | + - run: |
| 113 | + name: install dependencies |
| 114 | + command: | |
| 115 | + sudo apt-get update |
| 116 | + sudo apt-get install python3-venv git -y |
| 117 | + python3 -m venv venv |
| 118 | + . venv/bin/activate |
| 119 | + pip install --upgrade -e .[dev] |
| 120 | + - save_cache: |
| 121 | + paths: |
| 122 | + - ./venv |
| 123 | + key: v2-browser_ci-dependencies-{{ checksum "requirements/main.txt" }}-{{ checksum "requirements/dev.txt" }} |
| 124 | + - run: |
| 125 | + name: Generate pages and end to end testing |
| 126 | + when: always |
| 127 | + command: | |
| 128 | + . venv/bin/activate |
| 129 | + mkdir artifacts |
| 130 | + rm -rf .circleci/demo_pages && mkdir .circleci/demo_pages |
| 131 | + PAGES=`python -c "import hiplot.fetchers; print(\"\n\".join(list(hiplot.fetchers.README_DEMOS.keys())))"` |
| 132 | + for p in $PAGES; do echo $p; hiplot-render --format html $p > .circleci/demo_pages/$p.html; done |
| 133 | + pytest -s .circleci/test_e2e.py |
| 134 | + - run: |
| 135 | + name: Collect artifacts... |
| 136 | + command: mv .circleci/demo_pages artifacts/provided |
| 137 | + - run: |
| 138 | + name: Generate pages and end to end testing (dev bundle) |
| 139 | + when: always |
| 140 | + command: | |
| 141 | + . venv/bin/activate |
| 142 | + rm -rf hiplot/static/built/* |
| 143 | + cp -r npm-build/dist-dev/* hiplot/static/built |
| 144 | + pip install --upgrade -e .[dev] |
| 145 | + rm -rf .circleci/demo_pages && mkdir .circleci/demo_pages |
| 146 | + PAGES=`python -c "import hiplot.fetchers; print(\"\n\".join(list(hiplot.fetchers.README_DEMOS.keys())))"` |
| 147 | + for p in $PAGES; do echo $p; hiplot-render --format html $p > .circleci/demo_pages/$p.html; done |
| 148 | + pytest -s .circleci/test_e2e.py |
| 149 | + - run: |
| 150 | + name: Collect artifacts... |
| 151 | + when: always |
| 152 | + command: mv .circleci/demo_pages artifacts/dev |
| 153 | + - store_artifacts: |
| 154 | + when: always |
| 155 | + path: ~/repo/artifacts |
| 156 | + |
| 157 | + docs-build: |
| 158 | + docker: |
| 159 | + - image: python:3.7 |
| 160 | + steps: |
| 161 | + - checkout |
| 162 | + - attach_built_js |
| 163 | + - run: |
| 164 | + name: install dependencies |
| 165 | + command: | |
| 166 | + apt-get update |
| 167 | + apt-get install python3-venv git -y |
| 168 | + python3 -m venv venv |
| 169 | + . venv/bin/activate |
| 170 | + pip install --upgrade -e .[dev] |
| 171 | + - run: |
| 172 | + name: Generate HiPlot demos |
| 173 | + command: | |
| 174 | + . venv/bin/activate |
| 175 | + mkdir -p docs/_static/demo/ |
| 176 | + PAGES=`python -c "import hiplot.fetchers; print(\"\n\".join(list(hiplot.fetchers.README_DEMOS.keys())))"` |
| 177 | + for p in $PAGES; do echo $p; hiplot-render --format html $p > docs/_static/demo/$p.html; done |
| 178 | + - run: |
| 179 | + name: Generate other demos |
| 180 | + command: | |
| 181 | + . venv/bin/activate |
| 182 | + DATA_PATH="assets/data" |
| 183 | + EXPERIMENTS=`(cd $DATA_PATH && ls)` |
| 184 | + for p in $EXPERIMENTS; do echo $p; hiplot-render --format html $DATA_PATH/$p > docs/_static/demo/$p.html; done |
| 185 | + - run: cp hiplot/static/built/hiplot.bundle.js docs/_static/hiplot.bundle.js |
| 186 | + - run: |
| 187 | + name: Build docs |
| 188 | + command: | |
| 189 | + . venv/bin/activate |
| 190 | + cd docs/ && make html |
| 191 | + - persist_to_workspace: |
| 192 | + root: docs/_build |
| 193 | + paths: html |
| 194 | + - store_artifacts: |
| 195 | + when: always |
| 196 | + path: docs/_build/html |
| 197 | + |
| 198 | + docs-deploy: |
| 199 | + docker: |
| 200 | + - image: node:8.10.0 |
| 201 | + steps: |
| 202 | + - checkout |
| 203 | + - add_ssh_keys: |
| 204 | + fingerprints: |
| 205 | + - "25:76:4d:1b:f0:5b:72:cb:97:43:fd:35:c9:16:85:2c" |
| 206 | + - attach_workspace: |
| 207 | + at: docs/_build |
| 208 | + - run: |
| 209 | + name: Install and configure dependencies |
| 210 | + command: | |
| 211 | + npm install -g --silent [email protected] |
| 212 | + git config user.email "ci-build" |
| 213 | + git config user.name "ci-build" |
| 214 | + - run: |
| 215 | + name: Deploy docs to gh-pages branch |
| 216 | + command: gh-pages --dotfiles --message "[skip ci] Updates" --dist docs/_build/html |
| 217 | + |
| 218 | + pypi-build: |
| 219 | + docker: |
| 220 | + - image: python:3.7 |
| 221 | + steps: |
| 222 | + - checkout |
| 223 | + - attach_workspace: |
| 224 | + at: hiplot/static |
| 225 | + - run: |
| 226 | + name: install dependencies |
| 227 | + command: | |
| 228 | + apt-get update |
| 229 | + apt-get install python3-venv -y |
| 230 | + python3 -m venv venv |
| 231 | + . venv/bin/activate |
| 232 | + pip install -r requirements/dev.txt |
| 233 | + - run: |
| 234 | + name: verify git tag vs. version |
| 235 | + command: | |
| 236 | + . venv/bin/activate |
| 237 | + python setup.py verify |
| 238 | + - run: |
| 239 | + name: create packages |
| 240 | + command: | |
| 241 | + . venv/bin/activate |
| 242 | + rm -rf dist && mkdir dist pypi-build |
| 243 | + # create a source distribution |
| 244 | + python setup.py sdist |
| 245 | + # create a wheel |
| 246 | + python setup.py bdist_wheel |
| 247 | + mv dist pypi-build |
| 248 | + - run: |
| 249 | + name: verify package |
| 250 | + command: | |
| 251 | + . ./venv/bin/activate |
| 252 | + twine check pypi-build/dist/* |
| 253 | + - persist_to_workspace: |
| 254 | + root: pypi-build |
| 255 | + paths: dist |
| 256 | + - store_artifacts: |
| 257 | + when: always |
| 258 | + path: pypi-build |
| 259 | + |
| 260 | + pypi-deploy: |
| 261 | + docker: |
| 262 | + - image: python:3.7 |
| 263 | + steps: |
| 264 | + - attach_workspace: |
| 265 | + at: pypi-build |
| 266 | + - run: |
| 267 | + name: init .pypirc |
| 268 | + command: | |
| 269 | + echo -e "[pypi]" >> ~/.pypirc |
| 270 | + echo -e "username = danthe3rd" >> ~/.pypirc |
| 271 | + echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc |
| 272 | + - run: |
| 273 | + name: upload to pypi |
| 274 | + command: | |
| 275 | + python3 -m venv venv |
| 276 | + . venv/bin/activate |
| 277 | + pip install twine |
| 278 | + du -h pypi-build/dist/* |
| 279 | + twine upload pypi-build/dist/hiplot-* |
| 280 | +workflows: |
| 281 | + version: 2 |
| 282 | + all_ci: |
| 283 | + jobs: |
| 284 | + - npm-build: |
| 285 | + filters: |
| 286 | + tags: |
| 287 | + only: /.*/ |
| 288 | + - mypy_pytest: |
| 289 | + requires: |
| 290 | + - npm-build |
| 291 | + filters: |
| 292 | + tags: |
| 293 | + only: /.*/ |
| 294 | + - browser_ci: |
| 295 | + requires: |
| 296 | + - npm-build |
| 297 | + filters: |
| 298 | + tags: |
| 299 | + only: /.*/ |
| 300 | + - docs-build: |
| 301 | + requires: |
| 302 | + - npm-build |
| 303 | + filters: |
| 304 | + tags: |
| 305 | + only: /.*/ |
| 306 | + - docs-deploy: |
| 307 | + requires: |
| 308 | + - docs-build |
| 309 | + filters: |
| 310 | + branches: |
| 311 | + only: master |
| 312 | + - pypi-build: |
| 313 | + requires: |
| 314 | + - npm-build |
| 315 | + filters: |
| 316 | + tags: |
| 317 | + only: /(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/ |
| 318 | + branches: |
| 319 | + ignore: /.*/ |
| 320 | + - pypi-deploy: |
| 321 | + requires: |
| 322 | + - pypi-build |
| 323 | + - npm-build |
| 324 | + - docs-build |
| 325 | + - browser_ci |
| 326 | + - mypy_pytest |
| 327 | + filters: |
| 328 | + tags: |
| 329 | + only: /(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/ |
| 330 | + branches: |
| 331 | + ignore: /.*/ |
| 332 | + - npm-deploy: |
| 333 | + requires: |
| 334 | + - pypi-build |
| 335 | + - npm-build |
| 336 | + - docs-build |
| 337 | + - browser_ci |
| 338 | + - mypy_pytest |
| 339 | + filters: |
| 340 | + tags: |
| 341 | + only: /(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/ |
| 342 | + branches: |
| 343 | + ignore: /.*/ |
0 commit comments