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

9 10 11 12
#
# PREPARE STAGE
#

13
prepare_ci_sas_docker_image:
14 15
  stage: prepare
  script:
16
    - docker build -t ci_base -f  Docker/lofar-ci/Dockerfile_ci_base .
17 18
    - docker build -t ci_sas -f  Docker/lofar-ci/Dockerfile_ci_sas .

19 20 21 22 23 24
prepare_ci_lta_docker_image:
  stage: prepare
  script:
    - docker build -t ci_base -f  Docker/lofar-ci/Dockerfile_ci_base .
    - docker build -t ci_lta -f  Docker/lofar-ci/Dockerfile_ci_lta .

25 26 27 28 29 30
#TODO: make proper MAC docker image with WinCC (rpm packages from mcu001)
#prepare_ci_mac_docker_image:
#  stage: prepare
#  script:
#    - docker build -t ci_base -f  Docker/lofar-ci/Dockerfile_ci_base .
#    - docker build -t ci_mac -f  Docker/lofar-ci/Dockerfile_ci_mac .
31

32 33 34 35
#
# BUILD STAGE
#

36 37
build_TMSS:
  stage: build
38
  image: ci_sas:latest
39 40 41 42 43
  script:
    - PACKAGE=TMSS
    - echo "Building $PACKAGE..."
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
44
    - cmake -DBUILD_PACKAGES=$PACKAGE -DCASACORE_ROOT_DIR=/opt/casacore/ -DCASAREST_ROOT_DIR=/opt/casarest/ -DUSE_LOG4CPLUS=false ../..
45
    - make -j 8
46
    - make install
47
  dependencies:
48
    - prepare_ci_sas_docker_image
49 50 51
  artifacts:
    expire_in: 6 hours
    paths:
52
      - build/gnucxx11_opt
53

54 55 56 57 58 59 60 61 62
build_RAServices:
  stage: build
  image: ci_sas:latest
  script:
    - PACKAGE=RAServices
    - 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/ -DUSE_LOG4CPLUS=false ../..
63
    - make -j 8
64 65 66
    - make install
  dependencies:
    - prepare_ci_sas_docker_image
67
  artifacts:
Jorrit Schaap's avatar
Jorrit Schaap committed
68
    expire_in: 6 hours
69 70
    paths:
      - build/gnucxx11_opt
71

72 73 74 75 76 77 78 79 80
build_LTAIngest:
  stage: build
  image: ci_lta:latest
  script:
    - PACKAGE=LTAIngest
    - echo "Building $PACKAGE..."
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
    - cmake -DBUILD_PACKAGES=$PACKAGE -DUSE_LOG4CPLUS=false ../..
81
    - make -j 8
82 83 84 85 86 87 88 89
    - make install
  dependencies:
    - prepare_ci_lta_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
# TODO: enable when prepare_ci_mac_docker_image is fixed
#build_MCU_MAC:
#  stage: build
#  image: ci_mac:latest
#  script:
#    - PACKAGE=MCU_MAC
#    - echo "Building $PACKAGE..."
#    - mkdir -p build/gnucxx11_opt
#    - cd build/gnucxx11_opt
#    - cmake -DBUILD_PACKAGES=$PACKAGE -DUSE_LOG4CPLUS=false ../..
#    - make -j 8
#    - make install
#  dependencies:
#    - prepare_ci_mac_docker_image
#  artifacts:
#    expire_in: 6 hours
#    paths:
#      - build/gnucxx11_opt
108

109
#
110 111
# UNIT TEST STAGE
#
112

Jorrit Schaap's avatar
Jorrit Schaap committed
113
unit_test_TMSS:
114
  stage: unit_test
Jorrit Schaap's avatar
Jorrit Schaap committed
115
  image: ci_sas:latest
116
  script:
Jorrit Schaap's avatar
Jorrit Schaap committed
117
    - PACKAGE=TMSS
118 119 120 121
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=true ctest
  dependencies:
Jorrit Schaap's avatar
Jorrit Schaap committed
122
    - build_TMSS
123 124 125 126 127
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
128

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
unit_test_RAServices:
  stage: unit_test
  image: ci_sas:latest
  script:
    - PACKAGE=RAServices
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=true ctest
  services:
    - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    LOFAR_DEFAULT_BROKER: 'rabbitmq' # override default 'localhost' which does not work for CI service rabbitmq.
  dependencies:
    - build_RAServices
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log

