.gitlab-ci.yml 10.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
#     https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

21 22 23 24 25
# WARNING!
# OTB uses Git-LFS to store the (large) tests data.
# Git-LFS is mostly transparent for the user and recent versions
# are able to use Git-LFS quite efficiently.
# But Git fails to manage efficiently numerous LFS data.
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
26
# We have to use directly git-lfs wrapping commands to have an
27
# efficient cloning step.
28
# Furthermore, Git-LFS and Gitlab sufer a bug preventing usage of
29 30
# GIT_STRATEGY=fetch (https://gitlab.com/gitlab-org/gitlab-runner/issues/3318)

31
variables:
32
  BUILD_IMAGE_REGISTRY: $CI_REGISTRY/orfeotoolbox/otb-build-env
33
  GIT_CLONE_PATH: $CI_BUILDS_DIR/otb
34
  DOCKER_DRIVER: overlay2
35
  GIT_DEPTH: "3"
36
  # Disable automatic checkout to let us fetch LFS before
37
  GIT_CHECKOUT: "false"
38
  # The fetch strategy fails with LFS and GitLab
39
  GIT_STRATEGY: "clone"
40

41
stages:
42
  - precheck
aregimbe's avatar
aregimbe committed
43
  - prepare
44
  - build
45
  - report
46
  - deploy
47

48
.general:
49 50 51 52 53 54
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure

Guillaume Pasero's avatar
Guillaume Pasero committed
55
.common:
Antoine Regimbeau's avatar
Antoine Regimbeau committed
56
  extends: .general
Guillaume Pasero's avatar
Guillaume Pasero committed
57 58 59 60 61
  before_script:
    # Provision efficiently the local LFS cache before checkout
    - git lfs fetch origin $CI_COMMIT_SHA
    - git checkout -f -q $CI_COMMIT_SHA
  after_script:
Guillaume Pasero's avatar
Guillaume Pasero committed
62
    - python3 -u CI/cdash_handler.py
Guillaume Pasero's avatar
Guillaume Pasero committed
63

Guillaume Pasero's avatar
Guillaume Pasero committed
64
.common-build:
Guillaume Pasero's avatar
Guillaume Pasero committed
65
  extends: .common
66 67 68 69
  only:
    - merge_requests
    - develop
    - /^release-[0-9]+\.[0-9]+$/
70
  stage: build
