.gitlab-ci-for-lidarview.yml 11.3 KB
Newer Older
1
2
3
4
5
6
7
8
# If don't know how gitlab-ci is working, please refer to the official documentation
# see https://docs.gitlab.com/ee/ci/quick_start/
# If you need information about some keyword, please refer to the official documentation
# see https://docs.gitlab.com/ee/ci/yaml/
# If you need to modify or understand this CI script don't hesitate to use gitlab ci-lint tool
# see https://gitlab.kitware.com/LidarView/lidarview-core/-/ci/lint

variables:
9
  GIT_SUBMODULE_STRATEGY: recursive # see https://docs.gitlab.com/ee/ci/git_submodules.html#using-git-submodules-in-your-ci-jobs
10
11
  GIT_LFS_SKIP_SMUDGE: 1 # do not doawnload test data, see https://github.com/git-lfs/git-lfs/blob/master/docs/man/git-lfs-config.5.ronn#other-settings
  # user defined variable
12
  rel_path_to_lidarview_build_dir: lidarview-superbuild/common-superbuild/lidarview/build/
13
14
15
  # - gitlab only evaluate variable at depth 1, so it's not possible to reuse
  #   superbuild_build_dir to construct lidarview_build_dir
  #   see https://gitlab.com/gitlab-org/gitlab-runner/issues/1280
16
17
  superbuild_build_dir: $CI_BUILDS_DIR/SB/$SB_BUILD_PREFIX/$CI_PROJECT_NAME
  lidarview_build_dir: $CI_BUILDS_DIR/SB/$SB_BUILD_PREFIX/$CI_PROJECT_NAME/$rel_path_to_lidarview_build_dir
18
19
20
21
  # This variable should set only if the script is trigger from a LidarView submodule
  # This will enable to run the pipeline with the updated module
  TRIGGER_MODULE_PATH: '' # path of the module that trigger the pipeline relative to LidarView
  TRIGGER_MODULE_SHA: '' # commit sha of the module that trigger the pipeline
22
23
24
25
  SB_BUILD_PREFIX: '' # use a unique value to have a custom SB dir for some branches and not rely on the generic one
                      # this may be usefull, when you make changes to the superbuild, and want to check
                      # that this change pass the CI pipeline, but in the mean time you don't want to
                      # replace the common on.
26
27
28

stages:
  - superbuild
Nick Laurenson's avatar
Nick Laurenson committed
29
  - configure
30
31
  - build
  - test
Nick Laurenson's avatar
Nick Laurenson committed
32
  - package
33

34
# default parameters for all jobs, see https://docs.gitlab.com/ee/ci/yaml/#setting-default-parameters
35
default:
36
37
38
39
40
  before_script: &default_before_script_anchor
    # TRIGGER_MODULE_PATH and TRIGGER_MODULE_SHA, should be empty if the CI is triggered from LidarView
    # so the next fetching and checkout will basically do nothing.
    # "$git checkout " is a glorified no-op (no operation), see https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt-emgitcheckoutemltbranchgt
    - cd $CI_PROJECT_DIR/$TRIGGER_MODULE_PATH
MelanieCarriere's avatar
MelanieCarriere committed
41
    - git fetch --all
42
    - git checkout $TRIGGER_MODULE_SHA
43
44
45
  retry:
    max: 2
    when: runner_system_failure
46
  interruptible: true
47

48
49
50
51
52
53
54
55
56
# create a pipeline only in some cases : merge_request, tag, master branch
# see https://docs.gitlab.com/ee/ci/yaml/#workflowrules
workflow:
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == "master"


57
58
59
60
61
62
63
# job starting with a . are not run, see https://docs.gitlab.com/ee/ci/yaml/#hidden-keys-jobs
# but they can be used as:
# - anchor., which is yalm specific.
#   see https://docs.gitlab.com/ee/ci/yaml/#anchors
# - base job class (via the extends keyword), which is gitlab specific.
#   See https://docs.gitlab.com/ee/ci/yaml/#extends

Nick Laurenson's avatar
Nick Laurenson committed
64
65
66
67
68
69
70
71
.default_rules:
  rules:
    # Add option to disable the CI pipeline for a givent os.
    # To do so you must define some variable in the project CI settings, see https://docs.gitlab.com/ee/ci/variables/#via-the-ui
    # - DISABLE_OSX for osx
    # - DISABLE_WINDOWS for windows
    # - DISABLE_LINUX for linux
    - if: $DISABLE_OSX && $CI_JOB_NAME =~ /^osx*/
72
      when: never
Nick Laurenson's avatar
Nick Laurenson committed
73
    - if: $DISABLE_WINDOWS && $CI_JOB_NAME =~ /^windows*/
74
      when: never
Nick Laurenson's avatar
Nick Laurenson committed
75
    - if: $DISABLE_LINUX && $CI_JOB_NAME =~ /^linux*/
76
      when: never
Nick Laurenson's avatar
Nick Laurenson committed
77
78
79
    # define the manual job
    - if: $CI_JOB_STAGE == "superbuild" || $CI_JOB_STAGE == "package"
      when: manual
