Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.62 KiB
stages:
  - test
  - build
  - release

variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
  paths:
    - .cache/pip

linter:
  stage: test
  image: python:3

  cache:
    paths:
      - .cache/pip
      - .cache/pre-commit

  except:
    - schedules

  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
    PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"

  before_script:
    - pip install pre-commit

  script:
    - pre-commit run -a

tests:
  stage: test
  image: python:3.7

  cache:
    paths:
      - .cache/pip

  except:
    - schedules

  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

  before_script:
    - pip install tox

  script:
    - tox -e py37-unit

release-pypi:
  stage: release
  only:
    - tags
  environment:
    name: pypi
    url: https://pypi.org/project/teklia-toolbox

  before_script:
    - pip install twine setuptools wheel
    - echo "[distutils]" > ~/.pypirc
    - echo "index-servers =" >> ~/.pypirc
    - echo "  pypi" >> ~/.pypirc
    - echo "[pypi]" >> ~/.pypirc
    - echo "repository=https://upload.pypi.org/legacy/" >> ~/.pypirc
    - echo "username=$PYPI_release_USERNAME" >> ~/.pypirc
    - echo "password=$PYPI_release_PASSWORD" >> ~/.pypirc