.gitlab-ci.yml 13.5 KB
Newer Older
Ryan Pavlik's avatar
Ryan Pavlik committed
1
# SPDX-License-Identifier: CC0-1.0
2
# SPDX-FileCopyrightText: 2018-2021 Collabora, Ltd. and the Monado contributors
Ryan Pavlik's avatar
Ryan Pavlik committed
3

Daniel Stone's avatar
Daniel Stone committed
4
variables:
5
  FDO_UPSTREAM_REPO: monado/monado
Ryan Pavlik's avatar
Ryan Pavlik committed
6

7
.templates_sha: &templates_sha db8eb22cd1abb036560faaebd36a38565a3ebda2
8

9
# Variables listing packages for Debian-based distros
10
.monado.variables.debian-based-packages:
11
  variables:
12 13 14 15 16 17 18 19 20 21
    # Packages required for build and some other basic jobs
    CORE_REQUIRED_PACKAGES: "build-essential git wget unzip cmake meson ninja-build libeigen3-dev curl patch python3 pkg-config libx11-dev libx11-xcb-dev libxxf86vm-dev libxrandr-dev libxcb-randr0-dev libvulkan-dev glslang-tools libglvnd-dev libgl1-mesa-dev ca-certificates libusb-1.0-0-dev libudev-dev"

    # These are optional packages, that we're building against to ensure we build as much code as possible
    FEATURE_PACKAGES: "libhidapi-dev libwayland-dev libuvc-dev libavcodec-dev libopencv-dev libv4l-dev libcjson-dev libsdl2-dev libegl1-mesa-dev libdbus-1-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libsystemd-dev"

    # Only used for building packages
    PACKAGING_PACKAGES: "devscripts debhelper dput-ng gettext-base markdown"

    # Used for ancillary "not compilation" jobs/features, like docs, changelogs, formatting, etc.
22 23
    TOOLS_REQUIRED_PACKAGES: "clang-format-7 codespell doxygen graphviz python3-pip python3-click"

24 25 26
    # The NDK builder uses only these packages
    NDK_PACKAGES: "git wget unzip cmake meson ninja-build libeigen3-dev python3 pkg-config ca-certificates glslang-tools"

27
# Variables for build and usage of Debian 10 (Buster) image
28
.monado.variables.debian:buster:
29 30
  variables:
    FDO_DISTRIBUTION_VERSION: buster
31
    FDO_DISTRIBUTION_TAG: "2021-02-23.0"
32

33
# Variables for build and usage of Ubuntu 20.04 LTS (Focal) image
34
.monado.variables.ubuntu:focal:
35 36
  variables:
    FDO_DISTRIBUTION_VERSION: "20.04"
37
    FDO_DISTRIBUTION_TAG: "2021-02-23.0"
38

Ryan Pavlik's avatar
Ryan Pavlik committed
39
# Variables for build and usage of Debian 10 (Buster) + Android NDK image
40
.monado.variables.debian:buster-ndk:
Ryan Pavlik's avatar
Ryan Pavlik committed
41 42
  variables:
    FDO_DISTRIBUTION_VERSION: buster
43
    FDO_DISTRIBUTION_TAG: "2020-05-06.0"
Ryan Pavlik's avatar
Ryan Pavlik committed
44 45
    FDO_REPO_SUFFIX: ndk

46
# Variables for build and usage of Arch Linux image
47
.monado.variables.arch:rolling:
48
  variables:
Ryan Pavlik's avatar
Ryan Pavlik committed
49
    FDO_DISTRIBUTION_TAG: "2020-05-12.0"
50

Daniel Stone's avatar
Daniel Stone committed
51
include:
52 53
  - project: "freedesktop/ci-templates"
    ref: *templates_sha
Ryan Pavlik's avatar
Ryan Pavlik committed
54
    file: "/templates/debian.yml"
55 56 57
  - project: "freedesktop/ci-templates"
    ref: *templates_sha
    file: "/templates/ubuntu.yml"
58 59
  - project: "freedesktop/ci-templates"
    ref: *templates_sha
Ryan Pavlik's avatar
Ryan Pavlik committed
60
    file: "/templates/arch.yml"
Daniel Stone's avatar
Daniel Stone committed
61 62 63 64

