.gitlab-ci.yml 3.69 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
codestyle:
Thom Wiggers's avatar
Thom Wiggers committed
20
  stage: test
Thom Wiggers's avatar
Thom Wiggers committed
21
  image: $PY36_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
22 23
  script:
    - tox -e flake8
24
    # Check for obsolete translations in .po files (starting with `#~`).
25
    - cd website
26
    - grep --include="*.po" --files-with-matches --recursive "^#~" && exit 1 || echo "No obsolete translations found."
27 28 29 30 31 32
    # Check for untranslated strings in .po files
    - empty_strings=$(sed '$a\\' **/locale/nl/LC_MESSAGES/django.po | tac | sed '/^$/N;/\nmsgstr ""$/,/^msgid/!d' | tac)
    - empty_strings+=$(sed '$a\\' locale/nl/LC_MESSAGES/django.po | tac | sed '/^$/N;/\nmsgstr ""$/,/^msgid/!d' | tac)
    - if [[ $empty_strings ]]; then echo $empty_strings && exit 1; else echo "No untranslated strings found."; fi
    # Check for fuzzy translations in .po files
    - grep --include="*.po" --files-with-matches --recursive "#, fuzzy" && exit 1 || echo "No fuzzy translations found."
Thom Wiggers's avatar
Thom Wiggers committed
33 34

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

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

Sébastiaan Versteeg's avatar
Sébastiaan Versteeg committed
52
python37-django21:
Thom Wiggers's avatar
Thom Wiggers committed
53
  <<: *djangotest
Thom Wiggers's avatar
Thom Wiggers committed
54
  image: $PY37_IMAGE
Thom Wiggers's avatar
Thom Wiggers committed
55
  variables:
Thom Wiggers's avatar
Thom Wiggers committed
56
    PYTHON_VERSION: py37
Sébastiaan Versteeg's avatar
Sébastiaan Versteeg committed
57
    DJANGO_VERSION: django21
Thom Wiggers's avatar
Thom Wiggers committed
58

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

Thom Wiggers's avatar
Thom Wiggers committed
76 77 78 79 80 81 82 83
build docker image:
  stage: test
  services:
    - docker:dind
  image: thalia/docker-compose
  tags:
    - docker
  before_script:
84
    - echo $DOCKER_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.hub.docker.com
Thom Wiggers's avatar
Thom Wiggers committed
85
  script:
Joren Vrancken's avatar
Joren Vrancken committed
86
    - docker-compose config -q
87
    - 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
88 89 90 91
    - docker-compose run --rm web test
    - docker tag $DOCKER_LATEST $DOCKER_TAG
    - docker push $DOCKER_TAG
  variables:
92 93
    DOCKER_LATEST: registry.hub.docker.com/thalia/concrexit:latest
    DOCKER_TAG: registry.hub.docker.com/thalia/concrexit:$CI_COMMIT_SHA
Thom Wiggers's avatar
Thom Wiggers committed
94 95 96 97 98 99 100 101 102 103 104 105 106

tag docker image:
  stage: deploy
  services:
    - docker:dind
  image: docker:git
  tags:
    - docker
  only:
    - tags
  dependencies:
    - build docker image
  before_script:
107
    - echo $DOCKER_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.hub.docker.com
Thom Wiggers's avatar
Thom Wiggers committed
108 109
  script:
    - docker pull $DOCKER_TAG
Thom Wiggers's avatar
Thom Wiggers committed
110
    - docker tag $DOCKER_TAG $DOCKER_TAG_PRODUCTION
111
    - docker tag $DOCKER_TAG $DOCKER_LATEST
Thom Wiggers's avatar
Thom Wiggers committed
112
    - docker push $DOCKER_TAG_PRODUCTION
113
    - docker push $DOCKER_LATEST
Thom Wiggers's avatar
Thom Wiggers committed
114
  variables:
115 116
    DOCKER_TAG: registry.hub.docker.com/thalia/concrexit:$CI_COMMIT_SHA
    DOCKER_TAG_PRODUCTION: registry.hub.docker.com/thalia/concrexit:$CI_COMMIT_TAG
117
    DOCKER_LATEST: registry.hub.docker.com/thalia/concrexit:latest
Thom Wiggers's avatar
Thom Wiggers committed
118 119


Thom Wiggers's avatar
Thom Wiggers committed
120
cache:
121
  key: "$CI_JOB_NAME"
Thom Wiggers's avatar
Thom Wiggers committed
122
  paths:
Thom Wiggers's avatar
Thom Wiggers committed
123
    - "${PIP_CACHE_DIR}"
Thom Wiggers's avatar
Thom Wiggers committed
124 125

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