|
| 1 | +# Use the latest 2.1 version of CircleCI pipeline process engine. |
| 2 | +# See: https://circleci.com/docs/2.0/configuration-reference |
| 3 | +version: 2.1 |
| 4 | + |
| 5 | +# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects. |
| 6 | +# See: https://circleci.com/docs/2.0/orb-intro/ |
| 7 | +orbs: |
| 8 | + # The python orb contains a set of prepackaged CircleCI configuration you can use repeatedly in your configuration files |
| 9 | + # Orb commands and jobs help you with common scripting around a language/tool |
| 10 | + # so you dont have to copy and paste it everywhere. |
| 11 | + # See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python |
| 12 | + python: circleci/[email protected] |
| 13 | + |
| 14 | + |
| 15 | +executors: |
| 16 | + python-docker: # declares a reusable executor |
| 17 | + parameters: |
| 18 | + version: |
| 19 | + description: "version tag" |
| 20 | + default: "latest" |
| 21 | + type: string |
| 22 | + docker: |
| 23 | + - image: cimg/python:<<parameters.version>> |
| 24 | + |
| 25 | +# Define a job to be invoked later in a workflow. |
| 26 | +# See: https://circleci.com/docs/2.0/configuration-reference/#jobs |
| 27 | +jobs: |
| 28 | + build_and_test: |
| 29 | + parameters: |
| 30 | + version: |
| 31 | + description: "version tag" |
| 32 | + default: "latest" |
| 33 | + type: string |
| 34 | + executor: |
| 35 | + name: python-docker |
| 36 | + version: <<parameters.version>> |
| 37 | + |
| 38 | + steps: |
| 39 | + - checkout |
| 40 | + # - run: |
| 41 | + # name: Install System Dependencies |
| 42 | + # command: sudo apt-get update && sudo apt-get install -y libsndfile1 |
| 43 | + - python/install-packages: |
| 44 | + pkg-manager: pip |
| 45 | + # app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory. |
| 46 | + pip-dependency-file: requirements_dev.txt |
| 47 | + - run: |
| 48 | + name: Run tests |
| 49 | + command: pytest |
| 50 | + |
| 51 | + flake: |
| 52 | + parameters: |
| 53 | + version: |
| 54 | + description: "version tag" |
| 55 | + default: "latest" |
| 56 | + type: string |
| 57 | + executor: |
| 58 | + name: python-docker |
| 59 | + version: <<parameters.version>> |
| 60 | + |
| 61 | + steps: |
| 62 | + - checkout |
| 63 | + - python/install-packages: |
| 64 | + pkg-manager: pip |
| 65 | + # app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory. |
| 66 | + pip-dependency-file: requirements_dev.txt |
| 67 | + - run: |
| 68 | + name: Flake8 |
| 69 | + command: flake8 imkar |
| 70 | + |
| 71 | +# test_examples: |
| 72 | +# parameters: |
| 73 | +# version: |
| 74 | +# description: "version tag" |
| 75 | +# default: "latest" |
| 76 | +# type: string |
| 77 | +# executor: |
| 78 | +# name: python-docker |
| 79 | +# version: <<parameters.version>> |
| 80 | + |
| 81 | +# steps: |
| 82 | +# - checkout |
| 83 | +# # - run: |
| 84 | +# # name: Install System Dependencies |
| 85 | +# # command: sudo apt-get update && sudo apt-get install -y libsndfile1 |
| 86 | +# - python/install-packages: |
| 87 | +# pkg-manager: pip |
| 88 | +# # app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory. |
| 89 | +# pip-dependency-file: requirements_dev.txt |
| 90 | +# - run: |
| 91 | +# name: Examples |
| 92 | +# command: | |
| 93 | +# pip install -e . |
| 94 | +# pytest --nbmake examples/*.ipynb |
| 95 | + |
| 96 | + test_pypi_publish: |
| 97 | + parameters: |
| 98 | + version: |
| 99 | + description: "version tag" |
| 100 | + default: "latest" |
| 101 | + type: string |
| 102 | + executor: |
| 103 | + name: python-docker |
| 104 | + version: <<parameters.version>> |
| 105 | + |
| 106 | + steps: |
| 107 | + - checkout |
| 108 | + # - run: |
| 109 | + # name: Install System Dependencies |
| 110 | + # command: sudo apt-get update && sudo apt-get install -y libsndfile1 |
| 111 | + - python/install-packages: |
| 112 | + pkg-manager: pip |
| 113 | + # app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory. |
| 114 | + pip-dependency-file: requirements_dev.txt |
| 115 | + - run: |
| 116 | + name: deploy |
| 117 | + command: | # create whl, install twine and publish to Test PyPI |
| 118 | + python setup.py sdist bdist_wheel |
| 119 | + twine upload dist/* |
| 120 | +
|
| 121 | +# Invoke jobs via workflows |
| 122 | +# See: https://circleci.com/docs/2.0/configuration-reference/#workflows |
| 123 | +workflows: |
| 124 | + test: # Test workflow |
| 125 | + jobs: |
| 126 | + # Run tests for all python versions |
| 127 | + - build_and_test: |
| 128 | + matrix: |
| 129 | + parameters: |
| 130 | + version: |
| 131 | + - "3.7" |
| 132 | + - "3.8" |
| 133 | + - "3.9" |
| 134 | + - "3.10" |
| 135 | + - flake: |
| 136 | + matrix: |
| 137 | + parameters: |
| 138 | + version: |
| 139 | + - "3.9" |
| 140 | + requires: |
| 141 | + - build_and_test |
| 142 | + |
| 143 | + # - test_examples: |
| 144 | + # matrix: |
| 145 | + # parameters: |
| 146 | + # version: |
| 147 | + # - "3.9" |
| 148 | + # requires: |
| 149 | + # - build_and_test |
| 150 | + |
| 151 | + |
| 152 | +test_and_publish: |
| 153 | + # Test and publish on new git version tags |
| 154 | + # This requires its own workflow to successfully trigger the test and build |
| 155 | + jobs: |
| 156 | + - build_and_test: |
| 157 | + matrix: |
| 158 | + parameters: |
| 159 | + version: |
| 160 | + - "3.7" |
| 161 | + - "3.8" |
| 162 | + - "3.9" |
| 163 | + - "3.10" |
| 164 | + filters: |
| 165 | + branches: |
| 166 | + ignore: /.*/ |
| 167 | + # only act on version tags |
| 168 | + tags: |
| 169 | + only: /^v[0-9]+(\.[0-9]+)*$/ |
| 170 | + |
| 171 | + - flake: |
| 172 | + matrix: |
| 173 | + parameters: |
| 174 | + version: |
| 175 | + - "3.9" |
| 176 | + requires: |
| 177 | + - build_and_test |
| 178 | + filters: |
| 179 | + branches: |
| 180 | + ignore: /.*/ |
| 181 | + # only act on version tags |
| 182 | + tags: |
| 183 | + only: /^v[0-9]+(\.[0-9]+)*$/ |
| 184 | + |
| 185 | + # - test_examples: |
| 186 | + # matrix: |
| 187 | + # parameters: |
| 188 | + # version: |
| 189 | + # - "3.9" |
| 190 | + # requires: |
| 191 | + # - build_and_test |
| 192 | + # filters: |
| 193 | + # branches: |
| 194 | + # ignore: /.*/ |
| 195 | + # # only act on version tags |
| 196 | + # tags: |
| 197 | + # only: /^v[0-9]+(\.[0-9]+)*$/ |
| 198 | + |
| 199 | + - test_pypi_publish: |
| 200 | + matrix: |
| 201 | + parameters: |
| 202 | + version: |
| 203 | + - "3.9" |
| 204 | + requires: |
| 205 | + - build_and_test |
| 206 | + - flake |
| 207 | + # - test_examples |
| 208 | + filters: |
| 209 | + branches: |
| 210 | + ignore: /.*/ |
| 211 | + # only act on version tags |
| 212 | + tags: |
| 213 | + only: /^v[0-9]+(\.[0-9]+)*$/ |
0 commit comments