.gitlab-ci.yml 4.17 KB
Newer Older
1 2
stages:
  - test
3
  - test-built
4 5 6
  - deploy


7 8 9 10 11 12 13 14 15 16
variables: &variables
  PROJECT_NAME: rca-sh
  NAMESPACE: knoppo

  TERM: ansi
  DEBIAN_FRONTEND: noninteractive


.py template: &py
  image: python:3.6
17 18
  tags:
    - docker
19 20 21 22 23 24 25 26 27 28 29 30
  before_script:
    - pip install invoke


######################################################################
# Stage: test
#

.test-py template: &test-py
  <<: *py
  before_script:
    - pip install tox
31
  script:
32 33
    - tox --skip-missing-interpreters
    - mv .coverage ".coverage.py$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')"
34 35 36 37
  artifacts:
    paths:
      - .coverage.*

38 39 40 41 42 43
test py27:
  <<: *test-py
  image: python:2.7

test py34:
  <<: *test-py
44
  image: python:3.4
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

test py35:
  <<: *test-py
  image: python:3.5

test py36:
  <<: *test-py
  image: python:3.6

test py37:
  <<: *test-py
  image: python:3.7

lint:
  <<: *py
60
  script:
61 62 63 64 65 66
    - inv lint

wheel:
  <<: *py
  script:
    - inv wheel
67
  artifacts:
68
    name: '${PROJECT_NAME}_wheel'
69
    paths:
70
      - 'dist/*.whl'
71

72 73 74 75 76 77 78 79 80
#docs:
#  <<: *py
#  script:
#    - inv docs
#  artifacts:
#    paths:
#      - docs/_build/html

.build-deb template: &build-deb
81 82
  tags:
    - docker
83
  dependencies: []
84
  script:
85 86 87 88
    - apt-get update -qqy
    - apt-get install -qqy python3-pip
    - pip3 install invoke
    - inv build
89
  artifacts:
90
    name: '${PROJECT_NAME}_debian'
91
    paths:
92 93 94 95
      - build/*
  when: on_success


96 97 98
#build deb oldstable:
#  <<: *build-deb
#  image: debian:oldstable
99

100 101 102
#build deb stable:
#  <<: *build-deb
#  image: debian:stable
103

104 105 106
#build deb testing:
#  <<: *build-deb
#  image: debian:testing
107 108 109 110 111 112 113 114 115

build deb unstable:
  <<: *build-deb
  image: debian:unstable


######################################################################
# Stage: test-built
#
116 117

coverage:
118 119 120 121 122 123 124 125
  <<: *py
  stage: test-built
  dependencies:
    - test py27
    - test py34
    - test py35
    - test py36
    - test py37
126 127 128 129 130 131 132
  script:
    - pip install coverage
    - coverage combine
    - coverage html
    - coverage report
  artifacts:
    paths:
133
      - htmlcov/
Mathias Stelzer's avatar
Mathias Stelzer committed
134
  coverage: '/^rca_sh\.py[\s\d]+\s+(\d+.\d+\%)\s*$/'
135 136 137 138 139 140 141 142 143
  when: always

.test-built-deb template: &test-built-deb
  stage: test-built
  tags:
    - docker
  script:
    - apt-get update -qqy
    - apt-get install -qqy gdebi-core
144

145 146 147 148
    - 'gdebi --non-interactive build/${PROJECT_NAME}_*.deb'
    - apt-get purge -qqy ${PROJECT_NAME}
  when: on_success

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
#test deb oldstable:
#  <<: *test-built-deb
#  image: debian:oldstable
#  dependencies:
#    - build deb oldstable

#test deb stable:
#  <<: *test-built-deb
#  image: debian:stable
#  dependencies:
#    - build deb stable

#test deb testing:
#  <<: *test-built-deb
#  image: debian:testing
#  dependencies:
#    - build deb testing
166 167 168 169 170 171 172 173 174 175 176 177 178

test deb unstable:
  <<: *test-built-deb
  image: debian:unstable
  dependencies:
    - build deb unstable


######################################################################
# Stage: deploy
#

meta:
179 180 181
  stage: deploy
  tags:
    - docker
182 183 184 185
  image: knoppo/docker-publisher
  dependencies:
    #- docs
    - coverage
186
  script:
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host rolln.de\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

    - ssh publisher@rolln.de "mkdir -p ~/coverage/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/"
    - '[[ ! -d htmlcov ]] || rsync -az --delete htmlcov/ publisher@rolln.de:coverage/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/'

    #- ssh publisher@rolln.de "mkdir -p ~/docs/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/"
    #- '[[ ! -d docs/_build/html ]] || rsync -az --delete docs/_build/html/ publisher@rolln.de:docs/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/'
  when: always

deb:
  stage: deploy
  tags:
    - docker
  image: knoppo/docker-publisher
  dependencies:
    - build deb unstable
  script:
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_APT_KEY")
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host rolln.de\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

    - scp build/${PROJECT_NAME}_* apt@rolln.de:repos/debian/incoming/
    - ssh apt@rolln.de "reprepro -b repos/debian processincoming default"
  when: on_success
  only:
    - master
    - tags