Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.95 KiB
Newer Older
Tamas Gal's avatar
Tamas Gal committed
image: docker.km3net.de/base/python:3

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

cache:
  paths:
    - .cache/pip
    - venv/
  key: "$CI_COMMIT_REF_SLUG"

stages:
  - test
  - coverage
  - doc
Tamas Gal's avatar
Tamas Gal committed
  - release
Tamas Gal's avatar
Tamas Gal committed

.virtualenv_template: &virtualenv_definition |
  python -V
Tamas Gal's avatar
Tamas Gal committed
  python3 -m venv venv
Tamas Gal's avatar
Tamas Gal committed
  source venv/bin/activate
  pip install -U pip setuptools wheel
Tamas Gal's avatar
Tamas Gal committed
  hash -r
  pip freeze
Tamas Gal's avatar
Tamas Gal committed
  make install-dev
  pip freeze
Tamas Gal's avatar
Tamas Gal committed

.junit_template: &junit_definition
    artifacts:
      reports:
        junit: "reports/junit*.xml"

test-py3.6:
    image: docker.km3net.de/base/python:3.6
    stage: test
    script:
        - *virtualenv_definition
        - make test
    <<: *junit_definition

test-py3.7:
    image: docker.km3net.de/base/python:3.7
    stage: test
    script:
        - *virtualenv_definition
        - make test
    <<: *junit_definition

Tamas Gal's avatar
Tamas Gal committed
test-py3.8:
    image: docker.km3net.de/base/python:3.8
    stage: test
    script:
        - *virtualenv_definition
        - make test
    <<: *junit_definition

Tamas Gal's avatar
Tamas Gal committed
code-style:
    image: docker.km3net.de/base/python:3.7
    stage: test
    script:
        - *virtualenv_definition
Tamas Gal's avatar
Tamas Gal committed
        - make black-check
Tamas Gal's avatar
Tamas Gal committed
    allow_failure: true

coverage:
    image: docker.km3net.de/base/python:3.6
    stage: coverage
    script:
        - *virtualenv_definition
Tamas Gal's avatar
Tamas Gal committed
        - make install-dev
Tamas Gal's avatar
Tamas Gal committed
        - "make test-cov|grep TOTAL| awk '{printf \"COVERAGE: %.2f%%\", (1-$3/$2)*100 }'"
    coverage: '/COVERAGE:\s*([0-9]*\.[0-9]*%)/'
    #     - make test-cov
    # coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
    artifacts:
        paths:
            - reports/coverage


build-docs:
    image: docker.km3net.de/base/python:3.6
    stage: doc
    script:
        - *virtualenv_definition
        - cd doc && make clean && make html
    cache: {}

Tamas Gal's avatar
Tamas Gal committed
pages:
    image: docker.km3net.de/base/python:3.6
    stage: doc
    script:
        - *virtualenv_definition
        - cd doc && make clean && make html
        - mv _build/html ../public/
        - cd .. && mv reports/coverage public/coverage
    artifacts:
        paths:
            - public
    cache: {}
    only:
        - tags
        - master
Tamas Gal's avatar
Tamas Gal committed


pypi:
    image: docker.km3net.de/base/python:3
    stage: release
    cache: {}
    script:
Tamas Gal's avatar
Tamas Gal committed
        - pip install -U twine wheel
Tamas Gal's avatar
Tamas Gal committed
        - python setup.py sdist
Tamas Gal's avatar
Tamas Gal committed
        - python setup.py bdist_wheel
Tamas Gal's avatar
Tamas Gal committed
        - twine upload dist/*
    only:
        - tags
Tamas Gal's avatar
Tamas Gal committed

cc-lyon:
    image: docker.km3net.de/base/ci-helper:1
    stage: release
    script:
Tamas Gal's avatar
Tamas Gal committed
        - mkdir -p /root/.ssh && chmod 700 /root/.ssh
        - ssh-keyscan -H $IN2P3_HOST > ~/.ssh/known_hosts
        - chmod 600 /root/.ssh/known_hosts
Tamas Gal's avatar
Tamas Gal committed
        - sshpass -p $IN2P3_PASSWORD ssh -v $IN2P3_USERNAME@$IN2P3_HOST 'export MODULEPATH=/pbs/throng/km3net/modulefiles; source /usr/share/Modules/init/bash; module load python/3.7.5; pip install git+https://git.km3net.de/km3py/km3io.git'
Tamas Gal's avatar
Tamas Gal committed
    only:
        - tags
        - master