stages:
  - container_prep
  - build
65
  - package
66
  - reprepro
Ryan Pavlik's avatar
Ryan Pavlik committed
67
  - pages
68
  - deploy
Daniel Stone's avatar
Daniel Stone committed
69

70 71 72 73
###
# Container prep jobs

# Base for all container prep
74
.monado.variables.container-prep-base:
75 76 77 78
  # "stage" set here doesn't work, for some reason
  variables:
    # no need to pull the whole tree for rebuilding the image - is this still needed?
    GIT_STRATEGY: none
79
    # Each most-derived container prep job has a script to set up stuff for it.
80
    FDO_DISTRIBUTION_EXEC: "bash .gitlab-ci/$(echo ${CI_JOB_NAME} | sed 's/:/_/g').sh"
81

Ryan Pavlik's avatar
Ryan Pavlik committed
82
# Debian Buster (x64 + i386)
Ryan Pavlik's avatar
Ryan Pavlik committed
83
debian:container_prep:
Daniel Stone's avatar
Daniel Stone committed
84
  stage: container_prep
85
  extends:
86 87 88
    - .monado.variables.debian:buster
    - .monado.variables.container-prep-base
    - .monado.variables.debian-based-packages
89
    - .fdo.container-build@debian # from ci-templates
Ryan Pavlik's avatar
Ryan Pavlik committed
90
  variables:
91 92
    # a list of packages to install - assembled from .monado.variables.debian-based-packages, plus reprepro
    FDO_DISTRIBUTION_PACKAGES: "${CORE_REQUIRED_PACKAGES} ${FEATURE_PACKAGES} ${PACKAGING_PACKAGES} ${TOOLS_REQUIRED_PACKAGES} reprepro"
Daniel Stone's avatar
Daniel Stone committed
93

94
# Arch Linux (x64)
Ryan Pavlik's avatar
Ryan Pavlik committed
95 96
arch:container_prep:
  stage: container_prep
97
  extends:
98 99
    - .monado.variables.arch:rolling
    - .monado.variables.container-prep-base
100
    - .fdo.container-build@arch # from ci-templates
Ryan Pavlik's avatar
Ryan Pavlik committed
101 102
  variables:
    # a list of packages to install
Ryan Pavlik's avatar
Ryan Pavlik committed
103
    FDO_DISTRIBUTION_PACKAGES: "git gcc clang cmake meson ninja pkgconfig python3 diffutils patch doxygen graphviz eigen hidapi libxrandr mesa glslang vulkan-headers vulkan-icd-loader check glfw-x11 libusb opencv gtk3 ffmpeg v4l-utils qt5-base"
Ryan Pavlik's avatar
Ryan Pavlik committed
104

105
# Ubuntu Focal (x64)
106 107 108
ubuntu:container_prep:
  stage: container_prep
  extends:
109 110 111
    - .monado.variables.ubuntu:focal
    - .monado.variables.container-prep-base
    - .monado.variables.debian-based-packages
112 113
    - .fdo.container-build@ubuntu # from ci-templates
  variables:
114
    # a list of packages to install - assembled from .monado.variables.debian-based-packages
115
    FDO_DISTRIBUTION_PACKAGES: "${CORE_REQUIRED_PACKAGES} ${FEATURE_PACKAGES} ${PACKAGING_PACKAGES} ${TOOLS_REQUIRED_PACKAGES}"
116

Ryan Pavlik's avatar
Ryan Pavlik committed
117 118 119 120 121
# Debian Buster + the Android NDK in /opt/android-ndk
# The NDK itself gets installed by .gitlab-ci/ndk:container_prep.sh
ndk:container_prep:
  stage: container_prep
  extends:
122 123
    - .monado.variables.debian:buster-ndk
    - .monado.variables.container-prep-base
Ryan Pavlik's avatar
Ryan Pavlik committed
124 125
    - .fdo.container-build@debian # from ci-templates
  variables:
126
    # Repo suffix is set in .monado.variables.debian:buster-ndk
Ryan Pavlik's avatar
Ryan Pavlik committed
127
    # a list of packages to install
128
    FDO_DISTRIBUTION_PACKAGES: "${NDK_PACKAGES}"
