.gitlab-ci.yml 17.8 KB
Newer Older
1 2 3
variables:
  DOCKER_TLS_CERTDIR: ""
  GIT_STRATEGY: clone
4
  REGISTRY_USER: chembl/chembl
5
  SERVER_APPLICATION: delayed-jobs/delayed-jobs-api/delayed-jobs-server
6
  SERVER_IMAGE_TAG: ${CI_REGISTRY}/${REGISTRY_USER}/${SERVER_APPLICATION}:${CI_COMMIT_SHORT_SHA}
7
  SERVER_IMAGE_TAG_LATEST: ${CI_REGISTRY}/${REGISTRY_USER}/${SERVER_APPLICATION}:latest
8
  DOCKER_DRIVER: overlay
David Mendez's avatar
David Mendez committed
9
  CONFIGS_FOLDER: run_config
10 11
  # Config unit tests
  CONFIG_UNIT_TESTS_FILE_PATH: ${CONFIGS_FOLDER}/unit_tests.yml
12
  # Config staging
David Mendez's avatar
David Mendez committed
13
  CONFIG_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/staging.yml
14
  CONFIG_GUNICORN_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/staging.gunicorn.config.py
15
  INGRESS_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/ingress-staging.yml
16
  AUTOSCALER_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/autoscaler-staging.yml
17
  # Config prod_hx
18
  CONFIG_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/prod_hx.yml
19
  CONFIG_GUNICORN_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/prod_hx.gunicorn.config.py
20
  INGRESS_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/ingress-prod_hx.yml
21
  AUTOSCALER_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/autoscaler-prod_hx.yml
22
  # Config prod_hh
David Mendez's avatar
David Mendez committed
23 24
  CONFIG_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/prod_hh.yml
  CONFIG_GUNICORN_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/prod_hh.gunicorn.config.py
25
  INGRESS_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/ingress-prod_hh.yml
26
  AUTOSCALER_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/autoscaler-prod_hh.yml
27

David Mendez's avatar
David Mendez committed
28
stages:
29
  - build
30
  - prepare_config_tests
31
  - test_and_qa
David Mendez's avatar
David Mendez committed
32
  - prepare_config_staging
33
  - deploy_to_staging
David Mendez's avatar
David Mendez committed
34
  - test_staging
35 36 37
  - prepare_config_hx_hh
  - deploy_to_prod_hx_hh
  - test_prod_hx_hh
38
  - functional_tests_prod_public
39
  - schedules
David Mendez's avatar
David Mendez committed
40

41
# ----------------------------------------------------------------------------------------------------------------------
42
# build
43
# ----------------------------------------------------------------------------------------------------------------------
David Mendez's avatar
David Mendez committed
44 45
build_docker_image_server:
  image:
46
    name: docker/compose:1.24.1
47
    entrypoint: [ "/bin/sh", "-c" ]
David Mendez's avatar
David Mendez committed
48 49 50
  stage: build
  variables:
    DOCKER_HOST: tcp://docker:2375
51 52
  except:
    - schedules
53 54
  services:
    - docker:dind
David Mendez's avatar
David Mendez committed
55
  before_script:
56 57
    - mkdir -p $HOME/.docker
    - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
David Mendez's avatar
David Mendez committed
58 59 60
  script:
    - set -x
    # Check rate limit
David Mendez's avatar
David Mendez committed
61
    - docker version # verify docker cli is there. Also prints server info
David Mendez's avatar
David Mendez committed
62
    - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
63 64 65 66
    - docker pull ${SERVER_IMAGE_TAG_LATEST} || true
    - docker build --cache-from ${SERVER_IMAGE_TAG_LATEST} --tag ${SERVER_IMAGE_TAG} --tag ${SERVER_IMAGE_TAG_LATEST} --target production-server .
    - docker push ${SERVER_IMAGE_TAG}
    - docker push ${SERVER_IMAGE_TAG_LATEST}
67

68 69 70
# ----------------------------------------------------------------------------------------------------------------------
# QA
# ----------------------------------------------------------------------------------------------------------------------
71
pylint:
72
  stage: test_and_qa
73
  image:
74
    name: $SERVER_IMAGE_TAG