80
81
82
      # need to allow_failure as otherwise, this manual jobs will caused the pipeline status to be marked as "Blocked"
      # see https://gitlab.com/gitlab-org/gitlab/-/issues/27095
      allow_failure: true
83
84
    - when: on_success

85
86
.superbuild:
  stage: superbuild
87
  timeout: 5h
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  extends: .default_rules
  script:
    - cmake -E remove_directory $superbuild_build_dir
    - cmake -E make_directory $superbuild_build_dir
    - cd $superbuild_build_dir
    - > # must use | instead of > for multiline string here as some variable may be empty, otherwise gitlab doesn't manage to parse it correclty
      cmake -DCMAKE_BUILD_TYPE=Release
      $sb_cmake_option_GENERATOR
      $sb_cmake_option_USE_SYSTEM_qt5
      $sb_cmake_option_QT5_DIR
      $sb_cmake_option_CMAKE_OSX_ARCHITECTURES
      $sb_cmake_option_CMAKE_OSX_DEPLOYMENT_TARGET
      $sb_cmake_option_CMAKE_OSX_SDK
      -DBUILD_TESTING=ON
      -Dsuperbuild_download_location="../downloads"
      $CI_PROJECT_DIR/Superbuild
    - cmake --build . --parallel 8

Nick Laurenson's avatar
Nick Laurenson committed
106
107
108
109
110
111
112
113
.configure:
  stage: configure
  extends: .default_rules
  script:
    - cd $lidarview_build_dir
    # create a compilation database for the analize stage (clang-tidy)
    - cmake -DBUILD_TESTING=True -DCMAKE_EXPORT_COMPILE_COMMANDS=True .

114
115
116
117
.build:
  stage: build
  extends: .default_rules
  script:
118
    - cd $lidarview_build_dir
119
    - cmake --build . --target install --parallel 8
120
121

.test:
122
123
  variables:
    GIT_LFS_SKIP_SMUDGE: 0 # download the test data
124
    DISPLAY: ":0" # Enable UI Capabilities, may not interfere too much on win32
125
  stage: test
126
  extends: .default_rules
127
128
  script:
    - cd $lidarview_build_dir
129
    # in some occasion, the machine on which the runner run can be under heavily load
130
131
    # this may caused some failure (ex: Stream tests), so rerun the failing test
    - ctest --repeat until-pass:3
132
133
134

.package:
  stage: package
Nick Laurenson's avatar
Nick Laurenson committed
135
  extends: .default_rules
Nick Laurenson's avatar
Nick Laurenson committed
136
  needs: []
137
  script:
138
    - git fetch --tags # GIT_STRATEGY doesn't clone tags, see https://gitlab.com/gitlab-org/gitlab-runner/issues/11737
139
140
    - git fetch --depth=10000 --tags # despite GIT_STRATEGY and git fetch --tags, git describe fail
    - git describe
141
142
    - cd $lidarview_build_dir
    - cmake -DBUILD_TESTING=False .
143
    - cd $superbuild_build_dir
144
    - cmake --build . --parallel 8
