.gitlab-ci.yml 3.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Setup some variables and caches
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"

cache:
  paths:
    - "$CI_PROJECT_DIR/pip-cache"
  key: "$CI_PROJECT_ID"

# Declare the stages
11
stages:
12
  - prepare
13 14 15 16 17
  - lint
  - test
  - build
  - deploy

18 19 20 21 22 23 24 25 26 27 28 29 30
# PREPARE stage
prepare:
  stage: prepare
  image: python:3.5
  script:
    - pip install -U pip setuptools tox detox
    - pip install -r requirements.txt
    - pip install -r docs/requirements.txt

# CHECK stage
setup:
  image: python:3.5
  stage: lint
31 32
  before_script:
    - pip install tox
33 34 35 36 37
  script: tox -e setup

safety:
  image: python:3.5
  stage: lint
38 39
  before_script:
    - pip install tox
40 41 42 43 44
  script: tox -e safety

style:
  image: python:3.5
  stage: lint
45 46
  before_script:
    - pip install tox
47 48 49 50 51 52 53 54
  script: tox -e style
  allow_failure: true

docs:
  image: python:3.5
  stage: lint
  before_script:
    - apt-get update && apt-get install -y python-enchant
55
    - pip install tox
56 57 58 59
  script: tox -e docs
  allow_failure: true

# TEST stage
60
py34-django111:
61 62
  image: python:3.4
  stage: test
63 64
  before_script:
    - pip install tox
65
  script: tox -e py34-django111
66 67 68
  artifacts:
    paths:
      - .coverage.*
69

70
py35-django111:
71 72
  image: python:3.5
  stage: test
73 74
  before_script:
    - pip install tox
75
  script: tox -e py35-django111
76 77 78
  artifacts:
    paths:
      - .coverage.*
79

80
py36-django111:
81 82
  image: python:3.6
  stage: test
83 84
  before_script:
    - pip install tox
85
  script: tox -e py36-django111
86 87 88
  artifacts:
    paths:
      - .coverage.*
89

90
py37-django111:
91 92
  image: python:3.7-rc-stretch
  stage: test
93 94
  before_script:
    - pip install tox
95
  script: tox -e py37-dev-django111
96 97 98
  artifacts:
    paths:
      - .coverage.*
99

100
py34-django20:
101 102
  image: python:3.4
  stage: test
103 104
  before_script:
    - pip install tox
105
  script: tox -e py34-django20
106 107 108
  artifacts:
    paths:
      - .coverage.*
109

110
py35-django20:
111 112
  image: python:3.5
  stage: test
113 114
  before_script:
    - pip install tox
115
  script: tox -e py35-django20
116 117 118
  artifacts:
    paths:
      - .coverage.*
119

120
py36-django20:
121 122
  image: python:3.6
  stage: test
123 124
  before_script:
    - pip install tox
125
  script: tox -e py36-django20
126 127 128
  artifacts:
    paths:
      - .coverage.*
129

130
py37-django20:
131 132
  image: python:3.7-rc-stretch
  stage: test
133 134
  before_script:
    - pip install tox
135
  script: tox -e py37-dev-django20
136 137 138
  artifacts:
    paths:
      - .coverage.*
139

140
# BUILD stage
141 142 143 144 145 146 147
build:
  image: docker:latest
  services:
    - docker:dind
  stage: build
  script: echo "Build Docker images"

148
# DEPLOY stage
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
deploy_staging:
  stage: deploy
  script:
    - echo "Deploy to staging server"
  environment:
    name: staging
    url: https://staging.example.com
  only:
    - master

deploy_prod:
  stage: deploy
  script:
    - echo "Deploy to production server"
  environment:
    name: production
    url: https://example.com
  when: manual
  only:
    - master
169 170 171 172 173 174 175 176 177 178 179 180 181

pages:
  stage: deploy
  dependencies:
    - py34-django111
    - py35-django111
    - py36-django111
    - py37-django111
    - py34-django20
    - py35-django20
    - py36-django20
    - py37-django20
  before_script:
182
    - pip install tox
183
  script:
184
    - tox -e report
185 186 187 188 189 190 191
    - mv htmlcov/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master