.gitlab-ci.yml 3.31 KB
Newer Older
Markus Scheidgen's avatar
Markus Scheidgen committed
1
# default installed image for docker executor is: python:3.6
2
3
# using an image that can do git, docker, docker-compose
image: youpy/docker-compose-git
4
5
6
7
8

# Uncomment the next lines, to run each pipline/job in its own docker environment.
# Otherwise, it will use the docker of the gitlab runner host (e.g. enc-preprocessing...).
# This will give it access to a persitent layer cache, which will not be available
# with the docker service.
9
10
# services:
#   - docker:dind
Markus Scheidgen's avatar
Markus Scheidgen committed
11
12

stages:
Markus Scheidgen's avatar
Markus Scheidgen committed
13
  - build
14
  - test
15
  - release
16
  - deploy
17

18
variables:
Markus Scheidgen's avatar
Markus Scheidgen committed
19
20
21
22
  TEST_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair:test
  RELEASE_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair:latest
  FRONTEND_TEST_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair/frontend:test
  FRONTEND_RELEASE_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair/frontend:latest
Markus Scheidgen's avatar
Markus Scheidgen committed
23

Markus Scheidgen's avatar
Markus Scheidgen committed
24
25
26
build:
  stage: build
  script:
27
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de
Markus Scheidgen's avatar
Markus Scheidgen committed
28
29
30
31
32
33
34
35
    - docker build -t $TEST_IMAGE .
    - docker push $TEST_IMAGE

buildgui:
  stage: build
  script:
    - cd gui
    - ./gitinfo.sh
Markus Scheidgen's avatar
Markus Scheidgen committed
36
    - ls -la src/gitinfo.json
Markus Scheidgen's avatar
Markus Scheidgen committed
37
38
39
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de
    - docker build -t $FRONTEND_TEST_IMAGE .
    - docker push $FRONTEND_TEST_IMAGE
40
41

linting:
42
  stage: test
Markus Scheidgen's avatar
Markus Scheidgen committed
43
  image: $TEST_IMAGE
44
  script:
45
    - cd /app
Markus Scheidgen's avatar
Markus Scheidgen committed
46
47
48
    - python -m pycodestyle --ignore=E501,E701 nomad tests
    - python -m pylint --load-plugins=pylint_mongoengine nomad tests
    - python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional nomad tests
49
50

tests:
Markus Scheidgen's avatar
Markus Scheidgen committed
51
  stage: test
Markus Scheidgen's avatar
Markus Scheidgen committed
52
  image: $TEST_IMAGE
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  services:
      # this will cause a warning, as the gitlab ci runner health check will test the wrong
      # port on rabbitmq container:
      # https://gitlab.com/gitlab-org/gitlab-runner/issues/3163
    - rabbitmq
    - name: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
      alias: elastic
      # fix issue with running elastic in gitlab ci runner:
      # https://gitlab.com/gitlab-org/gitlab-ce/issues/42214
      command: [ "bin/elasticsearch", "-Ediscovery.type=single-node" ]
  variables:
    RABBITMQ_ERLANG_COOKIE: SWQOKODSQALRPCLNMEQG
    RABBITMQ_DEFAULT_USER: rabbitmq
    RABBITMQ_DEFAULT_PASS: rabbitmq
    RABBITMQ_DEFAULT_VHOST: /
    NOMAD_RABBITMQ_HOST: rabbitmq
    NOMAD_ELASTIC_HOST: elastic
    NOMAD_MONGO_HOST: mongo
Markus Scheidgen's avatar
Markus Scheidgen committed
71
  script:
72
    - cd /app
Markus Scheidgen's avatar
Markus Scheidgen committed
73
    - python -m pytest --cov=nomad -sv tests
74
75
76
77
78

release:
  stage: release
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de
Markus Scheidgen's avatar
Markus Scheidgen committed
79
80
81
82
83
84
    - docker pull $TEST_IMAGE
    - docker tag $TEST_IMAGE $RELEASE_IMAGE
    - docker push $RELEASE_IMAGE
    - docker pull $FRONTEND_TEST_IMAGE
    - docker tag $FRONTEND_TEST_IMAGE $FRONTEND_RELEASE_IMAGE
    - docker push $FRONTEND_RELEASE_IMAGE
Markus Scheidgen's avatar
Markus Scheidgen committed
85
86
  only:
    - master
87
88
89
90
91
92
93
94
95
96
97

deploy:
  stage: deploy
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de
    - cd infrastructure/nomad
    # secret .env file is stored on the "production" machine and is bind mounted into the
    # runner container at /nomad/config/.env
    - cp /nomad/config/.env .
    - docker-compose -f docker-compose.yml -f docker-compose.prod.yml build
    - docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --no-deps -d api worker gui
Markus Scheidgen's avatar
Markus Scheidgen committed
98
99
  only:
    - master
100
  when: manual