75
    entrypoint: [ "" ]
76 77
  except:
    - schedules
78
  script:
79 80 81
    - pwd
    - ls
    - echo 'disabled temporarily'
82

David Mendez's avatar
David Mendez committed
83 84 85
# ----------------------------------------------------------------------------------------------------------------------
# Tests
# ----------------------------------------------------------------------------------------------------------------------
86 87 88
prepare_config_tests:
  stage: prepare_config_tests
  image:
89
    name: alpine/git
90
    entrypoint: [ "/bin/sh", "-c" ]
91 92 93 94
  except:
    - schedules
  script:
    - set -x
95
    - rm -rf ${CONFIGS_FOLDER} || true
96 97 98 99 100 101
    - mkdir -p ${CONFIGS_FOLDER}
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
  artifacts:
    paths:
      - ${CONFIG_UNIT_TESTS_FILE_PATH}

102
unit_tests:
103
  stage: test_and_qa
104
  image:
105
    name: $SERVER_IMAGE_TAG
106
    entrypoint: [ "" ]
107 108
  except:
    - schedules
109
  script:
110 111
    - env
    - CONFIG_FILE_PATH=${CONFIG_UNIT_TESTS_FILE_PATH} python -m unittest
112

David Mendez's avatar
David Mendez committed
113 114 115
# ----------------------------------------------------------------------------------------------------------------------
# Deployment to staging
# ----------------------------------------------------------------------------------------------------------------------
David Mendez's avatar
David Mendez committed
116
prepare_config_staging:
David Mendez's avatar
David Mendez committed
117
  stage: prepare_config_staging
David Mendez's avatar
David Mendez committed
118
  image:
119
    name: alpine/git
120
    entrypoint: [ "/bin/sh", "-c" ]
121 122
  only:
    - staging
123 124
  except:
    - schedules
David Mendez's avatar
David Mendez committed
125
  script:
126
    - set -x
127
    - rm -rf ${CONFIGS_FOLDER} || true
David Mendez's avatar
David Mendez committed
128
    - mkdir -p ${CONFIGS_FOLDER}
David Mendez's avatar
David Mendez committed
129
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
David Mendez's avatar
David Mendez committed
130 131
  artifacts:
    paths:
David Mendez's avatar
David Mendez committed
132
      - ${CONFIG_STAGING_FILE_PATH}
133
      - ${CONFIG_GUNICORN_STAGING_FILE_PATH}
134
      - ${INGRESS_STAGING_FILE_PATH}
135
      - ${AUTOSCALER_STAGING_FILE_PATH}
David Mendez's avatar
David Mendez committed
136

137
deploy_to_staging:
138
  stage: deploy_to_staging
139
  image:
140
    name: lachlanevenson/k8s-kubectl:latest
141
    entrypoint: [ "/bin/sh", "-c" ]
142
  only:
143
    - staging
144 145
  except:
    - schedules
146 147
  environment:
    name: staging
148
    url: ${SERVER_URL_STAGING}
149
  script:
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
    - set -x
    - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
    - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
    - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
    - kubectl config set-context ${CHEMBL_NS_STAGING} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
    - kubectl config use-context ${CHEMBL_NS_STAGING}
    - echo ${CHEMBL_NS_STAGING} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
    - kubectl get pods -n ${CHEMBL_NS_STAGING}
    - kubectl create secret generic ${ID_RSA_SECRET_NAME_STAGING} --from-file=ID_RSA_LSF=${ID_RSA_LSF_HX} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_STAGING} --from-file=RUN_CONFIG.yml=${CONFIG_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_STAGING} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
    - cat ${CONFIG_STAGING_FILE_PATH}
    - cat ${CONFIG_GUNICORN_STAGING_FILE_PATH}
    - sed -i "s~<NAMESPACE>~${CHEMBL_NS_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<NUM_REPLICAS>~${NUM_REPLICAS_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<CPU_LIMIT>~${CPU_LIMIT_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<CPU_REQUESTED>~${CPU_REQUESTED_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
    - sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
    - sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
    - sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<NFS_FQDN>~${NFS_FQDN_HX}~" k8s-deployment.yaml
    - sed -i "s~<NFS_PATH>~${NFS_PATH_HX}~" k8s-deployment.yaml
    - sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_STAGING}~" k8s-deployment.yaml
    - sed -i "s~<NODE_PORT>~${DELAYED_JOBS_SERVICE_PORT_STAGING}~" k8s-deployment.yaml
    - cat k8s-deployment.yaml
    - kubectl apply -n ${CHEMBL_NS_STAGING} -f k8s-deployment.yaml
    - kubectl get pods -n ${CHEMBL_NS_STAGING}
    - cat ${INGRESS_STAGING_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_STAGING} -f ${INGRESS_STAGING_FILE_PATH}
    - kubectl describe ingress -n ${CHEMBL_NS_STAGING}
    - cat ${AUTOSCALER_STAGING_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_STAGING} -f ${AUTOSCALER_STAGING_FILE_PATH}
