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

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

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

17 18 19 20
#
# BUILD STAGE
#

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

43 44 45
build_TMSS:
  stage: build
  image: ci_raservices:latest
46 47 48 49
  services:
    - docker:19.03.1-dind
  before_script:
    - docker info
50 51 52 53 54 55 56 57 58
  script:
    - PACKAGE=TMSS
    - echo "Building $PACKAGE..."
    - mkdir install
    - 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
    - make DESTDIR=../../install install
59
    - cd ../..
60 61 62 63 64 65 66 67 68 69 70 71
    - cd install
    - 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:
72 73 74 75 76
    - prepare_RAServices
  artifacts:
    expire_in: 6 hours
    paths:
      - install
77

78
#
79 80
# UNIT TEST STAGE
#
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
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
97 98

#
99
# INTEGRATION TEST STAGE
100 101
#

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
# 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
121

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
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
140
    - build_TMSS
141
  when: manual
142

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
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
163
    - build_TMSS
164 165 166
  when: manual
  only:
    - "master"