|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +orbs: |
| 4 | + codeclimate: rohanpm/codeclimate@1.0.0 |
| 5 | + |
| 6 | +parameter-templates: ¶meter-templates |
| 7 | + py-version: &py-version-template |
| 8 | + description: "Python version to be used in the executor" |
| 9 | + default: "3.7" |
| 10 | + type: enum |
| 11 | + enum: |
| 12 | + - "2.7" |
| 13 | + - "3.4" |
| 14 | + - "3.5" |
| 15 | + - "3.6" |
| 16 | + - "3.7" |
| 17 | + |
| 18 | +executors: |
| 19 | + linux-docker: |
| 20 | + parameters: |
| 21 | + py-version: |
| 22 | + <<: *py-version-template |
| 23 | + working_directory: ~/pytest-sftpserver |
| 24 | + environment: |
| 25 | + PY_VERSION: << parameters.py-version >> |
| 26 | + docker: |
| 27 | + - image: circleci/python:<< parameters.py-version >> |
| 28 | + |
| 29 | +jobs: |
| 30 | + prepare: |
| 31 | + executor: |
| 32 | + name: linux-docker |
| 33 | + steps: |
| 34 | + - checkout |
| 35 | + - persist_to_workspace: |
| 36 | + root: "~" |
| 37 | + paths: |
| 38 | + - pytest-sftpserver |
| 39 | + |
| 40 | + lint: |
| 41 | + parameters: |
| 42 | + py-version: |
| 43 | + <<: *py-version-template |
| 44 | + skip-black: |
| 45 | + description: "Skip running black on old Python versions" |
| 46 | + type: boolean |
| 47 | + default: false |
| 48 | + executor: |
| 49 | + name: linux-docker |
| 50 | + py-version: << parameters.py-version >> |
| 51 | + steps: |
| 52 | + - attach_workspace: |
| 53 | + at: "~" |
| 54 | + - restore_cache: |
| 55 | + keys: |
| 56 | + - v1-pip-cache-<< parameters.py-version >>-{{ checksum "requirements-dev.txt" }} |
| 57 | + - v1-pip-cache-<< parameters.py-version >>- |
| 58 | + - run: |
| 59 | + name: Install deps |
| 60 | + command: | |
| 61 | + pip install --user -r requirements-dev.txt |
| 62 | + echo 'export PATH=~/.local/bin:${PATH}' >> ${BASH_ENV} |
| 63 | + - when: |
| 64 | + name: Workaround for black on old Python versions |
| 65 | + condition: << parameters.skip-black >> |
| 66 | + steps: |
| 67 | + - run: |
| 68 | + name: Link dummy black |
| 69 | + command: ln -s /bin/true ~/.local/bin/black |
| 70 | + - run: |
| 71 | + name: Lint |
| 72 | + command: make lint |
| 73 | + - save_cache: |
| 74 | + key: v1-pip-cache-<< parameters.py-version >>-{{ checksum "requirements-dev.txt" }} |
| 75 | + paths: |
| 76 | + - "~/.cache/pip" |
| 77 | + |
| 78 | + test: |
| 79 | + parameters: |
| 80 | + py-version: |
| 81 | + <<: *py-version-template |
| 82 | + executor: |
| 83 | + name: linux-docker |
| 84 | + py-version: << parameters.py-version >> |
| 85 | + steps: |
| 86 | + - attach_workspace: |
| 87 | + at: "~" |
| 88 | + - codeclimate/install_cc_test_reporter |
| 89 | + - run: |
| 90 | + name: Set Python version |
| 91 | + command: 'echo "export TOXENV=py${PY_VERSION/./}" >> ${BASH_ENV}' |
| 92 | + - restore_cache: |
| 93 | + keys: |
| 94 | + - v1-pip-cache-<< parameters.py-version >>-{{ checksum "requirements-dev.txt" }} |
| 95 | + - v1-pip-cache-<< parameters.py-version >>- |
| 96 | + - run: |
| 97 | + name: Install deps |
| 98 | + command: | |
| 99 | + pip install --user tox |
| 100 | + echo 'export PATH=~/.local/bin:${PATH}' >> ${BASH_ENV} |
| 101 | + - restore_cache: |
| 102 | + keys: |
| 103 | + - v1-tox-<< parameters.py-version >>-{{ checksum "requirements-dev.txt" }}-{{ checksum "setup.py" }} |
| 104 | + - v1-tox-<< parameters.py-version >>- |
| 105 | + - run: |
| 106 | + name: Prepare Code Climate |
| 107 | + command: cc-test-reporter before-build |
| 108 | + - run: |
| 109 | + name: Run tests |
| 110 | + command: tox |
| 111 | + - save_cache: |
| 112 | + key: v1-tox-<< parameters.py-version >>-{{ checksum "requirements-dev.txt" }}-{{ checksum "setup.py" }} |
| 113 | + paths: |
| 114 | + - "~/pytest-sftpserver/.tox" |
| 115 | + - persist_to_workspace: |
| 116 | + root: "~" |
| 117 | + paths: |
| 118 | + - "pytest-sftpserver/.coverage.*" |
| 119 | + |
| 120 | + finalize: |
| 121 | + executor: |
| 122 | + name: linux-docker |
| 123 | + steps: |
| 124 | + - attach_workspace: |
| 125 | + at: "~" |
| 126 | + - codeclimate/install_cc_test_reporter |
| 127 | + - run: |
| 128 | + name: Install coverage |
| 129 | + command: | |
| 130 | + pip install --user coverage |
| 131 | + echo 'export PATH=~/.local/bin:${PATH}' >> ${BASH_ENV} |
| 132 | + - run: |
| 133 | + name: Merge coverage |
| 134 | + command: | |
| 135 | + coverage combine |
| 136 | + coverage xml |
| 137 | + - run: |
| 138 | + name: Report to Code Climate |
| 139 | + command: cc-test-reporter after-build |
| 140 | + |
| 141 | +workflows: |
| 142 | + pr: |
| 143 | + jobs: |
| 144 | + - prepare |
| 145 | + |
| 146 | + - lint: |
| 147 | + name: lint-2.7 |
| 148 | + py-version: "2.7" |
| 149 | + skip-black: true |
| 150 | + requires: |
| 151 | + - prepare |
| 152 | + - lint: |
| 153 | + name: lint-3.5 |
| 154 | + py-version: "3.5" |
| 155 | + skip-black: true |
| 156 | + requires: |
| 157 | + - prepare |
| 158 | + - lint: |
| 159 | + name: lint-3.6 |
| 160 | + py-version: "3.6" |
| 161 | + requires: |
| 162 | + - prepare |
| 163 | + - lint: |
| 164 | + name: lint-3.7 |
| 165 | + py-version: "3.7" |
| 166 | + requires: |
| 167 | + - prepare |
| 168 | + |
| 169 | + - test: |
| 170 | + name: test-2.7 |
| 171 | + py-version: "2.7" |
| 172 | + requires: |
| 173 | + - lint-2.7 |
| 174 | + - test: |
| 175 | + name: test-3.5 |
| 176 | + py-version: "3.5" |
| 177 | + requires: |
| 178 | + - lint-3.5 |
| 179 | + - test: |
| 180 | + name: test-3.6 |
| 181 | + py-version: "3.6" |
| 182 | + requires: |
| 183 | + - lint-3.6 |
| 184 | + - test: |
| 185 | + name: test-3.7 |
| 186 | + py-version: "3.7" |
| 187 | + requires: |
| 188 | + - lint-3.7 |
| 189 | + |
| 190 | + - finalize: |
| 191 | + requires: |
| 192 | + - test-2.7 |
| 193 | + - test-3.5 |
| 194 | + - test-3.6 |
| 195 | + - test-3.7 |
0 commit comments