Ryan Pavlik's avatar
Ryan Pavlik committed
129

130
# Style check job
131
format-and-spellcheck:
132
  extends:
133
    - .monado.variables.debian:buster
134
    - .fdo.distribution-image@debian # from ci-templates
135 136
  stage: build
  script:
Ryan Pavlik's avatar
Ryan Pavlik committed
137
    - scripts/format-and-spellcheck.sh
138 139 140 141 142 143
  artifacts:
    paths:
      - patches/
    expire_in: 1 week
    when: on_failure

144
# "Base" job for a CMake build
145
.monado.base-job.build-cmake:
Ryan Pavlik's avatar
Ryan Pavlik committed
146 147
  stage: build
  script:
Ryan Pavlik's avatar
Ryan Pavlik committed
148 149
    - mkdir build
    - pushd build
150
    - cmake -GNinja .. $CMAKE_ARGS
Ryan Pavlik's avatar
Ryan Pavlik committed
151 152
    # List build options
    - grep "^XRT_" CMakeCache.txt
Ryan Pavlik's avatar
Ryan Pavlik committed
153
    - ninja
154
    - ctest --output-on-failure
Drew DeVault's avatar
Drew DeVault committed
155

156
# "Base" job for a Meson build
157
.monado.base-job.build-meson:
Drew DeVault's avatar
Drew DeVault committed
158 159
  stage: build
  script:
Ryan Pavlik's avatar
Ryan Pavlik committed
160 161
    - mkdir build
    - pushd build
162
    - meson .. $MESON_ARGS
Ryan Pavlik's avatar
Ryan Pavlik committed
163
    - ninja
Drew DeVault's avatar
Drew DeVault committed
164

165 166
debian:cmake:
  extends:
167
    - .monado.variables.debian:buster
168
    - .fdo.distribution-image@debian # from ci-templates
169
    - .monado.base-job.build-cmake
170 171 172
  before_script:
    # Generate "changes since last release" and add to changelog,
    # since this is the build that makes our docs.
Ryan Pavlik's avatar
Ryan Pavlik committed
173 174 175 176
    - pip3 install proclamation
    - pushd doc/changes
    - proclamation build --overwrite vNEXT
    - popd
177 178 179
  artifacts:
    paths:
      - build/doc/html/
Ryan Pavlik's avatar
Ryan Pavlik committed
180

181 182
debian:cmake-no-opencv:
  extends:
183
    - .monado.variables.debian:buster
184
    - .fdo.distribution-image@debian # from ci-templates
185
    - .monado.base-job.build-cmake
186
  variables:
187
    CMAKE_ARGS: -DXRT_HAVE_OPENCV=OFF
188 189 190

debian:cmake-no-opengl:
  extends:
191
    - .monado.variables.debian:buster
192
    - .fdo.distribution-image@debian # from ci-templates
193
    - .monado.base-job.build-cmake
194
  variables:
195
    CMAKE_ARGS: -DXRT_HAVE_OPENGL=OFF
196 197 198

debian:cmake-no-sdl2:
  extends:
199
    - .monado.variables.debian:buster
200
    - .fdo.distribution-image@debian # from ci-templates
201
    - .monado.base-job.build-cmake
202
  variables:
203
    CMAKE_ARGS: -DXRT_HAVE_SDL2=OFF
204

205 206 207 208 209 210
debian:cmake-no-service:
  extends:
    - .monado.variables.debian:buster
    - .fdo.distribution-image@debian # from ci-templates
    - .monado.base-job.build-cmake
  variables:
211
    CMAKE_ARGS: -DXRT_FEATURE_SERVICE=OFF
212

213 214
arch:cmake:
  extends:
215
    - .monado.variables.arch:rolling
216
    - .fdo.distribution-image@arch # from ci-templates
217
    - .monado.base-job.build-cmake
218

Ryan Pavlik's avatar
Ryan Pavlik committed
219 220 221 222 223 224 225 226
arch:cmake:clang:
  extends:
    - .monado.variables.arch:rolling
    - .fdo.distribution-image@arch # from ci-templates
    - .monado.base-job.build-cmake
  variables:
    CMAKE_ARGS: -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