71 72 73 74 75 76
  artifacts:
    when: always
    expire_in: 24 hrs
    paths:
      - build/*/*.log #CMake log
      - log/*.txt # Others
77 78 79 80 81
      - CookBook-*-html.tar.gz
      - CookBook-*.pdf
      - OTB-Doxygen-*.tar.bz2
      - OTB-*.run
      - OTB-*.zip
82 83 84
      - build/compile_commands.json
      - build/ctest_report.xml
      - build/cppcheck_report.xml
Guillaume Pasero's avatar
Guillaume Pasero committed
85
      - build/coverage_report.xml
Guillaume Pasero's avatar
Guillaume Pasero committed
86

87
.common-prepare:
aregimbe's avatar
aregimbe committed
88
  extends: .general
89 90 91 92
  only:
    - merge_requests
    - develop
    - /^release-[0-9]+\.[0-9]+$/
aregimbe's avatar
aregimbe committed
93 94
  stage: prepare
  before_script:
95 96 97
    - export GIT_LFS_SKIP_SMUDGE=1
    - git checkout -f -q $CI_COMMIT_SHA
    - export GIT_LFS_SKIP_SMUDGE=0
aregimbe's avatar
aregimbe committed
98 99
  artifacts:
    expire_in: 24 hrs
Antoine Regimbeau's avatar
Antoine Regimbeau committed
100
    when: always
aregimbe's avatar
aregimbe committed
101
    paths:
102 103
      - sb_branch.txt # Needed to checkout correct branch in build step
      - build/*/*/*/*.log # Superbuild log
104
      - build/*/*/*/*.cmake
aregimbe's avatar
aregimbe committed
105

106
#-------------------------- precheck job ---------------------------------------
107 108 109 110 111 112 113 114 115 116 117 118
fast-build:
  extends: .common
  only: [merge_requests, branches]
  stage: precheck
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-native-develop:latest
  before_script:
    - export GIT_LFS_SKIP_SMUDGE=1
    - git checkout -f -q $CI_COMMIT_SHA
    - python3 CI/check_twin_pipelines.py
  script:
    - ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-18.04-fast
    - ccache -s
119

120
legal-check:
121
  extends: .common
122 123 124 125
  only:
    - merge_requests
    - develop
    - /^release-[0-9]+\.[0-9]+$/
126 127 128 129 130 131 132
  stage: precheck
  image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7
  variables:
    GIT_DEPTH: ""
  allow_failure: true
  script:
    - ./CI/contributors_check.sh
133
    - ./CI/headers_check.py
134 135
  after_script: []

136
#------------------------- prepare & build jobs --------------------------------
137 138
debian-build:
  extends: .common-build
139
  image: $BUILD_IMAGE_REGISTRY/otb-debian-native:testing
140
  allow_failure: true
141
  script:
142
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=debian-testing-gcc
143 144 145
  after_script:
    - export CI_ALLOW_FAILURE=ON
    - python3 -u CI/cdash_handler.py
146
  dependencies: []
147

148
## Ubuntu superbuild
Guillaume Pasero's avatar
Guillaume Pasero committed
149
ubuntu-xdk-prepare:
150 151 152
  extends: .common-prepare
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-base:18.04
  script:
153
    - ctest -VV -S CI/prepare_superbuild.cmake -DIMAGE_NAME:string=ubuntu-18.04-llvm
154

155
ubuntu-xdk-build-doc:
156 157 158 159
  extends: .common-build
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-base:18.04
  script:
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=ubuntu-18.04-llvm-xdk
160 161 162
    - mv build/CookBook-*-html.tar.gz . || true
    - mv build/Documentation/Cookbook/latex/CookBook-*.pdf . || true
    - mv build/Documentation/Doxygen/OTB-Doxygen-*.tar.bz2 . || true
163
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=ubuntu-18.04-llvm-xdk -DNAME_SUFFIX:string=-glibc-2.27
164
    - mv build_packages/OTB-*.run . || true
165 166
  dependencies:
    - ubuntu-xdk-prepare
167

Antoine Regimbeau's avatar
Antoine Regimbeau committed
168
## CentOS superbuild
169 170 171 172
centos-xdk-prepare:
  extends: .common-prepare
  image: $BUILD_IMAGE_REGISTRY/otb-centos-superbuild-base:6.6
  script:
173
    - ctest -VV -S CI/prepare_superbuild.cmake -DIMAGE_NAME:string=centos-6.6-gcc
174

175 176 177 178
centos-xdk-build:
  extends: .common-build
  image: $BUILD_IMAGE_REGISTRY/otb-centos-superbuild-base:6.6
  script:
179 180
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=centos-6.6-gcc
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=centos-6.6-gcc
181
    - mv build_packages/OTB-*.run . || true
182 183
  dependencies:
    - centos-xdk-prepare
184

Antoine Regimbeau's avatar
Antoine Regimbeau committed
185
## MacOS superbuild
186 187 188 189 190
macos-xdk-prepare:
  extends: .common-prepare
  tags:
    - macos
  script:
191
    - ctest -VV -S CI/prepare_superbuild.cmake -DIMAGE_NAME:string=macos-10.11.6-clang
192

193 194 195 196 197
macos-xdk-build:
  tags:
    - macos
  extends: .common-build
  script:
198 199
    - ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=macos-10.11.6-clang
    - ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=macos-10.11.6-clang
200
    - mv build_packages/OTB-*.run . || true
201 202
  dependencies:
    - macos-xdk-prepare
203

204
## Windows
205 206 207 208 209 210 211 212 213 214 215 216 217
.windows-prepare:
  extends: .common-prepare
  before_script:
# This override the previous before_script
    - set GIT_LFS_SKIP_SMUDGE=1
    - git checkout -f -q %CI_COMMIT_SHA%
    - set GIT_LFS_SKIP_SMUDGE=0

.windows-build:
  extends: .common-build
  before_script:
    - git lfs fetch origin %CI_COMMIT_SHA%
    - git checkout -f -q %CI_COMMIT_SHA%
218

219
# - Win10
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
windows-10-prepare:
  extends: .windows-prepare
  tags:
    - windows10
  script:
    - call ./CI/dev_env.bat x64 xdk 10
    - clcache.exe -s
    - ctest -C Release -V -S CI/prepare_superbuild.cmake
    - clcache.exe -s

windows-10-build:
  extends: .windows-build
  tags:
    - windows10
  script:
    - call ./CI/dev_env.bat x64 otb 10
    - clcache.exe -s
    - ctest -V -S CI/main_superbuild.cmake
    - clcache.exe -s
    - ctest -V -S CI/main_packages.cmake
240
    - move "build_packages\OTB-*.zip" . || dir build_packages
241 242
  dependencies:
    - windows-10-prepare
243

244
# - Win8.1
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
windows-8-prepare:
  extends: .windows-prepare
  tags:
    - windows8
  script:
    - call ./CI/dev_env.bat x86 xdk 8.1
    - clcache.exe -s
    - ctest -C Release -V -S CI/prepare_superbuild.cmake
    - clcache.exe -s

windows-8-build:
  extends: .windows-build
  tags:
    - windows8
  script:
    - call ./CI/dev_env.bat x86 otb 8.1
    - clcache.exe -s
    - ctest -V -S CI/main_superbuild.cmake
    - clcache.exe -s
    - ctest -V -S CI/main_packages.cmake
265
    - move "build_packages\OTB-*.zip" . || dir build_packages
266 267
  dependencies:
    - windows-8-prepare
268

269 270 271
#------------------------- QA related jobs -------------------------------------
ubuntu-xdk-qa-code-coverage:
  extends: .common-build
272 273 274 275 276 277 278
  only:
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
279 280 281 282
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-qa:18.04
  script:
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96"
               ctest -V -S CI/main_qa.cmake
283
                     -DIMAGE_NAME:string=ubuntu-18.04-llvm-qa
284
                     -DQA:BOOL=ON
285
    - ./CI/otb_coverage.sh
286 287 288 289 290 291 292 293
    - saxon-xslt -o build/ctest_report.xml
                 build/Testing/`head -n 1 build/Testing/TAG`/Test.xml
                 CI/ctest2junit.xsl
  dependencies:
    - ubuntu-xdk-prepare

ubuntu-xdk-qa-static-analysis:
  extends: .common-build
294 295 296 297 298 299 300
  only:
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-qa:18.04
  script:
    - find Modules -type f -regextype posix-extended -regex '.*\.(h|hxx)$' -exec dirname '{}' \; |
          grep -vE '^Modules/ThirdParty/' |
          sort -u > header_directories
    - cppcheck -j 8 -q --xml --xml-version=2 --enable=all
               --language=c++ --std=c++14 --platform=unix64
               --includes-file=header_directories
               -i Modules/ThirdParty Modules
               2> build/cppcheck_report.xml
  after_script: []
  dependencies:
    - ubuntu-xdk-prepare

ubuntu-xdk-report:
  extends: .common
  variables:
    GIT_DEPTH: ""
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-qa:18.04
  stage: report
  only:
322 323 324 325 326 327
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
328 329 330 331
  script:
    - sonar-scanner -Dproject.settings=sonar-project.properties
                    -Dsonar.host.url=https://sonar.orfeo-toolbox.org
                    -Dsonar.login=$SONAR_OTB_TOKEN
332
                    -Dsonar.projectKey=$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME
333 334 335 336 337 338 339 340
                    `test -z "$CI_COMMIT_TAG" || echo "-Dsonar.projectVersion=$CI_COMMIT_TAG"`
                    -Dsonar.branch.name=$CI_COMMIT_REF_NAME

  after_script: []
  dependencies:
    - ubuntu-xdk-qa-code-coverage
    - ubuntu-xdk-qa-static-analysis

341
#---------------------------- Deploy job ---------------------------------------
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
deploy:
  tags:
    - deploy
  image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7
  stage: deploy
  extends: .general
  only:
    - develop@orfeotoolbox/otb
    - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
  before_script:
    # Provision efficiently the local LFS cache before checkout
    - git lfs fetch origin $CI_COMMIT_SHA
    - git checkout -f -q $CI_COMMIT_SHA
  script:
    - ./CI/deploy.sh $CI_COMMIT_REF_NAME $RC_NUMBER
  dependencies:
358
    - ubuntu-xdk-build-doc
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
    - centos-xdk-build
    - macos-xdk-build
    - windows-8-build
    - windows-10-build

release-container:
  image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7
  stage: deploy
  extends: .general
  only:
    refs:
      - tags@orfeotoolbox/otb
    variables:
      - $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
  script:
    - curl --request POST
           --form token=$K8S_SECRET_RELEASE
           --form ref=master
           --form variables[OTB_TAG]=$CI_COMMIT_TAG
           https://gitlab.orfeo-toolbox.org/api/v4/projects/126/trigger/pipeline