145
146
147
148
149
150
151
152
153
154
    # rely on paraview superbuild packaging system
    # the packaging is launched via a test
    - ctest
  artifacts:
    name: $CI_JOB_NAME
    paths:
      - ./*.dmg
      - ./*.zip
      - ./*.exe
      - ./*.tar.gz
155
      - ./*.tar.xz
156
157
158
159
160
161
162
163
164
165
166
167
    expire_in: 1 day

########################
# System configuration #
########################
# Need to know:
# - On powershell it's not possible to use $CI_BUILDS_DIR in GIT_CLONE_PATH
#   due to some incoherence with / and \\ in gitlab. So you need to garanty
#   manually that GIT_CLONE_PATH is inside the build_dir specify in the
#   runner configuration file (congif.toml)

.linux_runner_config:
168
  tags: [unix]
Nick Laurenson's avatar
Nick Laurenson committed
169
  resource_group: linux_machine
170
171
172

.osx_runner_config:
  variables:
173
174
175
    sb_cmake_option_CMAKE_OSX_ARCHITECTURES: -DCMAKE_OSX_ARCHITECTURES=x86_64
    sb_cmake_option_CMAKE_OSX_DEPLOYMENT_TARGET: -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10
    sb_cmake_option_CMAKE_OSX_SDK: -DCMAKE_OSX_SDK=macosx10.12
Jerome Dias's avatar
Jerome Dias committed
176
177
    sb_cmake_option_USE_SYSTEM_qt5: -DUSE_SYSTEM_qt5=True
    sb_cmake_option_QT5_DIR: -DQt5_DIR=/Users/veloviewci/Dev/Qt5.10.1/5.10.1/clang_64/lib/cmake/Qt5
178
  tags: [osx]
Nick Laurenson's avatar
Nick Laurenson committed
179
  resource_group: osx_machine
180

181
.windows_runner_config:
182
183
  before_script:
    - *default_before_script_anchor
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
    # to use the Microsoft C++ Toolset from the command line, some environment variable need to be set
    # To help with this, Microsoft provide the vcvarsall.bat script that set different environment see
    # https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019
    # However the script is made for the command shell and the job run in a powershell.
    # A powershell can run a command shell script by using the `cmd` executable, but this imply
    # that environment variable are only set in the child cmd.exe instance. The environment variables need to
    # be update in the powershell too. This is why the function Invoke-CmdScript is needed as it invokes
    # the script and update the powershell environment.
    # This is taken from https://stackoverflow.com/a/41399983
    - | # pipe allow to use multiline command, see https://gitlab.com/gitlab-org/gitlab-runner/issues/166
      function Invoke-CmdScript {
        param(
          [String] $scriptName
        )
        $cmdLine = """$scriptName"" $args & set"
        & $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
          Select-String '^([^=]*)=(.*)$' |
          ForEach-Object {
            $varName = $_.Matches[0].Groups[1].Value
            $varValue = $_.Matches[0].Groups[2].Value
            Set-Item Env:$varName $varValue
        }
      }
    - Invoke-CmdScript "${vcvarsall_script_location}/vcvarsall.bat" $architecture
  variables:
    # on windows due to the max command length, superbuild and project directory names should be short
    # this is why PROJECT_ID is used instead of PROJECT_NAME
211
212
    # Gitlab doesn't handle well all path notation on windows and force the clone path to start with C:\\
    GIT_CLONE_PATH: C:\\S/$CI_PROJECT_ID
213
214
    superbuild_build_dir: C:/SB/$SB_BUILD_PREFIX/$CI_PROJECT_ID
    lidarview_build_dir: C:/SB/$SB_BUILD_PREFIX/$CI_PROJECT_ID/$rel_path_to_lidarview_build_dir
215
    vcvarsall_script_location: 'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC'
216
    architecture: x86_amd64
217
218
    sb_cmake_option_GENERATOR: -GNinja
    sb_cmake_option_USE_SYSTEM_qt5: -DUSE_SYSTEM_qt5=True
219
    sb_cmake_option_QT5_DIR: -DQt5_DIR="C:/Qt/Qt5.10.1/5.10.1/msvc2015_64/lib/cmake/Qt5"
220
  tags: [windows]
Nick Laurenson's avatar
Nick Laurenson committed
221
  resource_group: windows_machine
222
223
224
225

##############
# Superbuild #
##############
226
linux_superbuild:
227
228
229
  extends:
    - .linux_runner_config
    - .superbuild
230

231
232
233
osx_superbuild:
  extends:
    - .osx_runner_config
234
    - .superbuild
235

236
237
238
windows_superbuild:
  extends:
    - .windows_runner_config
239
    - .superbuild
240

Nick Laurenson's avatar
Nick Laurenson committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
##############
#  Analize   #
##############
linux_configure:
  extends:
    - .linux_runner_config
    - .configure

osx_configure:
  extends:
    - .osx_runner_config
    - .configure

windows_configure:
  extends:
    - .windows_runner_config
    - .configure

259
260
261
262
263
264
265
##############
#   Build    #
##############
linux_build:
  extends:
    - .linux_runner_config
    - .build
Nick Laurenson's avatar
Nick Laurenson committed
266
  needs: [linux_configure]
267
268
269
270
271

osx_build:
  extends:
    - .osx_runner_config
    - .build
Nick Laurenson's avatar
Nick Laurenson committed
272
  needs: [osx_configure]
273
274
275
276
windows_build:
  extends:
    - .windows_runner_config
    - .build
Nick Laurenson's avatar
Nick Laurenson committed
277
  needs: [windows_configure]
278
279
280
281

##############
#    Test    #
##############
282
linux_test:
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
  extends:
    - .linux_runner_config
    - .test
  needs: [linux_build]

osx_test:
  extends:
    - .osx_runner_config
    - .test
  needs: [osx_build]

windows_test:
  extends:
    - .windows_runner_config
    - .test
  needs: [windows_build]

##############
#  Package   #
##############
# Need to know:
# - Artefact path must be inside CI_PROJECT_DIR
#   see https://docs.gitlab.com/ee/ci/yaml/README.html#artifactspaths

307
linux_package:
308
309
310
311
312
  extends:
    - .linux_runner_config
    - .package
  after_script:
    - mv $superbuild_build_dir/*.tar.gz $CI_PROJECT_DIR
313
    - mv $superbuild_build_dir/*.tar.xz $CI_PROJECT_DIR
314

315
osx_package:
316
317
318
319
320
321
  extends:
    - .osx_runner_config
    - .package
  after_script:
    - mv -f $superbuild_build_dir/*.dmg $CI_PROJECT_DIR

322
windows_package:
323
324
325
326
327
328
  extends:
    - .windows_runner_config
    - .package
  after_script:
    - mv $superbuild_build_dir/*.exe $CI_PROJECT_DIR
    - mv $superbuild_build_dir/*.zip $CI_PROJECT_DIR