.gitlab-ci.yml 12 KB
Newer Older
1
#
Sébastien Dinot's avatar
Sébastien Dinot committed
2
# Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#
# 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
fast-build:
  extends: .common
Sébastien Dinot's avatar
Sébastien Dinot committed
109 110 111
  only:
    - merge_requests
    - branches
112 113 114 115 116 117 118 119 120
  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
121

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

138
#------------------------- prepare & build jobs --------------------------------
139 140
debian-build:
  extends: .common-build
gpernot's avatar
gpernot committed
141
  image: $BUILD_IMAGE_REGISTRY/otb-debian-native:testing
142
  allow_failure: true
143
  script:
Guillaume Pernot's avatar
Guillaume Pernot committed
144
    - QT_QPA_PLATFORM=offscreen ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=debian-testing-gcc
145 146 147
  after_script:
    - export CI_ALLOW_FAILURE=ON
    - python3 -u CI/cdash_handler.py
148 149
  needs:
    - job: fast-build
aregimbe's avatar
aregimbe committed
150

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

158
ubuntu-xdk-build-doc:
159 160 161
  extends: .common-build
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-base:18.04
  script:
Guillaume Pernot's avatar
Guillaume Pernot committed
162 163
    - export QT_QPA_PLATFORM=offscreen
    - ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=ubuntu-18.04-llvm-xdk
164 165 166
    - mv build/CookBook-*-html.tar.gz . || true
    - mv build/Documentation/Cookbook/latex/CookBook-*.pdf . || true
    - mv build/Documentation/Doxygen/OTB-Doxygen-*.tar.bz2 . || true
Guillaume Pernot's avatar
Guillaume Pernot committed
167
    - ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=ubuntu-18.04-llvm-xdk -DNAME_SUFFIX:string=-glibc-2.27
168
    - mv build_packages/OTB-*.run . || true
169 170 171
  needs:
    - job: ubuntu-xdk-prepare
      artifacts: true
172

Antoine Regimbeau's avatar
Antoine Regimbeau committed
173
## CentOS superbuild
Guillaume Pasero's avatar
Guillaume Pasero committed
174
centos-xdk-prepare:
175 176 177
  extends: .common-prepare
  image: $BUILD_IMAGE_REGISTRY/otb-centos-superbuild-base:6.6
  script:
178
    - ctest -VV -S CI/prepare_superbuild.cmake -DIMAGE_NAME:string=centos-6.6-gcc
179

Guillaume Pasero's avatar
Guillaume Pasero committed
180
centos-xdk-build:
181 182 183
  extends: .common-build
  image: $BUILD_IMAGE_REGISTRY/otb-centos-superbuild-base:6.6
  script:
Guillaume Pernot's avatar
Guillaume Pernot committed
184 185 186
    - export QT_QPA_PLATFORM=offscreen
    - ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=centos-6.6-gcc
    - ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=centos-6.6-gcc
187
    - mv build_packages/OTB-*.run . || true
188 189 190
  needs:
    - job: centos-xdk-prepare
      artifacts: true
Cédric Traizet's avatar
Cédric Traizet committed
191

Antoine Regimbeau's avatar
Antoine Regimbeau committed
192
## MacOS superbuild
Guillaume Pasero's avatar
Guillaume Pasero committed
193
macos-xdk-prepare:
194
  extends: .common-prepare
195 196 197
  tags:
    - macos
  script:
198
    - ctest -VV -S CI/prepare_superbuild.cmake -DIMAGE_NAME:string=macos-10.11.6-clang
199

Guillaume Pasero's avatar
Guillaume Pasero committed
200
macos-xdk-build:
201 202 203 204
  tags:
    - macos
  extends: .common-build
  script:
205 206
    - 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
207
    - mv build_packages/OTB-*.run . || true
208 209 210
  needs:
    - job: macos-xdk-prepare
      artifacts: true
211

Guillaume Pasero's avatar
Guillaume Pasero committed
212
## Windows
213
.windows-prepare:
Guillaume Pasero's avatar
Guillaume Pasero committed
214
  extends: .common-prepare
aregimbe's avatar
aregimbe committed
215 216
  before_script:
# This override the previous before_script
217
    - set GIT_LFS_SKIP_SMUDGE=1
Guillaume Pasero's avatar
Guillaume Pasero committed
218
    - git checkout -f -q %CI_COMMIT_SHA%
219
    - set GIT_LFS_SKIP_SMUDGE=0
220

221
.windows-build:
Guillaume Pasero's avatar
Guillaume Pasero committed
222 223 224
  extends: .common-build
  before_script:
    - git lfs fetch origin %CI_COMMIT_SHA%
225
    - git checkout -f -q %CI_COMMIT_SHA%
226

Guillaume Pasero's avatar
Guillaume Pasero committed
227
# - Win10
228 229
windows-10-prepare:
  extends: .windows-prepare
