Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.7 KiB
Newer Older
image: python:3.11
Sebastian Müller's avatar
Sebastian Müller committed

stages:
  - test
Sebastian Müller's avatar
Sebastian Müller committed
  - build
  - docs
Sebastian Müller's avatar
Sebastian Müller committed
  - deploy
  - release
Sebastian Müller's avatar
Sebastian Müller committed

check:
  stage: test
Sebastian Müller's avatar
Sebastian Müller committed
  before_script:
    - pip3 install 'black>=23,<24' 'pylint<3' 'isort[colors]<6'
Sebastian Müller's avatar
Sebastian Müller committed
  script:
    - pip3 install --editable .
Sebastian Müller's avatar
Sebastian Müller committed
    - black --check --diff --color .
    - isort --check --diff --color .
    - pylint src/finam_mhm

test:
  stage: test
  script:
Sebastian Müller's avatar
Sebastian Müller committed
    - pip3 install --editable .[test]
    - python -m pytest --cov finam_mhm --cov-report term-missing --cov-report html:cov --cov-report xml:cov.xml -v tests/
  coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: cov.xml
    paths:
      - cov

build:
  stage: build
  variables:
    GIT_STRATEGY: clone
    GIT_DEPTH: 0  # to have all tags
  script:
    - pip install build
    - python -m build
  artifacts:
    paths:
      - dist

documentation:
  stage: docs
  variables:
    GIT_STRATEGY: clone
    GIT_DEPTH: 0  # to have all tags
  script:
    - pip3 install --editable .[doc]
    - sphinx-build docs/source docs/build
    - mv docs/build public/
  artifacts:
    paths:
      - public

pages:
  stage: deploy
  script: "true"
  artifacts:
    paths:
      - public
  only:
    - main

pypi_test_release:
  stage: release
  dependencies:
    - build
  script:
    - pip install twine
    - python -m twine upload --skip-existing -r testpypi -u __token__ -p ${TEST_PYPI_TOKEN} dist/*
  artifacts:
    paths:
      - dist
  only:
    - main
    - tags
pypi_release:
  stage: release
  dependencies:
    - build
  script:
    - pip install twine
    - python -m twine upload -u __token__ -p ${PYPI_TOKEN} dist/*
  artifacts:
    paths:
      - dist
  only:
    - tags