.gitlab-ci.yml 4.94 KB
Newer Older
Markus Scheidgen's avatar
Markus Scheidgen committed
1
# default installed image for docker executor is: python:3.6
2
# using an image that can do git, docker, docker-compose
3
image: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair/ci-runner
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
  - deploy
16
17
  - release

18

19
variables:
20
  TEST_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair:${CI_COMMIT_REF_NAME}
Markus Scheidgen's avatar
Markus Scheidgen committed
21
  STABLE_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair:stable
Markus Scheidgen's avatar
Markus Scheidgen committed
22
  LATEST_IMAGE: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair:latest
23
24
  KUBECONFIG: /etc/deploy/config

Markus Scheidgen's avatar
Markus Scheidgen committed
25
26
build:
  stage: build
27
28
  before_script:
    - git submodule sync
29
    - git submodule update --init --jobs=4
30
    # create the version information
31
    - ./gitinfo.sh
Markus Scheidgen's avatar
Markus Scheidgen committed
32
  script:
33
34
    # ignore test directories of dependencies, there is a lot of data that we not use
    # in the context of the docker image
35
    - find dependencies -name "*test*" -type d -exec echo "{}/" \;  >> .dockerignore
36
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de
37
    - docker build -t $TEST_IMAGE .
38
    - docker push $TEST_IMAGE
39
40
  except:
    - /^dev-.*$/
Markus Scheidgen's avatar
Markus Scheidgen committed
41
    - tags
42

43
44
45
46
47
linting:
  stage: test
  image: $TEST_IMAGE
  script:
    - cd /app
48
    - python -m pycodestyle --ignore=E501,E701,E731 nomad tests
49
    - python -m pylint --load-plugins=pylint_mongoengine,nomad/metainfo/pylint_plugin nomad tests
50
51
52
53
54
55
56
57
    - python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional nomad tests
  except:
    refs:
      - tags
    variables:
      - $CI_COMMIT_REF_NAME =~ /^dev-.*$/
      - $CI_COMMIT_MESSAGE =~ /\[skip[ _-]tests?\]/i

Markus Scheidgen's avatar
Markus Scheidgen committed
58
59
60
61
62
63
64
65
gui_linting:
  stage: test
  image: node
  script:
    - cd gui
    - yarn
    - yarn run eslint 'src/**/*.js'

66
tests:
Markus Scheidgen's avatar
Markus Scheidgen committed
67
  stage: test
Markus Scheidgen's avatar
Markus Scheidgen committed
68
  image: $TEST_IMAGE
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  services:
    - 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
84
    NOMAD_KEYCLOAK_PASSWORD: ${CI_KEYCLOAK_ADMIN_PASSWORD}
85
    NOMAD_NORMALIZE_SPRINGER_DB_PATH: /nomad/fairdi/db/data/springer.msg
Markus Scheidgen's avatar
Markus Scheidgen committed
86
  script:
87
    - cd /app
88
    - ls /builds
89
    - python -m pytest --cov=nomad -sv tests
90
  except:
Markus Scheidgen's avatar
Markus Scheidgen committed
91
92
    refs:
      - tags
93
94
    variables:
      - $CI_COMMIT_REF_NAME =~ /^dev-.*$/
95
      - $CI_COMMIT_MESSAGE =~ /\[skip[ _-]tests?\]/i
96

97
98
install_tests:
  stage: test
99
  image: python:3.7
100
101
102
103
104
105
106
107
108
109
  before_script:
    - git submodule sync
    - git submodule update --init --jobs=4
  script:
    - pip install --upgrade pip
    - pip install fastentrypoints
    - pip install pyyaml
    - pip install numpy
    - python setup.py compile
    - python setup.py sdist
110
    - pip install dist/nomad-lab-*.tar.gz
111
    - python -c "import nomad.datamodel, nomad.datamodel.metainfo, nomad.client"
112
    - pip install `echo dist/nomad-lab-*.tar.gz`[parsing]
113
114
    - python -m nomad.cli parse tests/data/parsers/vasp/vasp.xml

115
116
117
118
119
120
121
122
dev_setup_tests:
  stage: test
  image: python:3.7
  script:
    - pip install --upgrade pip
    - ./setup.sh
    - python -m nomad.cli parse tests/data/parsers/vasp/vasp.xml

123
124
125
126
127
128
deploy:
  stage: deploy
  before_script:
    - mkdir -p /etc/deploy
    - echo ${CI_K8S_CONFIG} | base64 -d > ${KUBECONFIG}
  script:
129
    - RELEASE_NAME=`echo ${CI_COMMIT_REF_NAME} | sed -e 's/[^A-Za-z0-9\-]/-/g'`
130
    - helm dependency update ops/helm/nomad
131
    - helm upgrade --namespace nomad --install $RELEASE_NAME ops/helm/nomad -f ops/helm/nomad/ci-dev-values.yaml --set proxy.external.path=/dev/nomad/$RELEASE_NAME,image.tag=$CI_COMMIT_REF_NAME,roll=true --wait
132
    - docker pull $TEST_IMAGE
133
    - docker run -t -e NOMAD_KEYCLOAK_REALM_NAME=fairdi_nomad_prod $TEST_IMAGE python -m nomad.cli client -n $CI_DEV_CLUSTER_PROXY/dev/nomad/$RELEASE_NAME/api -u admin -w $CI_NOMAD_ADMIN_PASSWORD integrationtests
134
135
136
137
138

  except:
    - /^dev-.*$/
  when: manual

139
140
141
142
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
143
    - docker pull $TEST_IMAGE
Markus Scheidgen's avatar
Markus Scheidgen committed
144
145
146
147
    - docker tag $TEST_IMAGE $LATEST_IMAGE
    - docker push $LATEST_IMAGE
  except:
    - /^dev-.*$/
148
  when:
Markus Scheidgen's avatar
Markus Scheidgen committed
149
    - manual
Markus Scheidgen's avatar
Markus Scheidgen committed
150
151
152
153
154

release_version:
  stage: release
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de
155
156
157
158
    - docker pull $TEST_IMAGE
    - docker tag $TEST_IMAGE $LATEST_IMAGE
    - docker push $LATEST_IMAGE
    - docker tag $TEST_IMAGE $STABLE_IMAGE
Markus Scheidgen's avatar
Markus Scheidgen committed
159
    - docker push $STABLE_IMAGE
Markus Scheidgen's avatar
Markus Scheidgen committed
160
161
  only:
    - tags