185 186 187 188

# ----------------------------------------------------------------------------------------------------------------------
# Test staging
# ----------------------------------------------------------------------------------------------------------------------
189
functional_tests_staging:
David Mendez's avatar
David Mendez committed
190
  stage: test_staging
David Mendez's avatar
David Mendez committed
191 192
  image:
    name: $SERVER_IMAGE_TAG
193
    entrypoint: [ "" ]
David Mendez's avatar
David Mendez committed
194
  only:
195
    - staging
David Mendez's avatar
David Mendez committed
196 197 198
  environment:
    name: staging
  script:
199 200 201
    - set -x
    - sleep 30 # Give some time for the deployment to take effect.
    - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_STAGING} ${DJ_SERVER_ADMIN_USERNAME_STAGING} ${DJ_SERVER_ADMIN_PASSWORD_STAGING}
202 203 204 205

# ----------------------------------------------------------------------------------------------------------------------
# Deployment to prod hx
# ----------------------------------------------------------------------------------------------------------------------
206
prepare_config_prod_hx:
David Mendez's avatar
David Mendez committed
207
  stage: prepare_config_hx_hh
208
  image:
209
    name: alpine/git
210
    entrypoint: [ "/bin/sh", "-c" ]
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
  only:
    - master
  except:
    - schedules
  script:
    - rm -rf ${CONFIGS_FOLDER} || true
    - mkdir -p ${CONFIGS_FOLDER}
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
  artifacts:
    paths:
      - ${CONFIG_PROD_HX_FILE_PATH}
      - ${CONFIG_GUNICORN_PROD_HX_FILE_PATH}
      - ${INGRESS_PROD_HX_FILE_PATH}
      - ${AUTOSCALER_PROD_HX_FILE_PATH}

deploy_to_prod_hx:
David Mendez's avatar
David Mendez committed
227
  stage: deploy_to_prod_hx_hh
228
  image:
229
    name: lachlanevenson/k8s-kubectl:latest
230
    entrypoint: [ "/bin/sh", "-c" ]
231 232 233 234 235 236 237 238 239 240 241 242 243
  only:
    - master
  except:
    - schedules
  script:
    - set -x
    - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
    - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
    - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
    - kubectl config set-context ${CHEMBL_NS_PROD} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
    - kubectl config use-context ${CHEMBL_NS_PROD}
    - echo ${CHEMBL_NS_PROD} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
    - kubectl get pods -n ${CHEMBL_NS_PROD}
244 245 246
    - kubectl create secret generic ${ID_RSA_SECRET_NAME_PROD_HX} --from-file=ID_RSA_LSF=${ID_RSA_LSF_HX} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_PROD_HX} --from-file=RUN_CONFIG.yml=${CONFIG_PROD_HX_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_PROD_HX} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_PROD_HX_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
    - cat ${CONFIG_PROD_HX_FILE_PATH}
    - cat ${CONFIG_GUNICORN_PROD_HX_FILE_PATH}
    - sed -i "s~<NAMESPACE>~${CHEMBL_NS_PROD}~" k8s-deployment.yaml
    - sed -i "s~<NUM_REPLICAS>~${NUM_REPLICAS_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<CPU_LIMIT>~${CPU_LIMIT_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<CPU_REQUESTED>~${CPU_REQUESTED_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
    - sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
    - sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
    - sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<NFS_FQDN>~${NFS_FQDN_HX}~" k8s-deployment.yaml
    - sed -i "s~<NFS_PATH>~${NFS_PATH_HX}~" k8s-deployment.yaml
    - sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_PROD_HX}~" k8s-deployment.yaml
