.gitlab-ci.yml 2.82 KB
Newer Older
Wietse Kuipers's avatar
Wietse Kuipers committed
1 2 3 4
variables:
  POSTGRES_DB: thalia
  POSTGRES_USER: postgres
  POSTGRES_PASSWORD: ""
5
  CI_DEPS: psycopg2-binary
6 7 8 9 10 11
  # https://hub.docker.com/r/twiggers/python-thalia/
  # https://github.com/thomwiggers/python-thalia
  # Should get auto-updated with the official 'python' repository
  # Installs:
  #  - pip: tox, coverage
  #  - apt: ghostscript
12 13
  PY35_IMAGE: thalia/python-thalia:3.5
  PY36_IMAGE: thalia/python-thalia:3.6
Thom Wiggers's avatar
Thom Wiggers committed
14
  PIP_CACHE_DIR: "${CI_PROJECT_DIR}/pip-cache"
Wietse Kuipers's avatar
Wietse Kuipers committed
15

Thom Wiggers's avatar
Thom Wiggers committed
16 17 18 19
stages:
  - test
  - deploy

Thom Wiggers's avatar
Thom Wiggers committed
20
pep8:
Thom Wiggers's avatar
Thom Wiggers committed
21
  stage: test
22
  image: $PY35_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
23 24 25 26 27
  before_script:
  script:
    - tox -e flake8

.djangotest: &djangotest
Thom Wiggers's avatar
Thom Wiggers committed
28
  stage: test
Thom Wiggers's avatar
Thom Wiggers committed
29 30
  services:
    - postgres:latest
Thom Wiggers's avatar
Thom Wiggers committed
31 32 33
  before_script:
    - git log -1
  script:
Thom Wiggers's avatar
Thom Wiggers committed
34
    - tox -e ${PYTHON_VERSION}-${DJANGO_VERSION}
Thom Wiggers's avatar
Thom Wiggers committed
35 36
    - cd website
    - coverage report
Thom Wiggers's avatar
Thom Wiggers committed
37

Thom Wiggers's avatar
Thom Wiggers committed
38 39
python35-django20:
  <<: *djangotest
40
  image: $PY35_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
41 42 43 44
  variables:
    PYTHON_VERSION: py35
    DJANGO_VERSION: django20

Thom Wiggers's avatar
Thom Wiggers committed
45 46
python36-django20:
  <<: *djangotest
47
  image: $PY36_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
48 49 50 51
  variables:
    PYTHON_VERSION: py36
    DJANGO_VERSION: django20

Thom Wiggers's avatar
Thom Wiggers committed
52
docs:
Thom Wiggers's avatar
Thom Wiggers committed
53
  stage: test
54
  image: $PY35_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
55 56 57
  before_script:
    # install django deps
    - pip install -r requirements.txt
58
    - pip install -r dev-requirements.txt
Thom Wiggers's avatar
Thom Wiggers committed
59 60 61 62
    - cd docs
    # install doc deps
    - pip install -r requirements.txt
  script:
Thom Wiggers's avatar
Thom Wiggers committed
63
    - echo "Building current docs"
Thom Wiggers's avatar
Thom Wiggers committed
64
    - env -u GITLAB_CI make doctest
Thom Wiggers's avatar
Thom Wiggers committed
65
    - env -u GITLAB_CI sphinx-build -M html "." "_build" -W -j $(nproc)
Thom Wiggers's avatar
Thom Wiggers committed
66 67 68
    - echo "Checking if there are changes"
    - ./generate-apidocs.sh
    - git diff --exit-code
Thom Wiggers's avatar
Thom Wiggers committed
69

Thom Wiggers's avatar
Thom Wiggers committed
70 71 72 73 74 75 76 77 78 79
build docker image:
  stage: test
  services:
    - docker:dind
  image: thalia/docker-compose
  tags:
    - docker
  before_script:
    - echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com
  script:
Joren Vrancken's avatar
Joren Vrancken committed
80
    - docker-compose config -q
81
    - docker-compose build --build-arg install_dev_requirements=0 --build-arg source_commit=$(git rev-parse HEAD) web
Thom Wiggers's avatar
Thom Wiggers committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
    - docker-compose run --rm web test
    - docker tag $DOCKER_LATEST $DOCKER_TAG
    - docker push $DOCKER_TAG
  variables:
    DOCKER_LATEST: registry.gitlab.com/thaliawww/concrexit:latest
    DOCKER_TAG: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_SHA

tag docker image:
  stage: deploy
  services:
    - docker:dind
  image: docker:git
  tags:
    - docker
  only:
    - tags
  dependencies:
    - build docker image
  before_script:
    - echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com
  script:
    - docker pull $DOCKER_TAG
Thom Wiggers's avatar
Thom Wiggers committed
104
    - docker tag $DOCKER_TAG $DOCKER_TAG_PRODUCTION
Thom Wiggers's avatar
Thom Wiggers committed
105 106 107 108 109 110
    - docker push $DOCKER_TAG_PRODUCTION
  variables:
    DOCKER_TAG: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_SHA
    DOCKER_TAG_PRODUCTION: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_TAG


Thom Wiggers's avatar
Thom Wiggers committed
111
cache:
112
  key: "$CI_JOB_NAME"
Thom Wiggers's avatar
Thom Wiggers committed
113
  paths:
Thom Wiggers's avatar
Thom Wiggers committed
114
    - "${PIP_CACHE_DIR}"
Thom Wiggers's avatar
Thom Wiggers committed
115 116

# vim: set sw=2 ts=2 et :