.gitlab-ci.yml 2.38 KB
Newer Older
Marek Chrastina's avatar
Marek Chrastina committed
1 2
stages:
  - test
Marek Chrastina's avatar
Marek Chrastina committed
3
  - build
4 5
  - check
  - deploy
Marek Chrastina's avatar
Marek Chrastina committed
6 7 8 9 10 11

mdcheck:
  stage: test
  image: it4innovations/docker-mdcheck:latest
  script:
    - mdl *.md
Marek Chrastina's avatar
Marek Chrastina committed
12

Marek Chrastina's avatar
Marek Chrastina committed
13 14 15 16
pycodestyle:
  stage: test
  image: it4innovations/docker-pycheck:latest
  script:
17
  - pycodestyle --max-line-length=100 --ignore=E265 *.py
Marek Chrastina's avatar
Marek Chrastina committed
18

Marek Chrastina's avatar
Marek Chrastina committed
19 20 21
pylint:
  stage: test
  image: it4innovations/docker-pycheck:latest
Marek Chrastina's avatar
Marek Chrastina committed
22
  before_script:
Marek Chrastina's avatar
Marek Chrastina committed
23 24
    - export PYTHONIOENCODING=UTF-8
    - export LC_CTYPE=en_US.UTF-8
25
    - python -W ignore::UserWarning:distutils.dist setup.py egg_info
Marek Chrastina's avatar
Marek Chrastina committed
26
    - pip install $(paste -d " " -s pipdeps.egg-info/requires.txt)
Marek Chrastina's avatar
Marek Chrastina committed
27
  script:
28
    - pylint $(find . -type f -not -path "*/.eggs/*" -name "*.py")
Marek Chrastina's avatar
Marek Chrastina committed
29 30 31 32 33 34 35

build:
  stage: build
  image: it4innovations/docker-pypi:latest
  artifacts:
    expire_in: 1 day
    paths:
Marek Chrastina's avatar
Marek Chrastina committed
36
      - dist/pipdeps*tar.gz
Marek Chrastina's avatar
Marek Chrastina committed
37
  before_script:
Marek Chrastina's avatar
Marek Chrastina committed
38 39
    - export PYTHONIOENCODING=UTF-8
    - export LC_CTYPE=en_US.UTF-8
40
    - pip install mustache pystache
Marek Chrastina's avatar
Marek Chrastina committed
41
  script:
Marek Chrastina's avatar
Marek Chrastina committed
42
    - echo "include_merge = False" >> .gitchangelog.rc
43
    - echo "output_engine = mustache(\"restructuredtext\")" >> .gitchangelog.rc
Marek Chrastina's avatar
Marek Chrastina committed
44 45
    - gitchangelog >> docs/HISTORY.txt
    - cat docs/HISTORY.txt
46 47 48
    - echo "output_engine = mustache(\"markdown\")" >> .gitchangelog.rc
    - echo >> README.md
    - gitchangelog | sed -r '1,/^# Changelog$/s/^(# Changelog)$/#\1/' >> README.md
Marek Chrastina's avatar
Marek Chrastina committed
49
    - python setup.py sdist
50 51 52 53

Install test:
  stage: check
  image: it4innovations/docker-pypi:latest
54 55
  before_script:
    - virtualenv .venv
56
  script:
57
    - source .venv/bin/activate
58
    - pip install dist/pipdeps*tar.gz
59
    - pip list
60 61 62 63 64 65
    - pipdeps -l || true
    - pipdeps -u

versioncheck:
  stage: check
  image: it4innovations/docker-pypi:latest
66 67
  before_script:
    - pip install packaging
68 69 70 71 72
  script:
    - python setup.py --version
    - export BUILD_VERSION="$(python setup.py --version)"
    - >-
         export PUBLISHED_VERSION="$(pip install pipdeps== 2>&1 | grep -oE "\(from versions: .*)" | sed "s/(from versions: //" | sed "s/)//" | tr ", " "\n" | tail -n1)"
Marek Chrastina's avatar
Marek Chrastina committed
73 74
    - CMP_VERSION="$(cmp-version $BUILD_VERSION $PUBLISHED_VERSION)"
    - if [ $CMP_VERSION -eq 1 ]; then true; else echo 'Git tag is older/same version as module already available from public pypi repository. Please run git tag -a <version> -m "<version>"'; false; fi
75 76 77 78 79 80

upload:
  stage: deploy
  image: it4innovations/docker-pypi:latest
  script:
    - twine upload -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" dist/pipdeps*tar.gz
81 82
  only:
    - master
83
  when: manual