.gitlab-ci.yml 2.77 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
Marek Chrastina's avatar
Marek Chrastina committed
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:
Marek Chrastina's avatar
Marek Chrastina committed
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
Marek Chrastina's avatar
Marek Chrastina committed
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
Marek Chrastina's avatar
Marek Chrastina committed
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
Marek Chrastina's avatar
Marek Chrastina committed
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

Marek Chrastina's avatar
Marek Chrastina committed
51 52 53 54 55 56 57 58 59 60 61 62 63
python safety:
  stage: check
  image: it4innovations/docker-pycheck:latest
  before_script:
    - virtualenv .venv
  script:
    - source .venv/bin/activate
    - pip install --upgrade pip setuptools
    - pip install dist/pipdeps*tar.gz
    - pip list
    - pip freeze | safety check --stdin --full-report

install test:
64 65
  stage: check
  image: it4innovations/docker-pypi:latest
66 67
  before_script:
    - virtualenv .venv
68
  script:
69
    - source .venv/bin/activate
70
    - pip install --upgrade pip setuptools
71
    - pip install dist/pipdeps*tar.gz
Marek Chrastina's avatar
Marek Chrastina committed
72
    - pip list
73 74 75
    - pipdeps --list || true
    - pipdeps --table || true
    - pipdeps --upgrade
76

Marek Chrastina's avatar
Marek Chrastina committed
77
version check:
78 79
  stage: check
  image: it4innovations/docker-pypi:latest
Marek Chrastina's avatar
Marek Chrastina committed
80 81
  before_script:
    - pip install packaging
82 83 84 85 86
  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
87 88
    - 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
89 90 91 92 93 94

upload:
  stage: deploy
  image: it4innovations/docker-pypi:latest
  script:
    - twine upload -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" dist/pipdeps*tar.gz
Marek Chrastina's avatar
Marek Chrastina committed
95 96
  only:
    - master
97
  when: manual