.gitlab-ci.yml 5.83 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:
16
    - docker build -t ci_raservices -f SubSystems/RAServices/Dockerfile .
17

18
prepare_ci_sas_docker_image:
19 20
  stage: prepare
  script:
21
    - docker build -t ci_base -f  Docker/lofar-ci/Dockerfile_ci_base .
22 23
    - docker build -t ci_sas -f  Docker/lofar-ci/Dockerfile_ci_sas .

24 25 26 27
#
# BUILD STAGE
#

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

50 51
build_TMSS:
  stage: build
52
  image: ci_sas:latest
53 54 55 56 57
  script:
    - PACKAGE=TMSS
    - echo "Building $PACKAGE..."
    - mkdir -p build/gnucxx11_opt
    - cd build/gnucxx11_opt
58
    - cmake -DBUILD_PACKAGES=$PACKAGE -DCASACORE_ROOT_DIR=/opt/casacore/ -DCASAREST_ROOT_DIR=/opt/casarest/ -DUSE_LOG4CPLUS=false ../..
59
    - make -j 6
60
    - make install
61
  dependencies:
62
    - prepare_ci_sas_docker_image
63 64 65
  artifacts:
    expire_in: 6 hours
    paths:
66
      - build/gnucxx11_opt
67 68 69 70 71 72 73 74

#
# DOCKERIZE
#

dockerize_TMSS:
  stage: dockerize
  script:
75
    - cd build/gnucxx11_opt
Auke L. Klazema's avatar
Auke L. Klazema committed
76
    - ls *
77
    - docker build -t tmss_django:$CI_COMMIT_SHORT_SHA -f docker/Dockerfile-tmss .
78
    - cd ../..
79 80 81 82 83 84 85 86 87
    - 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:
88
    - build_TMSS
89

90
#
91 92
# UNIT TEST STAGE
#
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
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
109 110

#
111
# INTEGRATION TEST STAGE
112 113
#

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
# 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
133

134 135 136 137 138 139 140 141 142 143 144 145 146 147
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:~/
148 149 150 151
    - 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"
152 153
    - ssh lofarsys@scu199.control.lofar "docker-compose -f docker-compose-scu199.yml up -d"
  dependencies:
154
    - build_TMSS
155
  when: manual
156

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
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:
177
    - build_TMSS
178 179 180
  when: manual
  only:
    - "master"