.gitlab-ci.yml
stages:
- test
- publish
.python:
image: python:3.7
stage: test
cache:
key: pip-cache
paths:
- .cache/pip
- .pytest_cache
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
before_script:
- pip install poetry
- poetry debug:info
- poetry config settings.virtualenvs.create false
- poetry --no-interaction install
pytest:
extends: .python
script:
- pytest --junitxml=pytest.xml --vcr-record=none
- coveralls
artifacts:
reports:
junit: pytest.xml
coverage: '/^TOTAL\s+\d+\s+\d+\s+(\d+\%)$/'
flake8:
extends: .python
script:
- flake8 --format=junit-xml --output-file flake8.xml
artifacts:
reports:
junit: flake8.xml
black:
extends: .python
cache:
key: black-cache
paths:
- .cache/pip
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
before_script:
- pip install -U black
script:
- black --check --verbose .
artifacts: {}
publish:
extends: .python
stage: publish
before_script:
- export LIB_VERSION=$(grep -Eo '__version__.*$' libtapedrive/__init__.py | sed -E 's/.*\=.\"(.+)\"/\1/')
- '[[ $LIB_VERSION == $CI_COMMIT_TAG ]] || exit 1'
- pip install poetry
- poetry debug:info
- poetry config settings.virtualenvs.create false
- poetry config http-basic.pypi "${PYPI_USERNAME}" "${PYPI_PASSWORD}"
script:
- poetry --build publish
only:
- tags