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

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

19
20
21
22
23
24
25
26
obsolete-translations:
  stage: test
  image: $PY37_IMAGE
  cache: {}
  script:
    # Check for obsolete translations in .po files (starting with `#~`).
    - (grep --include="*.po" --quiet --recursive --regexp "^#~" website && exit 1) || exit 0

Thom Wiggers's avatar
Thom Wiggers committed
27
pep8:
Thom Wiggers's avatar
Thom Wiggers committed
28
  stage: test
Thom Wiggers's avatar
Thom Wiggers committed
29
  image: $PY36_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
30
31
32
33
  script:
    - tox -e flake8

.djangotest: &djangotest
Thom Wiggers's avatar
Thom Wiggers committed
34
  stage: test
Thom Wiggers's avatar
Thom Wiggers committed
35
36
  services:
    - postgres:latest
Thom Wiggers's avatar
Thom Wiggers committed
37
38
39
  before_script:
    - git log -1
  script:
Thom Wiggers's avatar
Thom Wiggers committed
40
    - tox -e ${PYTHON_VERSION}-${DJANGO_VERSION}
Thom Wiggers's avatar
Thom Wiggers committed
41
42
    - cd website
    - coverage report
Thom Wiggers's avatar
Thom Wiggers committed
43

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

Thom Wiggers's avatar
Thom Wiggers committed
51
python37-django20:
Thom Wiggers's avatar
Thom Wiggers committed
52
  <<: *djangotest
Thom Wiggers's avatar
Thom Wiggers committed
53
  image: $PY37_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
54
  variables:
Thom Wiggers's avatar
Thom Wiggers committed
55
    PYTHON_VERSION: py37
Thom Wiggers's avatar
Thom Wiggers committed
56
57
    DJANGO_VERSION: django20

Thom Wiggers's avatar
Thom Wiggers committed
58
docs:
Thom Wiggers's avatar
Thom Wiggers committed
59
  stage: test
Thom Wiggers's avatar
Thom Wiggers committed
60
  image: $PY36_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
61
62
  before_script:
    # install django deps
Thom Wiggers's avatar
Thom Wiggers committed
63
    - pipenv --bare install --dev --ignore-pipfile
Thom Wiggers's avatar
Thom Wiggers committed
64
    # install doc deps
Thom Wiggers's avatar
Thom Wiggers committed
65
66
    - cd docs
    - pipenv run pip install -r requirements.txt
Thom Wiggers's avatar
Thom Wiggers committed
67
  script:
Thom Wiggers's avatar
Thom Wiggers committed
68
    - echo "Building current docs"
Thom Wiggers's avatar
Thom Wiggers committed
69
70
    - env -u GITLAB_CI pipenv run make doctest
    - env -u GITLAB_CI pipenv run sphinx-build -M html "." "_build" -W -j $(nproc)
Thom Wiggers's avatar
Thom Wiggers committed
71
    - echo "Checking if there are changes"
Thom Wiggers's avatar
Thom Wiggers committed
72
    - pipenv run ./generate-apidocs.sh
Thom Wiggers's avatar
Thom Wiggers committed
73
    - git diff --exit-code
Thom Wiggers's avatar
Thom Wiggers committed
74

Thom Wiggers's avatar
Thom Wiggers committed
75
76
77
78
79
80
81
82
83
84
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
85
    - docker-compose config -q
86
    - 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    - 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
109
    - docker tag $DOCKER_TAG $DOCKER_TAG_PRODUCTION
Thom Wiggers's avatar
Thom Wiggers committed
110
111
112
113
114
115
    - 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
116
cache:
117
  key: "$CI_JOB_NAME"
Thom Wiggers's avatar
Thom Wiggers committed
118
  paths:
Thom Wiggers's avatar
Thom Wiggers committed
119
    - "${PIP_CACHE_DIR}"
Thom Wiggers's avatar
Thom Wiggers committed
120
121

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