.gitlab-ci.yml 21.1 KB
Newer Older
1
stages:
2
  - prepare-base
3
  - prepare
4
  - build
5
  - unit_test
6
  - integration_test
7
  - dockerize
8 9
  - deploy-test
  - deploy-prod
10

Auke Klazema's avatar
Auke Klazema committed
11 12 13
include:
  - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'

14
variables:
15
  FASTLANE: "false"
16
  VERSION: "0.0.0"
17
  USE_PYTHON: "true"
18

19
set_version:
20
  stage: .pre
21
  script:
Auke Klazema's avatar
Auke Klazema committed
22
    - if echo $CI_COMMIT_TAG | grep -Eq "^LOFAR-Release-[0-9]_[0-9]_[0-9]"; then TMP=${CI_COMMIT_TAG//LOFAR-Release-/}; VERSION=${TMP//_/.}; fi
23
    - echo "BUILDING $VERSION"
Auke Klazema's avatar
Auke Klazema committed
24

25
#
26 27
# This script snippet needs a PACKAGE variable to define which package to build.
# It also uses the global VERSION variable.
28
#
Auke Klazema's avatar
Auke Klazema committed
29 30 31 32
.build_mac_package: &build_mac_package
  - echo "Building $PACKAGE..."
  - mkdir -p build/gnucxx11_opt
  - cd build/gnucxx11_opt
33
  - cmake -DBUILD_PACKAGES=$PACKAGE -DUSE_PYTHON=$USE_PYTHON -DWINCC_ROOT_DIR=/opt/WinCC_OA/3.16/ -DBLITZ_ROOT_DIR=/opt/blitz/ -DCASACORE_ROOT_DIR=/opt/casacore/ -DCMAKE_INSTALL_PREFIX=/opt/lofar ../..
Auke Klazema's avatar
Auke Klazema committed
34 35 36 37 38
  - make -j $(nproc)
  - make DESTDIR=${CI_BUILDS_DIR}/${CI_COMMIT_SHORT_SHA}/install install
  - cd ${CI_BUILDS_DIR}/${CI_COMMIT_SHORT_SHA}/install/opt/lofar
  - tar --ignore-failed-read --exclude=include --exclude="*.ztar" -czf ${PACKAGE}_${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}.ztar *
  - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ${PACKAGE}_${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}.ztar "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE}/${VERSION}/${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar"'
39

40 41 42 43 44 45 46 47 48 49 50 51
#
# This script snippet needs a LOFAR_TARGET variable to define the SSH host to connect to.
#
.prepare_ssh: &prepare_ssh
  - '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 $LOFAR_TARGET >> ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts

52 53 54 55 56 57 58 59
#
# This script snipper needs a PACKAGE, a LOFAR_TARGET, and a LOFAR_USER variable to mac install a package to a target
# It also uses the global VERSION variable
#
.mac_install_package: &mac_install_package
  - ssh $LOFAR_USER@$LOFAR_TARGET "cd ~/incoming; wget --backups=1 --user=$MACINSTALL_USER --password=$MACINSTALL_PASSWORD https://git.astron.nl/api/v4/projects/6/packages/generic/$PACKAGE/$VERSION/${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar"
  - ssh $LOFAR_USER@$LOFAR_TARGET "MAC_install -f ${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar -v ${CI_COMMIT_REF_NAME}"

60
#
61
# PREPARE BASE STAGE
62
#
63
prepare_ci_base_docker_image:
64
  stage: prepare-base
65 66
  script:
    - docker build -t ci_base:$CI_COMMIT_SHORT_SHA -f  Docker/lofar-ci/Dockerfile_ci_base .
67
  interruptible: true
68

69 70 71
#
# PREPARE STAGE
#
72
prepare_ci_scu_docker_image:
73 74
  stage: prepare
  script:
75
    - docker build --build-arg BASE_VERSION=$CI_COMMIT_SHORT_SHA -t ci_scu:$CI_COMMIT_SHORT_SHA -f  Docker/lofar-ci/Dockerfile_ci_scu .
76
  interruptible: true
77

78 79 80
prepare_ci_lta_docker_image:
  stage: prepare
  script:
81
    - docker build --build-arg BASE_VERSION=$CI_COMMIT_SHORT_SHA -t ci_lta:$CI_COMMIT_SHORT_SHA -f  Docker/lofar-ci/Dockerfile_ci_lta .
82
  interruptible: true
83

84 85 86
prepare_ci_mac_docker_image:
  stage: prepare
  script:
87
    - docker build --build-arg BASE_VERSION=$CI_COMMIT_SHORT_SHA -t ci_mac:$CI_COMMIT_SHORT_SHA -f  Docker/lofar-ci/Dockerfile_ci_mac .
88
  interruptible: true
89

90 91 92 93
#
# BUILD STAGE
#

94
build_SCU:
95
  stage: build
96
  image: ci_scu:$CI_COMMIT_SHORT_SHA
97
  script:
98
    - echo "Building SCU & TMSSFrontend..."
99 100
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
101
    - cmake -DBUILD_PACKAGES="SCU TMSSFrontend" -DUSE_PYTHON=$USE_PYTHON -DCASACORE_ROOT_DIR=/opt/casacore/ -DCASAREST_ROOT_DIR=/opt/casarest/ -DUSE_LOG4CPLUS=false ../..
102
    - make -j $(nproc)
103
    - make install
104
  interruptible: true
105
  needs:
106
    - prepare_ci_scu_docker_image
107
  artifacts:
Jorrit Schaap's avatar
Jorrit Schaap committed
108
    expire_in: 6 hours
109 110
    paths:
      - build/gnucxx11_opt
111

112 113
build_LTAIngest:
  stage: build
114
  image: ci_lta:$CI_COMMIT_SHORT_SHA
115
  script:
116
    - PACKAGE="LTAIngest"
117 118 119
    - echo "Building $PACKAGE..."
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
120
    - cmake -DBUILD_PACKAGES="$PACKAGE" -DUSE_PYTHON=$USE_PYTHON -DUSE_LOG4CPLUS=false ../..
121
    - make -j $(nproc)
122
    - make install
123
  interruptible: true
124
  needs:
125 126 127 128 129 130
    - prepare_ci_lta_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt

131 132 133 134 135 136 137 138
build_LTAIngestTransfer:
  stage: build
  image: ci_lta:$CI_COMMIT_SHORT_SHA
  script:
    - PACKAGE="LTAIngestTransfer"
    - echo "Building $PACKAGE..."
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
139
    - cmake -DBUILD_PACKAGES="$PACKAGE" -DUSE_PYTHON=$USE_PYTHON -DUSE_LOG4CPLUS=false ../..
140 141 142 143 144 145 146 147 148 149
    - make -j $(nproc)
    - make install
  interruptible: true
  needs:
    - prepare_ci_lta_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt

150 151
build_MCU_MAC:
  stage: build
152
  image: ci_mac:$CI_COMMIT_SHORT_SHA
153 154
  variables:
    PACKAGE: MCU_MAC
155
  script:
156
    - *build_mac_package
Auke Klazema's avatar
Auke Klazema committed
157
  interruptible: true
158
  needs:
159 160 161 162 163
    - prepare_ci_mac_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt
164

165 166 167
build_LCU_MAC:
  stage: build
  image: ci_mac:$CI_COMMIT_SHORT_SHA
Auke Klazema's avatar
Auke Klazema committed
168
  variables:
169
    PACKAGE: "LCU_MAC"
170
  script:
Auke Klazema's avatar
Auke Klazema committed
171
    - *build_mac_package
Auke Klazema's avatar
Auke Klazema committed
172 173 174 175 176 177 178 179 180 181 182
  interruptible: true
  needs:
    - prepare_ci_mac_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt

build_CCU_MAC:
  stage: build
  image: ci_mac:$CI_COMMIT_SHORT_SHA
Auke Klazema's avatar
Auke Klazema committed
183
  variables:
184
    PACKAGE: "CCU_MAC"
Auke Klazema's avatar
Auke Klazema committed
185
  script:
Auke Klazema's avatar
Auke Klazema committed
186
    - *build_mac_package
Auke Klazema's avatar
Auke Klazema committed
187 188 189 190 191 192 193 194 195 196 197
  interruptible: true
  needs:
    - prepare_ci_mac_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt

build_ST_MAC:
  stage: build
  image: ci_mac:$CI_COMMIT_SHORT_SHA
Auke Klazema's avatar
Auke Klazema committed
198
  variables:
199
    PACKAGE: "ST_MAC"
Auke Klazema's avatar
Auke Klazema committed
200
  script:
Auke Klazema's avatar
Auke Klazema committed
201
    - *build_mac_package
202 203 204 205 206 207 208 209
  interruptible: true
  needs:
    - prepare_ci_mac_docker_image
  artifacts:
    expire_in: 6 hours
    paths:
      - build/gnucxx11_opt

210
#
211 212
# UNIT TEST STAGE
#
213

214
unit_test_SCU:
215
  stage: unit_test
216
  image: ci_scu:$CI_COMMIT_SHORT_SHA
217
  script:
218
    - PACKAGE=SCU
219 220
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
221
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=true ctest
222
  interruptible: true
223 224 225 226 227 228
  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.
229
  needs:
230
    - build_SCU
231 232 233 234 235
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
236 237
  rules:
    - if: '$FASTLANE == "false"'
238 239 240

unit_test_LTAIngest:
  stage: unit_test
241
  image: ci_lta:$CI_COMMIT_SHORT_SHA
242 243 244 245
  script:
    - PACKAGE=LTAIngest
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
246
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=true ctest
247
  interruptible: true
248 249 250 251 252 253
  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.
254
  needs:
255 256 257 258 259 260
    - build_LTAIngest
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
261 262
  rules:
    - if: '$FASTLANE == "false"'
263

264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
unit_test_LTAIngestTransfer:
  stage: unit_test
  image: ci_lta:$CI_COMMIT_SHORT_SHA
  script:
    - PACKAGE=LTAIngestTransfer
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=true ctest
  interruptible: true
  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.
  needs:
    - build_LTAIngestTransfer
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
  rules:
    - if: '$FASTLANE == "false"'

289 290
unit_test_MCU_MAC:
  stage: unit_test
291
  image: ci_mac:$CI_COMMIT_SHORT_SHA
292
  script:
293 294
    - echo "Starting Qpid server..." && qpidd &
    - PACKAGE=MCU_MAC
295 296
    - echo "Testing $PACKAGE..."
    - cd build/gnucxx11_opt
297
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=true ctest
298
  interruptible: true
299 300 301 302 303 304
  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.
305
  needs:
306 307 308 309 310 311
    - build_MCU_MAC
  artifacts:
    name: unit-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
312 313
  rules:
    - if: '$FASTLANE == "false"'
314 315 316 317 318 319 320

#
# DOCKERIZE
#

dockerize_TMSS:
  stage: dockerize
321
  allow_failure: true
322 323 324
  script:
    - cd build/gnucxx11_opt
    - ls *
325
    - docker build --build-arg TMSS_VERSION=$CI_COMMIT_SHORT_SHA -t tmss_django:$CI_COMMIT_SHORT_SHA -f docker/Dockerfile-tmss .
326
    - cd ../..
Jorrit Schaap's avatar
Jorrit Schaap committed
327
    - cd SAS/TMSS/backend/test/oidc/docker-test-mozilla-django-oidc
328 329
    - 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
330 331 332 333
    - docker tag tmss_django:$CI_COMMIT_SHORT_SHA $CI_NEXUS_REGISTRY_LOCATION/tmss_django:$CI_COMMIT_SHORT_SHA
    - docker push $CI_NEXUS_REGISTRY_LOCATION/tmss_django:$CI_COMMIT_SHORT_SHA
    - docker tag tmss_testprovider:$CI_COMMIT_SHORT_SHA $CI_NEXUS_REGISTRY_LOCATION/tmss_testprovider:$CI_COMMIT_SHORT_SHA
    - docker push $CI_NEXUS_REGISTRY_LOCATION/tmss_testprovider:$CI_COMMIT_SHORT_SHA
334
    - docker logout $CI_NEXUS_REGISTRY
335
  interruptible: true
336
  needs:
337
    - job: build_SCU
338
      artifacts: true
339

340
#
341
# INTEGRATION TEST STAGE
342 343
#

344
integration_test_SCU:
345
  stage: integration_test
346
  image: ci_scu:$CI_COMMIT_SHORT_SHA
347 348 349 350 351 352
  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.
353
  script:
354
    - PACKAGE=SCU
355
    - echo "Integration Testing $PACKAGE..."
356
    - cd build/gnucxx11_opt
357
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=false SKIP_UNIT_TESTS=true ctest
358
  interruptible: true
359
  needs:
360 361
    - build_SCU
    - unit_test_SCU
362 363 364 365 366
  artifacts:
    name: integration-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
367 368
  rules:
    - if: '$FASTLANE == "false"'
369

370 371
integration_test_LTAIngest:
  stage: integration_test
372
  image: ci_lta:$CI_COMMIT_SHORT_SHA
373 374 375 376
  script:
    - PACKAGE=LTAIngest
    - echo "Integration Testing $PACKAGE..."
    - cd build/gnucxx11_opt
377
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=false SKIP_UNIT_TESTS=true ctest
378
  interruptible: true
379 380 381 382 383 384
  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.
385
  needs:
386
    - build_LTAIngest
387
    - unit_test_LTAIngest
388 389 390 391 392
  artifacts:
    name: integration-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
393 394
  rules:
    - if: '$FASTLANE == "false"'
395

396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
integration_test_LTAIngestTransfer:
  stage: integration_test
  image: ci_lta:$CI_COMMIT_SHORT_SHA
  script:
    - PACKAGE=LTAIngestTransfer
    - echo "Integration Testing $PACKAGE..."
    - cd build/gnucxx11_opt
    - SKIP_PYTHON_COVERAGE=true SKIP_INTEGRATION_TESTS=false SKIP_UNIT_TESTS=true ctest
  interruptible: true
  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.
  needs:
    - build_LTAIngestTransfer
    - unit_test_LTAIngestTransfer
  artifacts:
    name: integration-test-report
    when: always
    paths:
      - build/gnucxx11_opt/Testing/Temporary/LastTest.log
  rules:
    - if: '$FASTLANE == "false"'

422
#
423
# DEPLOY TEST STAGE
424
#
425

426
deploy-tmss-test:
427
  stage: deploy-test
428 429 430
  variables:
    LOFAR_TARGET: "scu199.control.lofar"
    LOFAR_USER: "lofarsys"
431
  before_script:
432
    - *prepare_ssh
433
  script:
Jorrit Schaap's avatar
Jorrit Schaap committed
434
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD stop TMSS:*"
435 436 437 438 439
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker pull ${CI_NEXUS_REGISTRY_LOCATION}/tmss_testprovider:$CI_COMMIT_SHORT_SHA"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker pull ${CI_NEXUS_REGISTRY_LOCATION}/tmss_django:$CI_COMMIT_SHORT_SHA"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker tag ${CI_NEXUS_REGISTRY_LOCATION}/tmss_testprovider:$CI_COMMIT_SHORT_SHA ${CI_NEXUS_REGISTRY_LOCATION}/tmss_testprovider:latest"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker tag ${CI_NEXUS_REGISTRY_LOCATION}/tmss_django:$CI_COMMIT_SHORT_SHA nexus.cep4.control.lofar:18080/tmss_django:latest"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker tag ${CI_NEXUS_REGISTRY_LOCATION}/tmss_django:$CI_COMMIT_SHORT_SHA tmss_django:latest"
440
    #- ssh $LOFAR_USER@head.cep4.control.lofar "/data/home/lofarsys/tmss_clean_commissioning_data.sh || true"
441
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD start TMSS:*"
442
  needs:
443
    - dockerize_TMSS
444
  allow_failure: true
445
  when: manual
446

447
deploy-tmss-ua:
448
  stage: deploy-test
449 450
  variables:
    LOFAR_TARGET: "tmss-ua.control.lofar"
451
  before_script:
452
    - *prepare_ssh
453 454 455 456 457 458 459 460 461
  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"
462
  needs:
463
    - dockerize_TMSS
464 465
    - job: integration_test_SCU
      artifacts: false
466
  allow_failure: true
467 468
  when: manual
  only:
469
    - "master"
470

471 472 473 474 475 476 477 478 479 480 481 482 483 484
deploy-MCU_MAC-test:
  stage: deploy-test
  variables:
    LOFAR_TARGET: "mcu199.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: "MCU_MAC"
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 0"
    - *mac_install_package
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 6"
  needs: 
    - unit_test_MCU_MAC
485
  allow_failure: true
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
  when: manual

deploy-CCU_MAC-test:
  stage: deploy-test
  variables:
    LOFAR_TARGET: "ccu199.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: "CCU_MAC"
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 0"
    - *mac_install_package
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 6"
  needs: 
    - build_CCU_MAC
502
  allow_failure: true
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
  when: manual

deploy-SCU-test:
  stage: deploy-test
  variables:
    LOFAR_TARGET: "scu199.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: "SCU"
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD stop all"
    - *mac_install_package
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD start all"
  needs: 
    - integration_test_SCU
519
  allow_failure: true
520 521 522 523 524 525
  when: manual

#
# deploy-prod stage
#

Auke Klazema's avatar
Auke Klazema committed
526
deploy-tmss-dockerhub:
527
  stage: deploy-prod
528 529 530 531 532
  script:
    - docker login -u $CI_DOCKERHUB_USERNAME -p $CI_DOCKERHUB_PASSWORD
    - docker tag tmss_django:$CI_COMMIT_SHORT_SHA lofar/tmss:master-$CI_COMMIT_SHORT_SHA
    - docker push lofar/tmss:master-$CI_COMMIT_SHORT_SHA
    - docker logout
533 534
  environment:
    name: production
535
  needs:
536
    - dockerize_TMSS
537 538
    - job: integration_test_SCU
      artifacts: false
539
  allow_failure: true
540 541
  when: manual

542 543
deploy-MCU_MAC-prod:
  stage: deploy-prod
544
  variables:
545
    LOFAR_TARGET: "mcu001.control.lofar"
546 547
    LOFAR_USER: "lofarsys"
    PACKAGE: "MCU_MAC"
548
  before_script:
549
    - *prepare_ssh
550
  script:
551
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 0"
552
    - *mac_install_package
553
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 6"
554 555
  environment:
    name: production
556 557
  needs: 
    - unit_test_MCU_MAC
558
  allow_failure: true
559
  when: manual
560 561
  only:
    - tags
562

563 564
deploy-CCU_MAC-prod:
  stage: deploy-prod
565
  variables:
566
    LOFAR_TARGET: "ccu001.control.lofar"
567 568 569
    LOFAR_USER: "lofarsys"
    PACKAGE: "CCU_MAC"
  before_script:
570
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 0"
571
    - *prepare_ssh
572
    - ssh $LOFAR_USER@$LOFAR_TARGET "swlevel 6"
573 574
  script:
    - *mac_install_package
575 576
  environment:
    name: production
577 578
  needs: 
    - build_CCU_MAC
579
  allow_failure: true
580
  when: manual
581 582
  only:
    - tags
583

584 585
deploy-SCU-prod:
  stage: deploy-prod
586
  variables:
587
    LOFAR_TARGET: "scu001.control.lofar"
588 589 590 591 592
    LOFAR_USER: "lofarsys"
    PACKAGE: "SCU"
  before_script:
    - *prepare_ssh
  script:
593
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD stop all"
594
    - *mac_install_package
595
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD start all"
596 597
  environment:
    name: production
598 599
  needs: 
    - integration_test_SCU
600
  allow_failure: true
601
  when: manual
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
  only:
    - tags

deploy-tmss-prod:
  stage: deploy-prod
  variables:
    LOFAR_TARGET: "scu001.control.lofar"
    LOFAR_USER: "lofarsys"
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD stop TMSS:*"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker pull ${CI_NEXUS_REGISTRY_LOCATION}/tmss_testprovider:$CI_COMMIT_SHORT_SHA"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker pull ${CI_NEXUS_REGISTRY_LOCATION}/tmss_django:$CI_COMMIT_SHORT_SHA"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker tag ${CI_NEXUS_REGISTRY_LOCATION}/tmss_testprovider:$CI_COMMIT_SHORT_SHA ${CI_NEXUS_REGISTRY_LOCATION}/tmss_testprovider:latest"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker tag ${CI_NEXUS_REGISTRY_LOCATION}/tmss_django:$CI_COMMIT_SHORT_SHA nexus.cep4.control.lofar:18080/tmss_django:latest"
    - ssh $LOFAR_USER@$LOFAR_TARGET "docker tag ${CI_NEXUS_REGISTRY_LOCATION}/tmss_django:$CI_COMMIT_SHORT_SHA tmss_django:latest"
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD start TMSS:*"
620 621
  environment:
    name: production
622 623
  needs:
    - dockerize_TMSS
624
  allow_failure: true
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
  when: manual
  only:
    - tags

deploy-LTAIngest-prod:
  stage: deploy-prod
  variables:
    LOFAR_TARGET: "lexar003.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: LTAIngest
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD stop all"
    - *mac_install_package
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD start all"
641 642
  environment:
    name: production
643 644
  needs: 
    - integration_test_LTAIngest
645
  allow_failure: true
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
  when: manual
  only:
    - tags

deploy-LTAIngestTransfer-prod:
  stage: deploy-prod
  variables:
    LOFAR_TARGET: "lexar004.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: LTAIngestTransfer
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD stop all"
    - *mac_install_package
    - ssh $LOFAR_USER@$LOFAR_TARGET "supervisorctl -u $SUPERVISOR_USER -p $SUPERVISOR_PASSWORD start all"
662 663
  environment:
    name: production
664 665
  needs: 
    - integration_test_LTAIngestTransfer
666
  allow_failure: true
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
  when: manual
  only:
    - tags

deploy-lcu-prod:
  stage: deploy-prod
  variables:
    LOFAR_TARGET: "lcuhead.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: LCU_MAC
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "lcurun -s today 'cd ~/incoming; wget --backups=1 --user=$MACINSTALL_USER --password=$MACINSTALL_PASSWORD https://git.astron.nl/api/v4/projects/6/packages/generic/$PACKAGE/$VERSION/${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar'"
    - ssh $LOFAR_USER@$LOFAR_TARGET "lcurun -s today 'swlevel 0'"
    - ssh $LOFAR_USER@$LOFAR_TARGET "lcurun -s today 'MAC_install -f ${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar -v ${CI_COMMIT_REF_NAME}'"
683 684
  environment:
    name: production
Auke Klazema's avatar
Auke Klazema committed
685
  needs:
Auke Klazema's avatar
Auke Klazema committed
686
    - build_LCU_MAC
687
  allow_failure: true
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
  when: manual
  only:
    - tags

deploy-station-test-prod:
  stage: deploy-prod
  variables:
    LOFAR_TARGET: "lcuhead.control.lofar"
    LOFAR_USER: "lofarsys"
    PACKAGE: ST_MAC
  before_script:
    - *prepare_ssh
  script:
    - ssh $LOFAR_USER@$LOFAR_TARGET "lcurun -s today 'cd ~/incoming; wget --backups=1 --user=$MACINSTALL_USER --password=$MACINSTALL_PASSWORD https://git.astron.nl/api/v4/projects/6/packages/generic/$PACKAGE/$VERSION/${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar'"
    - ssh $LOFAR_USER@$LOFAR_TARGET "lcurun -s today 'ST_install -f ${PACKAGE}_${CI_COMMIT_REF_NAME}_0.x86_64.ztar -v ${CI_COMMIT_REF_NAME}'"
703 704
  environment:
    name: production
Auke Klazema's avatar
Auke Klazema committed
705 706
  needs:
    - build_ST_MAC
707
  allow_failure: true
708 709 710
  when: manual
  only:
    - tags