262
    - sed -i "s~<NODE_PORT>~${DELAYED_JOBS_SERVICE_PORT_PROD_HX}~" k8s-deployment.yaml
263 264 265 266 267 268 269 270 271 272
    - cat k8s-deployment.yaml
    - kubectl apply -n ${CHEMBL_NS_PROD} -f k8s-deployment.yaml
    - kubectl get pods -n ${CHEMBL_NS_PROD}
    - cat ${INGRESS_PROD_HX_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${INGRESS_PROD_HX_FILE_PATH}
    - kubectl describe ingress -n ${CHEMBL_NS_PROD}
    - cat ${AUTOSCALER_PROD_HX_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${AUTOSCALER_PROD_HX_FILE_PATH}

functional_tests_prod_hx:
David Mendez's avatar
David Mendez committed
273
  stage: test_prod_hx_hh
274 275
  image:
    name: $SERVER_IMAGE_TAG
276
    entrypoint: [ "" ]
277
  only:
278
    - master
279
  script:
280 281 282
    - set -x
    - sleep 30 # Give some time for the deployment to take effect.
    - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_PROD_HX} ${DJ_SERVER_ADMIN_USERNAME_PROD_HX} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HX}
283

David Mendez's avatar
David Mendez committed
284 285 286 287
# ----------------------------------------------------------------------------------------------------------------------
# Deployment to prod hh
# ----------------------------------------------------------------------------------------------------------------------
prepare_config_prod_hh:
288
  stage: prepare_config_hx_hh
David Mendez's avatar
David Mendez committed
289
  image:
290
    name: alpine/git
291
    entrypoint: [ "/bin/sh", "-c" ]
David Mendez's avatar
David Mendez committed
292 293
  only:
    - master
294 295
  except:
    - schedules
David Mendez's avatar
David Mendez committed
296 297 298 299 300 301 302 303
  script:
    - rm -rf ${CONFIGS_FOLDER} || true
    - mkdir -p ${CONFIGS_FOLDER}
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
  artifacts:
    paths:
      - ${CONFIG_PROD_HH_FILE_PATH}
      - ${CONFIG_GUNICORN_PROD_HH_FILE_PATH}
304
      - ${INGRESS_PROD_HH_FILE_PATH}
305
      - ${AUTOSCALER_PROD_HH_FILE_PATH}
David Mendez's avatar
David Mendez committed
306 307

deploy_to_prod_hh:
308
  stage: deploy_to_prod_hx_hh
David Mendez's avatar
David Mendez committed
309
  image:
310
    name: lachlanevenson/k8s-kubectl:latest
311
    entrypoint: [ "/bin/sh", "-c" ]
David Mendez's avatar
David Mendez committed
312 313
  only:
    - master
314 315
  except:
    - schedules
David Mendez's avatar
David Mendez committed
316 317 318 319 320 321 322 323 324
  script:
    - set -x
    - echo "$KUBE_CA_PEM_HH" > "$(pwd)/kube.ca.pem"
    - kubectl config set-cluster ${KUBE_CLUS_NAME_HH} --server="${KUBE_URL_HH}" --certificate-authority="$(pwd)/kube.ca.pem"
    - kubectl config set-credentials ${KUBE_USER_HH} --token="${KUBE_TOKEN_HH}"
    - kubectl config set-context ${CHEMBL_NS_PROD} --cluster=${KUBE_CLUS_NAME_HH} --user=${KUBE_USER_HH}
    - kubectl config use-context ${CHEMBL_NS_PROD}
    - echo ${CHEMBL_NS_PROD} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HH} ${KUBE_USER_HH}
    - kubectl get pods -n ${CHEMBL_NS_PROD}
325 326 327
    - kubectl create secret generic ${ID_RSA_SECRET_NAME_PROD_HH} --from-file=ID_RSA_LSF=${ID_RSA_LSF_HH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_PROD_HH} --from-file=RUN_CONFIG.yml=${CONFIG_PROD_HH_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_PROD_HH} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_PROD_HH_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
