.gitlab-ci.yml 1.9 KB
Newer Older
Nathan Graule's avatar
Nathan Graule committed
1 2
image: python:3.7-alpine

Nathan Graule's avatar
Nathan Graule committed
3 4 5 6 7 8 9 10
cache:
  key: $CI_COMMIT_REF
  paths:
    - .cache

variables:
  PIP_DOWNLOAD_CACHE: .cache

Nathan Graule's avatar
Nathan Graule committed
11 12 13 14 15 16
stages:
  - build
  - dist

build:py2:
  stage: build
17
  image: python:2.7.15-alpine
Nathan Graule's avatar
Nathan Graule committed
18
  before_script:
Nathan Graule's avatar
Nathan Graule committed
19
    - pip install wheel
20
    - python -V
Nathan Graule's avatar
Nathan Graule committed
21 22
  script:
    - pip wheel .
Nathan Graule's avatar
Nathan Graule committed
23 24
    - mkdir -p dist
    - mv *.whl dist
Nathan Graule's avatar
Nathan Graule committed
25 26
  artifacts:
    paths:
Nathan Graule's avatar
Nathan Graule committed
27
      - dist
Nathan Graule's avatar
Nathan Graule committed
28 29 30 31 32 33 34 35
    name: Python 2

build:py3:
  stage: build
  before_script:
    - pip install wheel
  script:
    - pip wheel .
Nathan Graule's avatar
Nathan Graule committed
36 37
    - mkdir -p dist
    - mv *.whl dist
Nathan Graule's avatar
Nathan Graule committed
38 39
  artifacts:
    paths:
Nathan Graule's avatar
Nathan Graule committed
40
      - dist
Nathan Graule's avatar
Nathan Graule committed
41 42 43 44 45 46
    name: Python 3

test:py2:
  stage: build
  image: python:2.7-alpine
  before_script:
Nathan Graule's avatar
Nathan Graule committed
47
    - pip install nose typing
48
    - python -V
Nathan Graule's avatar
Nathan Graule committed
49
  script:
Nathan Graule's avatar
Nathan Graule committed
50
  - nosetests -v tests
Nathan Graule's avatar
Nathan Graule committed
51 52 53 54 55 56

test:py3:
  stage: build
  before_script:
    - pip install nose coverage
  script:
Nathan Graule's avatar
Nathan Graule committed
57
  - nosetests -v --with-coverage --cover-package=call tests
Nathan Graule's avatar
Nathan Graule committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  artifacts:
    paths:
      - .coverage
    expire_in: 1 hour

dist-test:
  stage: dist
  dependencies:
    - build:py2
    - build:py3
  variables:
    GIT_STRATEGY: none
  before_script:
    - pip install twine
  script:
73 74
    - >
      twine upload dist/*.whl
75 76 77
      --repository-url https://test.pypi.org/legacy/
      -u $PIP_UPLOAD_USER
      -p $PIP_UPLOAD_TEST_PASSWD
Nathan Graule's avatar
Nathan Graule committed
78 79
  except:
    - master
Nathan Graule's avatar
Nathan Graule committed
80

Nathan Graule's avatar
Nathan Graule committed
81 82 83 84 85 86 87 88 89 90 91 92 93
dist:
  stage: dist
  dependencies:
    - build:py2
    - build:py3
  variables:
    GIT_STRATEGY: none
  before_script:
    - pip install twine
  script:
    - twine upload dist/*.whl -u $PIP_UPLOAD_USER -p $PIP_UPLOAD_PASSWD
  only:
    - master
Nathan Graule's avatar
Nathan Graule committed
94 95 96 97 98 99 100 101 102 103 104 105 106
pages:
  stage: dist
  dependencies:
    - test:py3
  before_script:
    - pip install coverage
  script:
    - coverage html
  after_script:
    - mv htmlcov public
  artifacts:
    paths:
      - public
107 108 109 110 111 112 113
    expire_in: 1 hour

codacy:
  stage: dist
  dependencies:
    - test:py3
  before_script:
Nathan Graule's avatar
Nathan Graule committed
114
    - apk add git
115
    - pip install codacy-coverage coverage
116 117 118
  script:
    - coverage xml
    - python-codacy-coverage -r coverage.xml