unit_test_LTAIngest:
  stage: unit_test
  image: ci_lta:latest
  script:
    - PACKAGE=LTAIngest
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=true ctest
  services:
    - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    LOFAR_DEFAULT_BROKER: 'rabbitmq' # override default 'localhost' which does not work for CI service rabbitmq.
  dependencies:
    - build_LTAIngest
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
# TODO: enable when build_MCU_MAC is fixed
#unit_test_MCU_MAC:
#  stage: unit_test
#  image: ci_mac:latest
#  script:
#    - PACKAGE=MCU_MAC
#    - echo "Testing $PACKAGE..."
#    - cd build/gnucxx11_opt
#    - SKIP_INTEGRATION_TESTS=true ctest
#  dependencies:
#    - build_MCU_MAC
#  artifacts:
#    name: unit-test-report
#    when: always
#    paths:
#      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
189

190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211


#
# DOCKERIZE
#

dockerize_TMSS:
  stage: dockerize
  script:
    - cd build/gnucxx11_opt
    - ls *
    - docker build -t tmss_django:$CI_COMMIT_SHORT_SHA -f docker/Dockerfile-tmss .
    - cd ../..
    - 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:
212 213
    - build_TMSS
    - unit_test_TMSS
214 215 216
    - integration_test_TMSS


217
#
218
# INTEGRATION TEST STAGE
219 220
#

221 222 223 224 225 226 227 228
integration_test_TMSS:
  stage: integration_test
  image: ci_sas:latest
  script:
    - PACKAGE=TMSS
    - echo "Integration Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=false SKIP_UNIT_TESTS=true ctest
229 230 231 232 233 234
  services:
    - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    LOFAR_DEFAULT_BROKER: 'rabbitmq' # override default 'localhost' which does not work for CI service rabbitmq.
235 236 237 238 239 240 241 242
  dependencies:
    - build_TMSS
  artifacts:
    name: integration-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log

243 244 245
integration_test_RAServices:
  stage: integration_test
  image: ci_sas:latest
246 247 248 249 250 251
  services:
    - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    LOFAR_DEFAULT_BROKER: 'rabbitmq' # override default 'localhost' which does not work for CI service rabbitmq.
252 253
  script:
    - PACKAGE=RAServices
254
    - echo "Integration Testing $PACKAGE..."
255 256 257 258 259 260 261 262 263 264
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=false SKIP_UNIT_TESTS=true ctest
  dependencies:
    - build_RAServices
  artifacts:
    name: integration-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log

265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
integration_test_LTAIngest:
  stage: integration_test
  image: ci_lta:latest
  script:
    - PACKAGE=LTAIngest
    - echo "Integration Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_INTEGRATION_TESTS=false SKIP_UNIT_TESTS=true ctest
  services:
    - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    LOFAR_DEFAULT_BROKER: 'rabbitmq' # override default 'localhost' which does not work for CI service rabbitmq.
  dependencies:
    - build_LTAIngest
  artifacts:
    name: integration-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log


288 289 290
#
# DEPLOY STAGE
#
291

292 293 294 295 296 297 298 299 300 301 302 303 304 305
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:~/
306 307 308 309
    - ssh lofarsys@scu199.control.lofar "docker pull ${CI_NEXUS_REGISTRY}/tmss_testprovider:$CI_COMMIT_SHORT_SHA"
    - ssh lofarsys@scu199.control.lofar "docker pull ${CI_NEXUS_REGISTRY}/tmss_django:$CI_COMMIT_SHORT_SHA"
    - ssh lofarsys@scu199.control.lofar "docker tag ${CI_NEXUS_REGISTRY}/tmss_testprovider:$CI_COMMIT_SHORT_SHA ${CI_NEXUS_REGISTRY}/tmss_testprovider:latest"
    - ssh lofarsys@scu199.control.lofar "docker tag ${CI_NEXUS_REGISTRY}/tmss_django:$CI_COMMIT_SHORT_SHA ${CI_NEXUS_REGISTRY}/tmss_django:latest"
310 311
    - ssh lofarsys@scu199.control.lofar "docker-compose -f docker-compose-scu199.yml up -d"
  dependencies:
312
    - integration_test_TMSS
313
  when: manual
314

315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
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:
335
    - integration_test_TMSS
336 337
  when: manual
  only:
338
    - "master"