David Mendez's avatar
David Mendez committed
328 329 330 331
    - cat ${CONFIG_PROD_HH_FILE_PATH}
    - cat ${CONFIG_GUNICORN_PROD_HH_FILE_PATH}
    - sed -i "s~<NAMESPACE>~${CHEMBL_NS_PROD}~" k8s-deployment.yaml
    - sed -i "s~<NUM_REPLICAS>~${NUM_REPLICAS_PROD_HH}~" k8s-deployment.yaml
332 333
    - sed -i "s~<CPU_LIMIT>~${CPU_LIMIT_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<CPU_REQUESTED>~${CPU_REQUESTED_PROD_HH}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
334 335 336 337 338 339 340 341 342
    - sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
    - sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
    - sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
    - sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<NFS_FQDN>~${NFS_FQDN_HH}~" k8s-deployment.yaml
    - sed -i "s~<NFS_PATH>~${NFS_PATH_HH}~" k8s-deployment.yaml
    - sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_PROD_HH}~" k8s-deployment.yaml
343
    - sed -i "s~<NODE_PORT>~${DELAYED_JOBS_SERVICE_PORT_PROD_HH}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
344 345
    - cat k8s-deployment.yaml
    - kubectl apply -n ${CHEMBL_NS_PROD} -f k8s-deployment.yaml
346
    - kubectl get pods -n ${CHEMBL_NS_PROD}
347 348 349
    - cat ${INGRESS_PROD_HH_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${INGRESS_PROD_HH_FILE_PATH}
    - kubectl describe ingress -n ${CHEMBL_NS_PROD}
350 351
    - cat ${AUTOSCALER_PROD_HH_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${AUTOSCALER_PROD_HH_FILE_PATH}
352 353

functional_tests_prod_hh:
354
  stage: test_prod_hx_hh
355 356
  image:
    name: $SERVER_IMAGE_TAG
357
    entrypoint: [ "" ]
358
  only:
359
    - master
360
  script:
361 362 363
    - set -x
    - sleep 30 # Give some time for the deployment to take effect.
    - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_PROD_HH} ${DJ_SERVER_ADMIN_USERNAME_PROD_HH} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HH}
364 365 366 367 368

# ----------------------------------------------------------------------------------------------------------------------
# Test prod public url
# ----------------------------------------------------------------------------------------------------------------------
functional_tests_prod_public:
David Mendez's avatar
David Mendez committed
369
  stage: functional_tests_prod_public
370 371
  image:
    name: $SERVER_IMAGE_TAG
372
    entrypoint: [ "" ]
373
  only:
374
    - master
375
  needs: [ "functional_tests_prod_hh", "functional_tests_prod_hx" ]
376
  script:
377 378
    - set -x
    - sleep 30 # Give some time for the deployment to take effect.
379
    - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_PROD_PUBLIC} ${DJ_SERVER_ADMIN_USERNAME_PROD_HX} ${DJ_SERVER_ADMIN_PASSWORD_PROD_PUBLIC}
380 381 382 383

# ----------------------------------------------------------------------------------------------------------------------
# Schedules
# ----------------------------------------------------------------------------------------------------------------------
384
delete_expired_jobs:
385
  stage: schedules
386
  image: python:3.7
387 388 389 390
  only:
    - schedules
  script:
    - set -x
391
    - pip install requests
David Mendez's avatar
David Mendez committed
392
    - admin_tasks/delete_expired_jobs.py ${DELAYED_JOBS_URL_STAGING} ${DJ_SERVER_ADMIN_USERNAME_STAGING} ${DJ_SERVER_ADMIN_PASSWORD_STAGING}
393 394
    - admin_tasks/delete_expired_jobs.py ${DELAYED_JOBS_URL_PROD_HX} ${DJ_SERVER_ADMIN_USERNAME_PROD_HX} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HX}
    - admin_tasks/delete_expired_jobs.py ${DELAYED_JOBS_URL_PROD_HH} ${DJ_SERVER_ADMIN_USERNAME_PROD_HH} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HH}