.gitlab-ci.yml 11.2 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.
#

Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
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
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
27
# efficient cloning step.
28
# Furthermore, Git-LFS and Gitlab sufer a bug preventing usage of
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
29 30
# GIT_STRATEGY=fetch (https://gitlab.com/gitlab-org/gitlab-runner/issues/3318)

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

Sébastien Dinot's avatar
Sébastien Dinot committed
41
stages:
Guillaume Pasero's avatar
Guillaume Pasero committed
42
  - precheck
aregimbe's avatar
aregimbe committed
43
  - prepare
Sébastien Dinot's avatar
Sébastien Dinot committed
44
  - build
45
  - report
46
  - deploy
Sébastien Dinot's avatar
Sébastien Dinot committed
47

48
.general:
Sébastien Dinot's avatar
Sébastien Dinot committed
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
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
Antoine Regimbeau's avatar
Antoine Regimbeau 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:
Antoine Regimbeau's avatar
Antoine Regimbeau committed
102 103
      - sb_branch.txt # Needed to checkout correct branch in build step
      - build/*/*/*/*.log # Superbuild log
Antoine Regimbeau's avatar
Antoine Regimbeau committed
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

Sébastien Dinot's avatar
Sébastien Dinot committed
120
legal-check:
Sébastien Dinot's avatar
Sébastien Dinot committed
121
  extends: .common
122 123 124 125
  only:
    - merge_requests
    - develop
    - /^release-[0-9]+\.[0-9]+$/
Sébastien Dinot's avatar
Sébastien Dinot committed
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
Sébastien Dinot's avatar
Sébastien Dinot committed
133
    - ./CI/headers_check.py
Sébastien Dinot's avatar
Sébastien Dinot committed
134 135
  after_script: []

136
#------------------------- prepare & build jobs --------------------------------
137 138
debian-build:
  extends: .common-build
gpernot's avatar
gpernot committed
139
  image: $BUILD_IMAGE_REGISTRY/otb-debian-native:testing
140
  allow_failure: true
141
  script:
gpernot's avatar
gpernot committed
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
aregimbe's avatar
aregimbe committed
146

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

154
ubuntu-xdk-build-doc:
155 156 157
  extends: .common-build
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-base:18.04
  script:
158
    - 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
159 160 161
    - mv build/CookBook-*-html.tar.gz . || true
    - mv build/Documentation/Cookbook/latex/CookBook-*.pdf . || true
    - mv build/Documentation/Doxygen/OTB-Doxygen-*.tar.bz2 . || true
162
    - 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
163
    - mv build_packages/OTB-*.run . || true
164 165 166
  needs:
    - job: ubuntu-xdk-prepare
      artifacts: true
167

Antoine Regimbeau's avatar
Antoine Regimbeau committed
168
## CentOS superbuild
Guillaume Pasero's avatar
Guillaume Pasero committed
169
centos-xdk-prepare:
170 171 172
  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

Guillaume Pasero's avatar
Guillaume Pasero committed
175
centos-xdk-build:
176 177 178
  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 184
  needs:
    - job: centos-xdk-prepare
      artifacts: true
Cédric Traizet's avatar
Cédric Traizet committed
185

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

Guillaume Pasero's avatar
Guillaume Pasero committed
194
macos-xdk-build:
195 196 197 198
  tags:
    - macos
  extends: .common-build
  script:
199 200
    - 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
201
    - mv build_packages/OTB-*.run . || true
202 203 204
  needs:
    - job: macos-xdk-prepare
      artifacts: true
205

Guillaume Pasero's avatar
Guillaume Pasero committed
206
## Windows
207
.windows-prepare:
Guillaume Pasero's avatar
Guillaume Pasero committed
208
  extends: .common-prepare
aregimbe's avatar
aregimbe committed
209 210
  before_script:
# This override the previous before_script
211
    - set GIT_LFS_SKIP_SMUDGE=1
Guillaume Pasero's avatar
Guillaume Pasero committed
212
    - git checkout -f -q %CI_COMMIT_SHA%
213
    - set GIT_LFS_SKIP_SMUDGE=0
214

215
.windows-build:
Guillaume Pasero's avatar
Guillaume Pasero committed
216 217 218
  extends: .common-build
  before_script:
    - git lfs fetch origin %CI_COMMIT_SHA%
219
    - git checkout -f -q %CI_COMMIT_SHA%
220

Guillaume Pasero's avatar
Guillaume Pasero committed
221
# - Win10
222 223
windows-10-prepare:
  extends: .windows-prepare
224 225
  tags:
    - windows10
226
  script:
Guillaume Pasero's avatar
Guillaume Pasero committed
227
    - call ./CI/dev_env.bat x64 xdk 10
228 229 230 231
    - clcache.exe -s
    - ctest -C Release -V -S CI/prepare_superbuild.cmake
    - clcache.exe -s

232
windows-10-build:
233
  extends: .windows-build
Guillaume Pasero's avatar
Guillaume Pasero committed
234
  tags:
235
    - windows10
Guillaume Pasero's avatar
Guillaume Pasero committed
236 237 238 239 240
  script:
    - call ./CI/dev_env.bat x64 otb 10
    - clcache.exe -s
    - ctest -V -S CI/main_superbuild.cmake
    - clcache.exe -s
Guillaume Pasero's avatar
Guillaume Pasero committed
241
    - ctest -V -S CI/main_packages.cmake
242
    - move "build_packages\OTB-*.zip" . || dir build_packages
243 244 245
  needs:
    - job: windows-10-prepare
      artifacts: true
Guillaume Pasero's avatar
Guillaume Pasero committed
246

Guillaume Pasero's avatar
Guillaume Pasero committed
247 248 249 250 251 252 253 254 255 256 257
# - Win8.1
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

Guillaume Pasero's avatar
Guillaume Pasero committed
258
windows-8-build:
259
  extends: .windows-build
Guillaume Pasero's avatar
Guillaume Pasero committed
260
  tags:
261
    - windows8
Guillaume Pasero's avatar
Guillaume Pasero committed
262
  script:
Guillaume Pasero's avatar
Guillaume Pasero committed
263
    - call ./CI/dev_env.bat x86 otb 8.1
Guillaume Pasero's avatar
Guillaume Pasero committed
264 265 266
    - clcache.exe -s
    - ctest -V -S CI/main_superbuild.cmake
    - clcache.exe -s
Guillaume Pasero's avatar
Guillaume Pasero committed
267
    - ctest -V -S CI/main_packages.cmake
268
    - move "build_packages\OTB-*.zip" . || dir build_packages
269 270 271
  needs:
    - job: windows-8-prepare
      artifacts: true
272

273 274 275
#------------------------- QA related jobs -------------------------------------
ubuntu-xdk-qa-code-coverage:
  extends: .common-build
276 277 278 279 280 281 282
  only:
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
283 284 285 286
  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
287
                     -DIMAGE_NAME:string=ubuntu-18.04-llvm-qa
288
                     -DQA:BOOL=ON
289
    - ./CI/otb_coverage.sh
290 291 292
    - saxon-xslt -o build/ctest_report.xml
                 build/Testing/`head -n 1 build/Testing/TAG`/Test.xml
                 CI/ctest2junit.xsl
293 294 295
  needs:
    - job: ubuntu-xdk-prepare
      artifacts: true
296

297 298
ubuntu-xdk-qa-static-analysis:
  extends: .common-build
299 300 301 302 303 304 305
  only:
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
306 307 308 309 310 311 312 313 314 315 316
  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: []
317 318 319
  needs:
    - job: ubuntu-xdk-prepare
      artifacts: true
320 321 322 323 324 325 326 327

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

  after_script: []
343 344 345 346 347
  needs:
    - job: ubuntu-xdk-qa-code-coverage
      artifacts: true
    - job: ubuntu-xdk-qa-static-analysis
      artifacts: true
348

349
#---------------------------- Deploy job ---------------------------------------
350 351 352 353 354 355 356
deploy:
  tags:
    - deploy
  image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7
  stage: deploy
  extends: .general
  only:
357 358
    - develop@orfeotoolbox/otb
    - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
359 360 361 362 363
  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:
364 365 366 367 368 369 370 371 372 373 374 375
    - ./CI/deploy.sh $CI_COMMIT_REF_NAME $RC_NUMBER
  needs:
    - job: ubuntu-xdk-build-doc
      artifacts: true
    - job: centos-xdk-build
      artifacts: true
    - job: macos-xdk-build
      artifacts: true
    - job: windows-8-build
      artifacts: true
    - job: windows-10-build
      artifacts: true
gpernot's avatar
gpernot committed
376

377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
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