227 228
ubuntu:cmake:
  extends:
229
    - .monado.variables.ubuntu:focal
230
    - .fdo.distribution-image@ubuntu # from ci-templates
231
    - .monado.base-job.build-cmake
232

233 234
debian:meson:
  extends:
235
    - .monado.variables.debian:buster
236
    - .fdo.distribution-image@debian # from ci-templates
237
    - .monado.base-job.build-meson
238

239 240
ubuntu:meson:
  extends:
241
    - .monado.variables.ubuntu:focal
242
    - .fdo.distribution-image@ubuntu # from ci-templates
243
    - .monado.base-job.build-meson
244

245 246
arch:meson:
  extends:
247
    - .monado.variables.arch:rolling
248
    - .fdo.distribution-image@arch # from ci-templates
249
    - .monado.base-job.build-meson
250 251
  variables:
    MESON_ARGS: -Ddocs=disabled
252

Ryan Pavlik's avatar
Ryan Pavlik committed
253 254 255
# Cross-compiling
debian:meson:32bit:
  extends:
256
    - .monado.variables.debian:buster
Ryan Pavlik's avatar
Ryan Pavlik committed
257
    - .fdo.distribution-image@debian # from ci-templates
258
    - .monado.base-job.build-meson
Ryan Pavlik's avatar
Ryan Pavlik committed
259 260 261 262 263
  variables:
    MESON_ARGS: --prefix /usr --libdir /usr/lib/i386-linux-gnu --cross-file ../.gitlab-ci/i386-cross.txt

debian:cmake:32bit:
  extends:
264
    - .monado.variables.debian:buster
Ryan Pavlik's avatar
Ryan Pavlik committed
265
    - .fdo.distribution-image@debian # from ci-templates
266
    - .monado.base-job.build-cmake
Ryan Pavlik's avatar
Ryan Pavlik committed
267 268
  variables:
    # OpenCV and local OpenHMD doesn't play nicely with us in multi-arch.
269
    CMAKE_ARGS: -DCMAKE_TOOLCHAIN_FILE=../.gitlab-ci/i386.cmake -DXRT_HAVE_OPENCV=off -DXRT_BUILD_DRIVER_OHMD=off
Ryan Pavlik's avatar
Ryan Pavlik committed
270

271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
# Base of Android NDK builds.
# Takes the last :-delimited part of the name as the ABI to build for,
# so you don't need to do anything other than "extends" in the job
.monado.ndk:build-base:
  stage: build
  extends:
    - .monado.variables.debian:buster-ndk
    - .fdo.suffixed-image@debian # from ci-templates
  variables:
    ANDROID_PLATFORM: 26
  script:
    - mkdir build
    - pushd build
    # This extracts the ABI from the job name
    - export ABI=$(echo $CI_JOB_NAME | cut --delimiter=":" -f 2)
    # Note we are pointing CMake to the host install of Eigen3 because it's header-only
    # and thus this is safe to do.
    - cmake -GNinja .. -DANDROID_PLATFORM=$ANDROID_PLATFORM -DANDROID_ABI=$ABI -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DEigen3_DIR=/usr/lib/cmake/eigen3/
    - grep "^XRT_" CMakeCache.txt
    - ninja

ndk:armeabi-v7a:
  extends: .monado.ndk:build-base

ndk:arm64-v8a:
  extends: .monado.ndk:build-base

298
# Packaging
299 300 301 302 303 304 305 306
.monado.packaging.conditions:
  rules:
    # Only the default branch of the "upstream" repo.
    - if: '$CI_PROJECT_PATH == $FDO_UPSTREAM_REPO && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
      when: on_success
    # Otherwise, don't build packages.
    - when: never

307
.monado.base-job.debuild:
308 309
  extends:
    - .monado.packaging.conditions
310
  stage: package
311
  before_script:
312 313 314
    # Configure git - needed despite not actually committing here.
    - git config --global user.email "ryan.pavlik@collabora.com"
    - git config --global user.name "Monado CI"
315
  script:
316
    # Prep the source tree
317
    - git clean -dfx
318
    - git merge origin/${PACKAGE_BRANCH} --no-commit
