|
| 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 | +include: |
| 41 | + - project: 'freedesktop/ci-templates' |
| 42 | + # Here we use a fixed ref in order to isolate ourselves from ci-templates |
| 43 | + # API changes. If you need new features from ci-templates you must bump |
| 44 | + # this to the current SHA you require from the ci-templates repo, however |
| 45 | + # be aware that you may need to account for API changes when doing so. |
| 46 | + ref: b791bd48996e3ced9ca13f1c5ee82be8540b8adb |
| 47 | + file: |
| 48 | + - '/templates/debian.yml' |
| 49 | + - '/templates/freebsd.yml' |
| 50 | + - '/templates/ci-fairy.yml' |
| 51 | + |
| 52 | +variables: |
| 53 | + FDO_UPSTREAM_REPO: wayland/wayland |
| 54 | + FDO_REPO_SUFFIX: "$BUILD_OS/$BUILD_ARCH" |
| 55 | + |
| 56 | + |
| 57 | +# Define the build stages. These are used for UI grouping as well as |
| 58 | +# dependencies. |
| 59 | +stages: |
| 60 | + - "Merge request checks" |
| 61 | + - "Base container" |
| 62 | + - "Build and test" |
| 63 | + - "Other build configurations" |
| 64 | + |
| 65 | +.ci-rules: |
| 66 | + rules: |
| 67 | + - when: on_success |
| 68 | + |
| 69 | +# Base variables used for anything using a Debian environment |
| 70 | +.os-debian: |
| 71 | + variables: |
| 72 | + BUILD_OS: debian |
| 73 | + FDO_DISTRIBUTION_VERSION: bookworm |
| 74 | + 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' |
| 75 | + FDO_DISTRIBUTION_EXEC: 'pip3 install --break-system-packages meson~=0.57.2' |
| 76 | + # bump this tag every time you change something which requires rebuilding the |
| 77 | + # base image |
| 78 | + FDO_DISTRIBUTION_TAG: "2024-03-28.2" |
| 79 | + |
| 80 | +.debian-x86_64: |
| 81 | + extends: |
| 82 | + - .os-debian |
| 83 | + variables: |
| 84 | + BUILD_ARCH: "x86-64" |
| 85 | + |
| 86 | +.debian-aarch64: |
| 87 | + extends: |
| 88 | + - .os-debian |
| 89 | + variables: |
| 90 | + BUILD_ARCH: "aarch64" |
| 91 | + |
| 92 | +.debian-armv7: |
| 93 | + extends: |
| 94 | + - .os-debian |
| 95 | + variables: |
| 96 | + BUILD_ARCH: "armv7" |
| 97 | + |
| 98 | + |
| 99 | +# Does not inherit .ci-rules as we only want it to run in MR context. |
| 100 | +check-commit: |
| 101 | + extends: |
| 102 | + - .fdo.ci-fairy |
| 103 | + stage: "Merge request checks" |
| 104 | + rules: |
| 105 | + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' |
| 106 | + when: always |
| 107 | + - when: never |
| 108 | + script: |
| 109 | + - ci-fairy check-commits --signed-off-by --junit-xml=results.xml |
| 110 | + variables: |
| 111 | + GIT_DEPTH: 100 |
| 112 | + artifacts: |
| 113 | + reports: |
| 114 | + junit: results.xml |
| 115 | + |
| 116 | + |
| 117 | +# Build our base container image, which contains the core distribution, the |
| 118 | +# toolchain, and all our build dependencies. This will be reused in the build |
| 119 | +# stage. |
| 120 | +x86_64-debian-container_prep: |
| 121 | + extends: |
| 122 | + - .ci-rules |
| 123 | + - .debian-x86_64 |
| 124 | + - .fdo.container-build@debian |
| 125 | + stage: "Base container" |
| 126 | + variables: |
| 127 | + GIT_STRATEGY: none |
| 128 | + |
| 129 | +aarch64-debian-container_prep: |
| 130 | + extends: |
| 131 | + - .ci-rules |
| 132 | + - .debian-aarch64 |
| 133 | + - .fdo.container-build@debian |
| 134 | + tags: |
| 135 | + - aarch64 |
| 136 | + stage: "Base container" |
| 137 | + variables: |
| 138 | + GIT_STRATEGY: none |
| 139 | + |
| 140 | +armv7-debian-container_prep: |
| 141 | + extends: |
| 142 | + - .ci-rules |
| 143 | + - .debian-armv7 |
| 144 | + - .fdo.container-build@debian |
| 145 | + tags: |
| 146 | + - aarch64 |
| 147 | + stage: "Base container" |
| 148 | + variables: |
| 149 | + GIT_STRATEGY: none |
| 150 | + FDO_BASE_IMAGE: "arm32v7/debian:$FDO_DISTRIBUTION_VERSION" |
| 151 | + |
| 152 | + |
| 153 | +# Core build environment. |
| 154 | +.build-env: |
| 155 | + variables: |
| 156 | + MESON_BUILD_TYPE: "-Dbuildtype=debug -Doptimization=0 -Db_sanitize=address,undefined" |
| 157 | + # See https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/154 |
| 158 | + ASAN_OPTIONS: "detect_odr_violation=0" |
| 159 | + before_script: |
| 160 | + - export BUILD_ID="wayland-$CI_JOB_NAME" |
| 161 | + - export PREFIX="${CI_PROJECT_DIR}/prefix-${BUILD_ID}" |
| 162 | + - export BUILDDIR="${CI_PROJECT_DIR}/build-${BUILD_ID}" |
| 163 | + - mkdir "$BUILDDIR" "$PREFIX" |
| 164 | + |
| 165 | + |
| 166 | +# Build variants to be stacked on as required. |
| 167 | +.build-release: |
| 168 | + stage: "Other build configurations" |
| 169 | + variables: |
| 170 | + MESON_BUILD_TYPE: "-Dbuildtype=release" |
| 171 | + |
| 172 | + |
| 173 | +# OS/architecture-specific variants |
| 174 | +.build-env-debian-x86_64: |
| 175 | + extends: |
| 176 | + - .fdo.suffixed-image@debian |
| 177 | + - .debian-x86_64 |
| 178 | + - .build-env |
| 179 | + needs: |
| 180 | + - job: x86_64-debian-container_prep |
| 181 | + artifacts: false |
| 182 | + |
| 183 | +.build-env-debian-aarch64: |
| 184 | + extends: |
| 185 | + - .fdo.suffixed-image@debian |
| 186 | + - .debian-aarch64 |
| 187 | + - .build-env |
| 188 | + variables: |
| 189 | + # At least with the versions we have, the LSan runtime makes fork unusably |
| 190 | + # slow on AArch64, which is bad news since the test suite decides to fork |
| 191 | + # for every single subtest. For now, in order to get AArch64 builds and |
| 192 | + # tests into CI, just assume that we're not going to leak any more on |
| 193 | + # AArch64 than we would on ARMv7 or x86-64. |
| 194 | + ASAN_OPTIONS: "detect_leaks=0,detect_odr_violation=0" |
| 195 | + tags: |
| 196 | + - aarch64 |
| 197 | + needs: |
| 198 | + - job: aarch64-debian-container_prep |
| 199 | + artifacts: false |
| 200 | + |
| 201 | +.build-env-debian-armv7: |
| 202 | + extends: |
| 203 | + - .fdo.suffixed-image@debian |
| 204 | + - .debian-armv7 |
| 205 | + - .build-env |
| 206 | + tags: |
| 207 | + - aarch64 |
| 208 | + needs: |
| 209 | + - job: armv7-debian-container_prep |
| 210 | + artifacts: false |
| 211 | + |
| 212 | + |
| 213 | +# Full build and test. |
| 214 | +.do-build: |
| 215 | + extends: |
| 216 | + - .ci-rules |
| 217 | + stage: "Build and test" |
| 218 | + script: |
| 219 | + - cd "$BUILDDIR" |
| 220 | + - meson --prefix="$PREFIX" -Dicon_directory=/usr/share/X11/icons --fatal-meson-warnings -Dwerror=true ${MESON_BUILD_TYPE} .. |
| 221 | + - ninja -k0 -j${FDO_CI_CONCURRENT:-4} |
| 222 | + - meson test --num-processes ${FDO_CI_CONCURRENT:-4} |
| 223 | + - ninja clean |
| 224 | + artifacts: |
| 225 | + name: wayland-$CI_JOB_NAME |
| 226 | + when: always |
| 227 | + paths: |
| 228 | + - build-*/meson-logs |
| 229 | + - prefix-* |
| 230 | + reports: |
| 231 | + junit: build-*/meson-logs/testlog.junit.xml |
| 232 | + |
| 233 | +# Full build and test. |
| 234 | +.do-build-qemu: |
| 235 | + extends: |
| 236 | + - .ci-rules |
| 237 | + stage: "Build and test" |
| 238 | + script: |
| 239 | + # Start the VM and copy our workspace to the VM |
| 240 | + - /app/vmctl start |
| 241 | + - scp -r $PWD "vm:" |
| 242 | + # The `set +e is needed to ensure that we always copy the meson logs back to |
| 243 | + # the workspace to see details about the failed tests. |
| 244 | + - | |
| 245 | + set +e |
| 246 | + /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}" |
| 247 | + /app/vmctl exec "meson test --print-errorlogs -C $BUILDDIR --num-processes ${FDO_CI_CONCURRENT:-4}" && touch .tests-successful |
| 248 | + set -ex |
| 249 | + scp -r vm:$BUILDDIR/meson-logs . |
| 250 | + /app/vmctl exec "ninja -C $BUILDDIR install" |
| 251 | + mkdir -p $PREFIX && scp -r vm:$PREFIX/ $PREFIX/ |
| 252 | + # Finally, shut down the VM. |
| 253 | + - /app/vmctl stop |
| 254 | + - test -f .tests-successful || exit 1 |
| 255 | + artifacts: |
| 256 | + name: wayland-$CI_JOB_NAME |
| 257 | + when: always |
| 258 | + paths: |
| 259 | + - meson-logs |
| 260 | + - prefix-* |
| 261 | + reports: |
| 262 | + junit: meson-logs/testlog.junit.xml |
| 263 | + |
| 264 | +# Full build and test. |
| 265 | +x86_64-debian-build: |
| 266 | + extends: |
| 267 | + - .build-env-debian-x86_64 |
| 268 | + - .do-build |
| 269 | + |
| 270 | +x86_64-release-debian-build: |
| 271 | + extends: |
| 272 | + - .build-env-debian-x86_64 |
| 273 | + - .do-build |
| 274 | + - .build-release |
| 275 | + |
| 276 | +aarch64-debian-build: |
| 277 | + extends: |
| 278 | + - .build-env-debian-aarch64 |
| 279 | + - .do-build |
| 280 | + |
| 281 | +aarch64-release-debian-build: |
| 282 | + extends: |
| 283 | + - .build-env-debian-aarch64 |
| 284 | + - .do-build |
| 285 | + - .build-release |
| 286 | + |
| 287 | +armv7-debian-build: |
| 288 | + extends: |
| 289 | + - .build-env-debian-armv7 |
| 290 | + - .do-build |
| 291 | + |
| 292 | +armv7-release-debian-build: |
| 293 | + extends: |
| 294 | + - .build-env-debian-armv7 |
| 295 | + - .do-build |
| 296 | + - .build-release |
| 297 | + |
| 298 | +# Base variables used for anything using a FreeBSD environment |
| 299 | +.os-freebsd: |
| 300 | + variables: |
| 301 | + BUILD_OS: freebsd |
| 302 | + FDO_DISTRIBUTION_VERSION: "13.2" |
| 303 | + FDO_DISTRIBUTION_PACKAGES: 'libxslt meson ninja pkgconf expat libffi libepoll-shim libxml2' |
| 304 | + # bump this tag every time you change something which requires rebuilding the |
| 305 | + # base image |
| 306 | + FDO_DISTRIBUTION_TAG: "2023-08-02.0" |
| 307 | + # Don't build documentation since installing the required tools massively |
| 308 | + # increases the VM image (and therefore container) size. |
| 309 | + MESON_ARGS: "--fatal-meson-warnings -Dwerror=true -Ddocumentation=false" |
| 310 | + |
| 311 | +.freebsd-x86_64: |
| 312 | + extends: |
| 313 | + - .os-freebsd |
| 314 | + variables: |
| 315 | + BUILD_ARCH: "x86_64" |
| 316 | + |
| 317 | +x86_64-freebsd-container_prep: |
| 318 | + extends: |
| 319 | + - .ci-rules |
| 320 | + - .freebsd-x86_64 |
| 321 | + - .fdo.qemu-build@freebsd@x86_64 |
| 322 | + stage: "Base container" |
| 323 | + variables: |
| 324 | + GIT_STRATEGY: none |
| 325 | + |
| 326 | +.build-env-freebsd-x86_64: |
| 327 | + variables: |
| 328 | + # Compiling with ASan+UBSan appears to trigger an infinite loop in the |
| 329 | + # compiler shipped with FreeBSD 13.0, so we only use UBSan here. |
| 330 | + # Additionally, sanitizers can't be used with b_lundef on FreeBSD. |
| 331 | + MESON_BUILD_TYPE: "-Dbuildtype=debug -Db_sanitize=undefined -Db_lundef=false" |
| 332 | + extends: |
| 333 | + - .fdo.suffixed-image@freebsd |
| 334 | + - .freebsd-x86_64 |
| 335 | + - .build-env |
| 336 | + needs: |
| 337 | + - job: x86_64-freebsd-container_prep |
| 338 | + artifacts: false |
| 339 | + |
| 340 | +# Full build and test. |
| 341 | +x86_64-freebsd-build: |
| 342 | + extends: |
| 343 | + - .build-env-freebsd-x86_64 |
| 344 | + - .do-build-qemu |
| 345 | + |
| 346 | +x86_64-release-freebsd-build: |
| 347 | + extends: |
| 348 | + - .build-env-freebsd-x86_64 |
| 349 | + - .do-build-qemu |
| 350 | + - .build-release |
0 commit comments