1# This file uses the freedesktop ci-templates to build Wayland and run our 2# tests in CI. 3# 4# ci-templates uses a multi-stage build process. First, the base container 5# image is built which contains the core distribution, the toolchain, and 6# all our build dependencies. This container is aggressively cached; if a 7# container image matching $FDO_DISTRIBUTION_TAG is found in either the 8# upstream repo (wayland/weston) or the user's downstream repo, it is 9# reused for the build. This gives us predictability of build and far 10# quicker runtimes, however it means that any changes to the base container 11# must also change $FDO_DISTRIBUTION_TAG. When changing this, please use 12# the current date as well as a unique build identifier. 13# 14# After the container is either rebuilt (tag mismatch) or reused (tag 15# previously used), the build stage executes within this container. 16# 17# The final stage is used to expose documentation and coverage information, 18# including publishing documentation to the public site when built on the 19# main branch. 20# 21# Apart from the 'variables', 'include', and 'stages' top-level anchors, 22# everything not beginning with a dot ('.') is the name of a job which will 23# be executed as part of CI, unless the rules specify that it should not be 24# run. 25# 26# Variables prefixed with CI_ are generally provided by GitLab itself; 27# variables prefixed with FDO_ and templates prefixed by .fdo are provided 28# by the ci-templates. 29# 30# For more information on GitLab CI, including the YAML syntax, see: 31# https://docs.gitlab.com/ee/ci/yaml/README.html 32# 33# Note that freedesktop.org uses the 'Community Edition' of GitLab, so features 34# marked as 'premium' or 'ultimate' are not available to us. 35# 36# For more information on ci-templates, see: 37# - documentation at https://freedesktop.pages.freedesktop.org/ci-templates/ 38# - repo at https://gitlab.freedesktop.org/freedesktop/ci-templates/ 39 40# Here we use a fixed ref in order to isolate ourselves from ci-templates 41# API changes. If you need new features from ci-templates you must bump 42# this to the current SHA you require from the ci-templates repo, however 43# be aware that you may need to account for API changes when doing so. 44.templates_sha: &template_sha d5aa3941aa03c2f716595116354fb81eb8012acb # see https://docs.gitlab.com/ee/ci/yaml/#includefile 45 46include: 47 - project: 'freedesktop/ci-templates' 48 ref: *template_sha 49 file: 50 - '/templates/debian.yml' 51 - '/templates/freebsd.yml' 52 - '/templates/ci-fairy.yml' 53 54variables: 55 FDO_UPSTREAM_REPO: wayland/wayland 56 FDO_REPO_SUFFIX: "$BUILD_OS/$BUILD_ARCH" 57 58 59# Define the build stages. These are used for UI grouping as well as 60# dependencies. 61stages: 62 - "Merge request checks" 63 - "Base container" 64 - "Build and test" 65 - "Other build configurations" 66 67.ci-rules: 68 rules: 69 - when: on_success 70 71# Base variables used for anything using a Debian environment 72.os-debian: 73 variables: 74 BUILD_OS: debian 75 FDO_DISTRIBUTION_VERSION: bullseye 76 FDO_DISTRIBUTION_PACKAGES: 'build-essential pkg-config libexpat1-dev libffi-dev libxml2-dev doxygen graphviz xmlto xsltproc docbook-xsl python3-pip python3-setuptools ninja-build' 77 FDO_DISTRIBUTION_EXEC: 'pip3 install meson==0.56.0' 78 # bump this tag every time you change something which requires rebuilding the 79 # base image 80 FDO_DISTRIBUTION_TAG: "2022-08-08.0" 81 82.debian-x86_64: 83 extends: 84 - .os-debian 85 variables: 86 BUILD_ARCH: "x86-64" 87 88.debian-aarch64: 89 extends: 90 - .os-debian 91 variables: 92 BUILD_ARCH: "aarch64" 93 94.debian-armv7: 95 extends: 96 - .os-debian 97 variables: 98 BUILD_ARCH: "armv7" 99 100 101# Does not inherit .ci-rules as we only want it to run in MR context. 102check-commit: 103 extends: 104 - .fdo.ci-fairy 105 stage: "Merge request checks" 106 rules: 107 - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' 108 when: always 109 - when: never 110 script: 111 - ci-fairy check-commits --signed-off-by --junit-xml=results.xml 112 variables: 113 GIT_DEPTH: 100 114 artifacts: 115 reports: 116 junit: results.xml 117 118 119# Build our base container image, which contains the core distribution, the 120# toolchain, and all our build dependencies. This will be reused in the build 121# stage. 122x86_64-debian-container_prep: 123 extends: 124 - .ci-rules 125 - .debian-x86_64 126 - .fdo.container-build@debian 127 stage: "Base container" 128 variables: 129 GIT_STRATEGY: none 130 131aarch64-debian-container_prep: 132 extends: 133 - .ci-rules 134 - .debian-aarch64 135 - .fdo.container-build@debian 136 tags: 137 - aarch64 138 stage: "Base container" 139 variables: 140 GIT_STRATEGY: none 141 142armv7-debian-container_prep: 143 extends: 144 - .ci-rules 145 - .debian-armv7 146 - .fdo.container-build@debian 147 tags: 148 - aarch64 149 stage: "Base container" 150 variables: 151 GIT_STRATEGY: none 152 FDO_BASE_IMAGE: "arm32v7/debian:$FDO_DISTRIBUTION_VERSION" 153 154 155# Core build environment. 156.build-env: 157 variables: 158 MESON_BUILD_TYPE: "-Dbuildtype=debug -Doptimization=0 -Db_sanitize=address,undefined" 159 # See https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/154 160 ASAN_OPTIONS: "detect_odr_violation=0" 161 before_script: 162 - export BUILD_ID="wayland-$CI_JOB_NAME" 163 - export PREFIX="${CI_PROJECT_DIR}/prefix-${BUILD_ID}" 164 - export BUILDDIR="${CI_PROJECT_DIR}/build-${BUILD_ID}" 165 - mkdir "$BUILDDIR" "$PREFIX" 166 167 168# Build variants to be stacked on as required. 169.build-release: 170 stage: "Other build configurations" 171 variables: 172 MESON_BUILD_TYPE: "-Dbuildtype=release" 173 174 175# OS/architecture-specific variants 176.build-env-debian-x86_64: 177 extends: 178 - .fdo.suffixed-image@debian 179 - .debian-x86_64 180 - .build-env 181 needs: 182 - job: x86_64-debian-container_prep 183 artifacts: false 184 185.build-env-debian-aarch64: 186 extends: 187 - .fdo.suffixed-image@debian 188 - .debian-aarch64 189 - .build-env 190 variables: 191 # At least with the versions we have, the LSan runtime makes fork unusably 192 # slow on AArch64, which is bad news since the test suite decides to fork 193 # for every single subtest. For now, in order to get AArch64 builds and 194 # tests into CI, just assume that we're not going to leak any more on 195 # AArch64 than we would on ARMv7 or x86-64. 196 ASAN_OPTIONS: "detect_leaks=0,detect_odr_violation=0" 197 tags: 198 - aarch64 199 needs: 200 - job: aarch64-debian-container_prep 201 artifacts: false 202 203.build-env-debian-armv7: 204 extends: 205 - .fdo.suffixed-image@debian 206 - .debian-armv7 207 - .build-env 208 tags: 209 - aarch64 210 needs: 211 - job: armv7-debian-container_prep 212 artifacts: false 213 214 215# Full build and test. 216.do-build: 217 extends: 218 - .ci-rules 219 stage: "Build and test" 220 script: 221 - cd "$BUILDDIR" 222 - meson --prefix="$PREFIX" -Dicon_directory=/usr/share/X11/icons -Dwerror=true ${MESON_BUILD_TYPE} .. 223 - ninja -k0 -j${FDO_CI_CONCURRENT:-4} 224 - meson test --num-processes ${FDO_CI_CONCURRENT:-4} 225 - ninja clean 226 artifacts: 227 name: wayland-$CI_JOB_NAME 228 when: always 229 paths: 230 - build-*/meson-logs 231 - prefix-* 232 reports: 233 junit: build-*/meson-logs/testlog.junit.xml 234 235# Full build and test. 236.do-build-qemu: 237 extends: 238 - .ci-rules 239 stage: "Build and test" 240 script: 241 # Start the VM and copy our workspace to the VM 242 - /app/vmctl start 243 - scp -r $PWD "vm:" 244 # The `set +e is needed to ensure that we always copy the meson logs back to 245 # the workspace to see details about the failed tests. 246 - | 247 set +e 248 /app/vmctl exec "pkg info; cd $CI_PROJECT_NAME ; meson $BUILDDIR --prefix=$PREFIX $MESON_BUILD_TYPE $MESON_ARGS && ninja -C $BUILDDIR -j${FDO_CI_CONCURRENT:-4}" 249 /app/vmctl exec "meson test --print-errorlogs -C $BUILDDIR --num-processes ${FDO_CI_CONCURRENT:-4}" && touch .tests-successful 250 set -ex 251 scp -r vm:$BUILDDIR/meson-logs . 252 /app/vmctl exec "ninja -C $BUILDDIR install" 253 mkdir -p $PREFIX && scp -r vm:$PREFIX/ $PREFIX/ 254 # Finally, shut down the VM. 255 - /app/vmctl stop 256 - test -f .tests-successful || exit 1 257 artifacts: 258 name: wayland-$CI_JOB_NAME 259 when: always 260 paths: 261 - meson-logs 262 - prefix-* 263 reports: 264 junit: meson-logs/testlog.junit.xml 265 266# Full build and test. 267x86_64-debian-build: 268 extends: 269 - .build-env-debian-x86_64 270 - .do-build 271 272x86_64-release-debian-build: 273 extends: 274 - .build-env-debian-x86_64 275 - .do-build 276 - .build-release 277 278aarch64-debian-build: 279 extends: 280 - .build-env-debian-aarch64 281 - .do-build 282 283aarch64-release-debian-build: 284 extends: 285 - .build-env-debian-aarch64 286 - .do-build 287 - .build-release 288 289armv7-debian-build: 290 extends: 291 - .build-env-debian-armv7 292 - .do-build 293 294armv7-release-debian-build: 295 extends: 296 - .build-env-debian-armv7 297 - .do-build 298 - .build-release 299 300# Base variables used for anything using a FreeBSD environment 301.os-freebsd: 302 variables: 303 BUILD_OS: freebsd 304 FDO_DISTRIBUTION_VERSION: "13.1" 305 FDO_DISTRIBUTION_PACKAGES: 'libxslt meson ninja pkgconf expat libffi libepoll-shim libxml2' 306 # bump this tag every time you change something which requires rebuilding the 307 # base image 308 FDO_DISTRIBUTION_TAG: "2022-09-08.0" 309 # Don't build documentation since installing the required tools massively 310 # increases the VM image (and therefore container) size. 311 MESON_ARGS: "-Ddocumentation=false" 312 313.freebsd-x86_64: 314 extends: 315 - .os-freebsd 316 variables: 317 BUILD_ARCH: "x86_64" 318 319x86_64-freebsd-container_prep: 320 extends: 321 - .ci-rules 322 - .freebsd-x86_64 323 - .fdo.qemu-build@freebsd@x86_64 324 stage: "Base container" 325 variables: 326 GIT_STRATEGY: none 327 328.build-env-freebsd-x86_64: 329 variables: 330 # Compiling with ASan+UBSan appears to trigger an infinite loop in the 331 # compiler shipped with FreeBSD 13.0, so we only use UBSan here. 332 # Additionally, sanitizers can't be used with b_lundef on FreeBSD. 333 MESON_BUILD_TYPE: "-Dbuildtype=debug -Db_sanitize=undefined -Db_lundef=false" 334 extends: 335 - .fdo.suffixed-image@freebsd 336 - .freebsd-x86_64 337 - .build-env 338 needs: 339 - job: x86_64-freebsd-container_prep 340 artifacts: false 341 342# Full build and test. 343x86_64-freebsd-build: 344 extends: 345 - .build-env-freebsd-x86_64 346 - .do-build-qemu 347 348x86_64-release-freebsd-build: 349 extends: 350 - .build-env-freebsd-x86_64 351 - .do-build-qemu 352 - .build-release 353