.gitlab-ci.yml 5.36 KB
Newer Older
1
stages:
2
  - prepare
3
  - build
4
  - dockerize
5
  - unit_test
6
  - deploy
7
#  - integration_test
8

9 10 11 12 13 14 15
#
# PREPARE STAGE
#

prepare_RAServices:
  stage: prepare
  script:
Auke Klazema's avatar
Auke Klazema committed
16
    - docker build -t ci_raservices -f SubSystems/RAServices/Dockerfile .
17

18 19 20 21
#
# BUILD STAGE
#

22
build_RAServices:
23
  stage: build
24
  image: ci_raservices:latest
25
  script:
26
    - PACKAGE=RAServices
27
    - echo "Building $PACKAGE..."
Auke Klazema's avatar
Auke Klazema committed
28
    - mkdir install
Auke Klazema's avatar
Auke Klazema committed
29 30
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
Auke Klazema's avatar
Auke Klazema committed
31
    - cmake -DBUILD_PACKAGES=$PACKAGE -DCASACORE_ROOT_DIR=/opt/casacore/ -DCASAREST_ROOT_DIR=/opt/casarest/ -DCMAKE_INSTALL_PREFIX=/opt/lofar -DUSE_LOG4CPLUS=false ../..
32
    - make -j 6
Auke Klazema's avatar
Auke Klazema committed
33
    - make DESTDIR=../../install install
34
    - cd ../../install/opt/lofar
Auke Klazema's avatar
Auke Klazema committed
35
    - tar --ignore-failed-read --exclude=include -czf ../../RAServices_$CI_COMMIT_SHORT_SHA.ztar *
36 37
  dependencies:
    - prepare_RAServices
38
  artifacts:
39
    expire_in: 6 hours
40
    paths:
Auke Klazema's avatar
Auke Klazema committed
41
      - build/gnucxx11_opt
42
      - install/*.ztar
43

44 45 46 47 48 49 50 51 52 53
build_TMSS:
  stage: build
  image: ci_raservices:latest
  script:
    - PACKAGE=TMSS
    - echo "Building $PACKAGE..."
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
    - cmake -DBUILD_PACKAGES=$PACKAGE -DCASACORE_ROOT_DIR=/opt/casacore/ -DCASAREST_ROOT_DIR=/opt/casarest/ -DCMAKE_INSTALL_PREFIX=/opt/lofar -DUSE_LOG4CPLUS=false ../..
    - make -j 6
54
    - make DESTDIR=installed install
55 56 57 58 59
  dependencies:
    - prepare_RAServices
  artifacts:
    expire_in: 6 hours
    paths:
60
      - build/gnucxx11_opt
61 62 63 64 65 66 67 68

#
# DOCKERIZE
#

dockerize_TMSS:
  stage: dockerize
  script:
69
    - cd build/gnucxx11_opt
Auke Klazema's avatar
Auke Klazema committed
70
    - ls *
71
    - docker build -t tmss_django:$CI_COMMIT_SHORT_SHA -f docker/Dockerfile-tmss .
72
    - cd ../..
73 74 75 76 77 78 79 80 81
    - cd SAS/TMSS/test/oidc/docker-test-mozilla-django-oidc
    - docker build -t tmss_testprovider:$CI_COMMIT_SHORT_SHA -f dockerfiles/oidc_testprovider .
    - docker login -u $CI_NEXUS_REGISTRY_USERNAME -p $CI_NEXUS_REGISTRY_PASSWORD $CI_NEXUS_REGISTRY
    - docker tag tmss_django:$CI_COMMIT_SHORT_SHA nexus.cep4.control.lofar:18080/tmss_django:$CI_COMMIT_SHORT_SHA
    - docker push nexus.cep4.control.lofar:18080/tmss_django:$CI_COMMIT_SHORT_SHA
    - docker tag tmss_testprovider:$CI_COMMIT_SHORT_SHA nexus.cep4.control.lofar:18080/tmss_testprovider:$CI_COMMIT_SHORT_SHA
    - docker push nexus.cep4.control.lofar:18080/tmss_testprovider:$CI_COMMIT_SHORT_SHA
    - docker logout $CI_NEXUS_REGISTRY  
  dependencies:
82
    - build_TMSS
83

84
#
85 86
# UNIT TEST STAGE
#
87

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
unit_test_RAServices:
  stage: unit_test
  image: ci_raservices:latest
  script:
    - PACKAGE=RAServices
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=true ctest
  dependencies:
    - build_RAServices
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
103 104

#
105
# INTEGRATION TEST STAGE
106 107
#

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
# integration_test_RAServices:
#   stage: integration_test
#   image: ci_raservices:latest
#   services:
#     - rabbitmq:latest
#   variables:
#     LOFAR_DEFAULT_BROKER: "rabbitmq"
#   script:
#     - PACKAGE=RAServices
#     - echo "Testing $PACKAGE..."
#     - cd build/gnucxx11_opt
#     - SKIP_UNIT_TESTS=true ctest
#   dependencies:
#     - build_RAServices
#   artifacts:
#     name: integration-test-report
#     when: always
#     paths:
#       - build/gnucxx11_opt/Testing/Temporary/LastTest.log
127

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
deploy-tmss-test:
  stage: deploy
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan scu199.control.lofar >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:   
    - cd SAS/TMSS
    - ssh lofarsys@scu199.control.lofar "docker-compose -f docker-compose-scu199.yml down"
    - scp docker-compose-scu199.yml lofarsys@scu199.control.lofar:~/
    - ssh lofarsys@scu199.control.lofar "docker pull ${CI_NEXUS_REGISTRY}/tmss_testprovider:latest"
    - ssh lofarsys@scu199.control.lofar "docker pull ${CI_NEXUS_REGISTRY}/tmss_web:latest"
    - ssh lofarsys@scu199.control.lofar "docker-compose -f docker-compose-scu199.yml up -d"
  dependencies:
Auke Klazema's avatar
Auke Klazema committed
146
    - build_TMSS
147
  when: manual
148

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
deploy-tmss-ua:
  stage: deploy
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan tmss-ua.control.lofar >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - cd SAS/TMSS
    - ssh lofarsys@tmss-ua.control.lofar "docker-compose -f docker-compose-ua.yml down"
    - scp docker-compose-ua.yml lofarsys@tmss-ua.control.lofar:~/
    - ssh lofarsys@tmss-ua.control.lofar "docker pull ${CI_NEXUS_REGISTRY}/tmss_testprovider:$CI_COMMIT_SHORT_SHA"
    - ssh lofarsys@tmss-ua.control.lofar "docker pull ${CI_NEXUS_REGISTRY}/tmss_django:$CI_COMMIT_SHORT_SHA"
    - ssh lofarsys@tmss-ua.control.lofar "docker tag ${CI_NEXUS_REGISTRY}/tmss_testprovider:$CI_COMMIT_SHORT_SHA ${CI_NEXUS_REGISTRY}/tmss_testprovider:latest"
    - ssh lofarsys@tmss-ua.control.lofar "docker tag ${CI_NEXUS_REGISTRY}/tmss_django:$CI_COMMIT_SHORT_SHA ${CI_NEXUS_REGISTRY}/tmss_django:latest"
    - ssh lofarsys@tmss-ua.control.lofar "docker-compose -f docker-compose-ua.yml up -d"
  dependencies:
Auke Klazema's avatar
Auke Klazema committed
169
    - build_TMSS
170 171 172
  when: manual
  only:
    - "master"