|
| 1 | +# Defined anchors for re-usable components |
| 2 | +references: |
| 3 | + restore_cache: &restore_cache |
| 4 | + restore_cache: |
| 5 | + key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }} |
| 6 | + install_dependencies: &install_dependencies |
| 7 | + run: |
| 8 | + name: Install Python deps in a venv |
| 9 | + command: | |
| 10 | + python3 -m venv venv |
| 11 | + . venv/bin/activate |
| 12 | + python3 -m pip install --upgrade pip |
| 13 | + pip install -r requirements.txt |
| 14 | + pip install setuptools wheel twine |
| 15 | + save_cache: &save_cache |
| 16 | + save_cache: |
| 17 | + key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }} |
| 18 | + paths: |
| 19 | + - "venv" |
| 20 | + run_unittests: &run_unittests |
| 21 | + run: |
| 22 | + name: Run unittests |
| 23 | + command: | |
| 24 | + . venv/bin/activate |
| 25 | + python3 -m unittest discover |
| 26 | + init_pypirc: &init_pypirc |
| 27 | + run: |
| 28 | + name: init .pypirc |
| 29 | + command: | |
| 30 | + echo -e "[pypi]" >> ~/.pypirc |
| 31 | + echo -e "username = __token__" >> ~/.pypirc |
| 32 | + echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc |
| 33 | + build_publish: &build_publish |
| 34 | + run: |
| 35 | + name: Build and publish |
| 36 | + command: | |
| 37 | + . venv/bin/activate |
| 38 | + python3 setup.py sdist bdist_wheel |
| 39 | + python3 -m twine upload dist/* |
| 40 | +
|
| 41 | +
|
| 42 | +# Actual jobs |
| 43 | +version: 2 |
| 44 | +jobs: |
| 45 | + test_all: |
| 46 | + working_directory: ~/pycorr |
| 47 | + docker: |
| 48 | + - image: circleci/python:3.7.1-stretch |
| 49 | + steps: |
| 50 | + - checkout |
| 51 | + - <<: *restore_cache |
| 52 | + - <<: *install_dependencies |
| 53 | + - <<: *save_cache |
| 54 | + - <<: *run_unittests |
| 55 | + |
| 56 | + pypi_publish: |
| 57 | + working_directory: ~/pycorr |
| 58 | + docker: |
| 59 | + - image: circleci/python:3.7.1-stretch |
| 60 | + steps: |
| 61 | + - checkout |
| 62 | + - <<: *restore_cache |
| 63 | + - <<: *install_dependencies |
| 64 | + - <<: *save_cache |
| 65 | + - <<: *run_unittests |
| 66 | + - <<: *init_pypirc |
| 67 | + - <<: *build_publish |
| 68 | + |
| 69 | +# defined workflows |
| 70 | +workflows: |
| 71 | + version: 2 |
| 72 | + test_dev: |
| 73 | + jobs: |
| 74 | + - test_all: |
| 75 | + filters: |
| 76 | + branches: |
| 77 | + only: |
| 78 | + - develop |
| 79 | + publish_master: |
| 80 | + jobs: |
| 81 | + - pypi_publish: |
| 82 | + filters: |
| 83 | + branches: |
| 84 | + only: |
| 85 | + - master |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
0 commit comments