319
    - DEBFULLNAME="Monado CI" DEBEMAIL="ryan.pavlik@collabora.com" debian/extra/prepare-commit-package.sh ${CI_COMMIT_SHA} 1~${BACKPORT_SUFFIX}~ci$(date --utc "+%Y%m%d")
320
    # Build the package
321
    - debuild -uc -us
322 323 324 325 326 327 328
    # Use dput-ng to move the package-related files into some artifacts.
    - export INCOMING=$(pwd)/incoming
    - mkdir -p $INCOMING
    - mkdir -p ~/.dput.d/profiles
    - cat .gitlab-ci/localhost.json | envsubst  > ~/.dput.d/profiles/localhost.json
    - dpkg-parsechangelog --show-field version > incoming/${DISTRO}.distro
    - dput --debug localhost ../monado_$(dpkg-parsechangelog --show-field version)_amd64.changes
329 330
  artifacts:
    paths:
331 332
      - "incoming/"
    expire_in: 2 days
333

334 335
debian:buster:package:
  extends:
336
    - .monado.variables.debian:buster
337
    - .fdo.distribution-image@debian # from ci-templates
338
    - .monado.base-job.debuild
339 340 341 342 343 344 345
  variables:
    BACKPORT_SUFFIX: bpo10
    PACKAGE_BRANCH: debian/buster-backports
    DISTRO: buster

ubuntu:focal:package:
  extends:
346
    - .monado.variables.ubuntu:focal
347
    - .fdo.distribution-image@ubuntu # from ci-templates
348
    - .monado.base-job.debuild
349 350 351 352 353
  variables:
    BACKPORT_SUFFIX: ubuntu20.04
    PACKAGE_BRANCH: ubuntu/focal
    DISTRO: focal

354 355 356 357
reprepro:package:
  stage: reprepro
  extends:
    - .monado.variables.debian:buster
358
    - .monado.packaging.conditions
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
    - .fdo.distribution-image@debian # from ci-templates
  dependencies:
    - debian:buster:package
    - ubuntu:focal:package
  before_script:
    # Convince gnupg to work properly in CI
    - mkdir -p ~/.gnupg && chmod 700 ~/.gnupg
    - touch ~/.gnupg/gpg.conf
    - echo 'use-agent' > ~/.gnupg/gpg.conf
    - echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf
    - touch ~/.gnupg/gpg-agent.conf
    - echo 'allow-loopback-pinentry' > ~/.gnupg/gpg-agent.conf
    - echo RELOADAGENT | gpg-connect-agent
    - gpg --batch --no-tty --yes --pinentry-mode loopback --passphrase ${MONADO_GPG_PASSPHRASE} --import ${MONADO_GPG_SECRET_KEY}

  script:
    # Use reprepro to create an apt repository in our artifacts
    - mkdir -p repo/conf
    # For each distro, sign the changes file and add it to the repo.
    - |
      for fn in incoming/*.distro; do
        # parse the distro name out
        export DISTRO=$(echo $fn | sed -e 's:incoming/::' -e 's:[.]distro::')
        echo "Processing $DISTRO"
        # add distro to repository config - blank line is mandatory!
        cat .gitlab-ci/distributions | envsubst >> repo/conf/distributions
        echo >> repo/conf/distributions

        echo "Signing package for $DISTRO"
        debsign -k ${MONADO_GPG_FINGERPRINT} -p "gpg --batch --no-tty --yes --pinentry-mode loopback --passphrase ${MONADO_GPG_PASSPHRASE}" incoming/monado_$(cat $fn)_amd64.changes

        echo "Adding package for $DISTRO to the repository"
        reprepro -V --ignore=wrongdistribution -b repo include ${DISTRO} incoming/monado_$(cat $fn)_amd64.changes
      done
  artifacts:
    paths:
      - "repo/"
    expire_in: 2 days

398 399 400 401
###
# Pages
###
pages:
Ryan Pavlik's avatar
Ryan Pavlik committed
402
  stage: pages
403 404
  only:
    - master
405
  dependencies:
406
    - debian:cmake
407
    - reprepro:package
408
  script:
409 410
    - mkdir -p public
    - mv build/doc/html/* public/
411
    - mv repo public/apt
412 413 414
  artifacts:
    paths:
      - public