230 231
  tags:
    - windows10
232
  script:
Guillaume Pasero's avatar
Guillaume Pasero committed
233
    - call ./CI/dev_env.bat x64 xdk 10
234 235 236 237
    - clcache.exe -s
    - ctest -C Release -V -S CI/prepare_superbuild.cmake
    - clcache.exe -s

238
windows-10-build:
239
  extends: .windows-build
Guillaume Pasero's avatar
Guillaume Pasero committed
240
  tags:
241
    - windows10
Guillaume Pasero's avatar
Guillaume Pasero committed
242 243 244 245 246
  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
247
    - ctest -V -S CI/main_packages.cmake
248
    - move "build_packages\OTB-*.zip" . || dir build_packages
249 250 251
  needs:
    - job: windows-10-prepare
      artifacts: true
Guillaume Pasero's avatar
Guillaume Pasero committed
252

Guillaume Pasero's avatar
Guillaume Pasero committed
253 254 255 256 257 258 259 260 261 262 263
# - 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
264
windows-8-build:
265
  extends: .windows-build
Guillaume Pasero's avatar
Guillaume Pasero committed
266
  tags:
267
    - windows8
Guillaume Pasero's avatar
Guillaume Pasero committed
268
  script:
Guillaume Pasero's avatar
Guillaume Pasero committed
269
    - call ./CI/dev_env.bat x86 otb 8.1
Guillaume Pasero's avatar
Guillaume Pasero committed
270 271 272
    - clcache.exe -s
    - ctest -V -S CI/main_superbuild.cmake
    - clcache.exe -s
Guillaume Pasero's avatar
Guillaume Pasero committed
273
    - ctest -V -S CI/main_packages.cmake
274
    - move "build_packages\OTB-*.zip" . || dir build_packages
275 276 277
  needs:
    - job: windows-8-prepare
      artifacts: true
278

279 280 281
#------------------------- QA related jobs -------------------------------------
ubuntu-xdk-qa-code-coverage:
  extends: .common-build
282 283 284 285 286 287 288
  only:
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
289 290
  image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-qa:18.04
  script:
Guillaume Pernot's avatar
Guillaume Pernot committed
291
    - QT_QPA_PLATFORM=offscreen ctest -V -S CI/main_qa.cmake
292
                     -DIMAGE_NAME:string=ubuntu-18.04-llvm-qa
293
                     -DQA:BOOL=ON
294
    - ./CI/otb_coverage.sh
295 296 297
    - saxon-xslt -o build/ctest_report.xml
                 build/Testing/`head -n 1 build/Testing/TAG`/Test.xml
                 CI/ctest2junit.xsl
298 299 300
  needs:
    - job: ubuntu-xdk-prepare
      artifacts: true
301

302 303
ubuntu-xdk-qa-static-analysis:
  extends: .common-build
304 305 306 307 308 309 310
  only:
    refs:
      - merge_requests
      - develop
      - /^release-[0-9]+\.[0-9]+$/
    variables:
      - $SONAR_OTB_TOKEN
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: []
322 323 324
  needs:
    - job: ubuntu-xdk-prepare
      artifacts: true
325 326 327 328 329 330 331 332

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

  after_script: []
348 349 350 351 352
  needs:
    - job: ubuntu-xdk-qa-code-coverage
      artifacts: true
    - job: ubuntu-xdk-qa-static-analysis
      artifacts: true
353

gpernot's avatar
gpernot committed
354 355 356 357 358
#------------------------- Conda packages jobs ---------------------------------
conda-linux-build:
  extends: .common
  stage: build
  only:
359 360
    - nightly
    - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
gpernot's avatar
gpernot committed
361 362 363 364 365
  image: $BUILD_IMAGE_REGISTRY/otb-conda-build:latest
  allow_failure: true
  script:
    - export otb_tag=${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
    - ./CI/conda_build.sh
366
  after_script: []
367 368
  needs:
    - job: fast-build
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
      artifacts: false
  artifacts:
    when: always
    expire_in: 24 hrs
    paths:
      - conda-bld/*

conda-linux-deploy:
  extends: .general
  stage: deploy
  only:
    - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
  image: $BUILD_IMAGE_REGISTRY/otb-conda-build:latest
  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/conda_deploy.sh
  needs:
    - job: conda-linux-build
      artifacts: yes
gpernot's avatar
gpernot committed
391

392
#---------------------------- Deploy job ---------------------------------------
393 394 395 396 397 398 399
deploy:
  tags:
    - deploy
  image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7
  stage: deploy
  extends: .general
  only:
400 401
    - develop@orfeotoolbox/otb
    - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
402 403 404 405 406
  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:
407 408 409 410 411 412 413 414 415 416 417 418
    - ./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
419

420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
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