Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.43 KiB
Newer Older
image: python

  - docs
  - release
    - pip3 install black 'pylint<3' 'isort[colors]<6'
    - pip3 install --editable .
    - black --check --diff --color .
    - isort --check --diff --color .
    - pylint src/finam

test:
  stage: test
  script:
    - pip3 install --editable .[test]
Martin Lange's avatar
Martin Lange committed
    - python -m pytest --cov finam --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
Sebastian Müller's avatar
Sebastian Müller committed
    paths:
      - cov
Martin Lange's avatar
Martin Lange committed
benchmark:
  stage: test
  script:
    - pip3 install --editable .[test]
    - python -m pytest -v benchmarks/ --benchmark-histogram bench/bench  --benchmark-sort name
  artifacts:
    paths:
      - bench
profile:
  stage: test
  before_script:
    - apt-get update -y
    - apt-get install -y graphviz
    - pip3 install graphviz gprof2dot
  script:
    - pip3 install --editable .[test]
    - ./benchmarks/run_profiling.sh
  artifacts:
    paths:
      - prof

Martin Lange's avatar
Martin Lange committed
doctest:
  stage: test
Martin Lange's avatar
Martin Lange committed
  script:
    - pip3 install --editable .[doc]
    # doctest does not detect tests in code files during the first run.
    # add a dummy build to generate .rst files before the actual tests
    - sphinx-build -b dummy docs/source docs/build
Martin Lange's avatar
Martin Lange committed
    - sphinx-build -b doctest docs/source docs/build

  stage: docs
  variables:
    GIT_STRATEGY: clone
    GIT_DEPTH: 0  # to have all tags
    - pip3 install --editable .[doc]
Sebastian Müller's avatar
Sebastian Müller committed
    - sphinx-build docs/source docs/build
    - mv docs/build public/
  artifacts:
    paths:
      - public

pages:
  stage: deploy
  script: "true"
  artifacts:
    paths:
      - public
  only:
    - main
build:
  stage: build
    GIT_STRATEGY: clone
    GIT_DEPTH: 0  # to have all tags
  script:
    - pip install build
    - python -m build
  artifacts:
    paths:
      - dist

pypi_test_release:
  stage: release
  script:
    - pip install twine
    - python -m twine upload -r testpypi -u __token__ -p ${TEST_PYPI_TOKEN} dist/*
  artifacts:
    paths:
      - dist

pypi_release:
  stage: release
    - pip install twine
    - python -m twine upload -u __token__ -p ${PYPI_TOKEN} dist/*
  artifacts:
    paths:
      - dist
  only:
    - tags