.gitlab-ci.yml 11.7 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:
gpernot's avatar
gpernot committed
144
    - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" 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
aregimbe's avatar
aregimbe committed
148

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

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

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

Guillaume Pasero's avatar
Guillaume Pasero committed
177
centos-xdk-build:
178 179 180
  extends: .common-build
  image: $BUILD_IMAGE_REGISTRY/otb-centos-superbuild-base:6.6
  script:
181 182
    - 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
183
    - mv build_packages/OTB-*.run . || true
184 185 186
  needs:
    - job: centos-xdk-prepare
      artifacts: true
Cédric Traizet's avatar
Cédric Traizet committed
187

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

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

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

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

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

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

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

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

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

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

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

gpernot's avatar
gpernot committed
351 352 353 354 355
#------------------------- Conda packages jobs ---------------------------------
conda-linux-build:
  extends: .common
  stage: build
  only:
356 357 358 359
    - develop
    - /^release-[0-9]+\.[0-9]+$/
  #  - develop@orfeotoolbox/otb
  #  - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
gpernot's avatar
gpernot committed
360 361
  image: $BUILD_IMAGE_REGISTRY/otb-conda-build:latest
  allow_failure: true
362 363
  before_script:
    - export CI_SKIP_CDASH=1
gpernot's avatar
gpernot committed
364 365 366 367 368
  script:
    - export otb_tag=${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
    - ./CI/conda_build.sh
  dependencies: []

369
#---------------------------- Deploy job ---------------------------------------
370 371 372 373 374 375 376
deploy:
  tags:
    - deploy
  image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7
  stage: deploy
  extends: .general
  only:
377 378
    - develop@orfeotoolbox/otb
    - /^release-[0-9]+\.[0-9]+$/@orfeotoolbox/otb
379 380 381 382 383
  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:
384 385 386 387 388 389 390 391 392 393 394 395
    - ./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
396

397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
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