| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
image: python:latest |
| 10 |
|
| 11 |
variables: |
| 12 |
|
| 13 |
|
| 14 |
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
cache: |
| 22 |
paths: |
| 23 |
- .cache/pip |
| 24 |
|
| 25 |
stages: |
| 26 |
- build |
| 27 |
- test |
| 28 |
- deploy |
| 29 |
|
| 30 |
build-package: |
| 31 |
stage: build |
| 32 |
script: |
| 33 |
- 'export PATH="$PATH:/root/.local/bin"' |
| 34 |
- python --version |
| 35 |
|
| 36 |
- python setup.py sdist --dist-dir=dist --formats=zip |
| 37 |
- pip install --user --upgrade pip |
| 38 |
|
| 39 |
- pip install --user -r test-requirements.txt -r requirements.txt virtualenv wheel |
| 40 |
artifacts: |
| 41 |
paths: |
| 42 |
- sdist |
| 43 |
untracked: true |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
.run-tests: |
| 48 |
needs: |
| 49 |
- build-package |
| 50 |
stage: test |
| 51 |
before_script: |
| 52 |
- 'export PATH="$PATH:/root/.local/bin"' |
| 53 |
- pip install --user --upgrade pip |
| 54 |
|
| 55 |
- pip install --user virtualenv |
| 56 |
- virtualenv ENV |
| 57 |
- source ENV/bin/activate |
| 58 |
|
| 59 |
- pip install dist/*.zip |
| 60 |
|
| 61 |
- python example.py |
| 62 |
|
| 63 |
- pip install -r test-requirements.txt |
| 64 |
|
| 65 |
- python3 -c 'import time; time.tzset(); print(time.strftime("%X %x %Z"))' |
| 66 |
script: |
| 67 |
- test/test_code_quality.sh |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
- coverage run -m pytest |
| 72 |
- coverage report |
| 73 |
- coverage xml |
| 74 |
artifacts: |
| 75 |
expire_in: 2 days |
| 76 |
reports: |
| 77 |
coverage_report: |
| 78 |
|
| 79 |
|
| 80 |
coverage_format: cobertura |
| 81 |
path: coverage.xml |
| 82 |
|
| 83 |
.env1: |
| 84 |
variables: |
| 85 |
TZ: Europe/Berlin |
| 86 |
|
| 87 |
.env2: |
| 88 |
variables: |
| 89 |
TZ: Australia/Sydney |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
test-python-2.7-env1: |
| 94 |
image: python:2.7 |
| 95 |
extends: |
| 96 |
- .run-tests |
| 97 |
- .env1 |
| 98 |
|
| 99 |
test-python-2.7-env2: |
| 100 |
image: python:2.7 |
| 101 |
extends: |
| 102 |
- .run-tests |
| 103 |
- .env2 |
| 104 |
|
| 105 |
test-python-3.7-env1: |
| 106 |
image: python:3.7 |
| 107 |
extends: |
| 108 |
- .run-tests |
| 109 |
- .env1 |
| 110 |
|
| 111 |
test-python-3.7-env2: |
| 112 |
image: python:3.7 |
| 113 |
extends: |
| 114 |
- .run-tests |
| 115 |
- .env2 |
| 116 |
|
| 117 |
test-python-3.8-env1: |
| 118 |
image: python:3.8 |
| 119 |
extends: |
| 120 |
- .run-tests |
| 121 |
- .env1 |
| 122 |
|
| 123 |
test-python-3.8-env2: |
| 124 |
image: python:3.8 |
| 125 |
extends: |
| 126 |
- .run-tests |
| 127 |
- .env2 |
| 128 |
|
| 129 |
test-python-3.9-env1: |
| 130 |
image: python:3.9 |
| 131 |
extends: |
| 132 |
- .run-tests |
| 133 |
- .env1 |
| 134 |
|
| 135 |
test-python-3.9-env2: |
| 136 |
image: python:3.9 |
| 137 |
extends: |
| 138 |
- .run-tests |
| 139 |
- .env2 |
| 140 |
|
| 141 |
test-python-3.10-env1: |
| 142 |
image: python:3.10 |
| 143 |
extends: |
| 144 |
- .run-tests |
| 145 |
- .env1 |
| 146 |
|
| 147 |
test-python-3.10-env2: |
| 148 |
image: python:3.10 |
| 149 |
extends: |
| 150 |
- .run-tests |
| 151 |
- .env2 |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
deploy-package: |
| 156 |
|
| 157 |
image: python:3.9 |
| 158 |
stage: deploy |
| 159 |
needs: |
| 160 |
- test-python-2.7-env1 |
| 161 |
- test-python-2.7-env2 |
| 162 |
- test-python-3.7-env1 |
| 163 |
- test-python-3.7-env2 |
| 164 |
- test-python-3.8-env1 |
| 165 |
- test-python-3.8-env2 |
| 166 |
- test-python-3.9-env1 |
| 167 |
- test-python-3.9-env2 |
| 168 |
- test-python-3.10-env1 |
| 169 |
- test-python-3.10-env2 |
| 170 |
before_script: |
| 171 |
- 'export PATH="$PATH:/root/.local/bin"' |
| 172 |
- pip install --user --upgrade pip |
| 173 |
|
| 174 |
- pip config set global.extra-index-url 'https://www.piwheels.org/simple' |
| 175 |
- pip config list |
| 176 |
- pip install --user wheel twine |
| 177 |
script: |
| 178 |
- PACKAGE_VERSION=`python setup.py --version` |
| 179 |
- TAG_NAME=v$PACKAGE_VERSION |
| 180 |
- echo "Package version $PACKAGE_VERSION with possible tag name $TAG_NAME on $CI_COMMIT_TAG" |
| 181 |
|
| 182 |
|
| 183 |
- '( if [ -n "$CI_COMMIT_TAG" ]; then if [ $TAG_NAME != $CI_COMMIT_TAG ]; then echo "This tag is for the wrong version. Got \"$CI_COMMIT_TAG\" expected \"$TAG_NAME\"."; exit 1; fi; fi; )' |
| 184 |
|
| 185 |
- rm -rf dist/* |
| 186 |
|
| 187 |
- python setup.py bdist_wheel sdist |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
- twine check dist/* |
| 197 |
- twine upload dist/* |
| 198 |
artifacts: |
| 199 |
paths: |
| 200 |
- dist/* |
| 201 |
only: |
| 202 |
|
| 203 |
|
| 204 |
- /^v[0-9]+\.[0-9]+\.[0-9a-z]+/ |
| 205 |
|