ci.template 24.2 KB
Newer Older
1
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
2 3 4 5 6 7 8 9 10

{# You're looking at the template here, so you can ignore the below
   warning. This is the right file to edit #}
########################################
#                                      #
# THIS FILE IS GENERATED, DO NOT EDIT  #
#                                      #
########################################

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#
# This is a bit complicated for two reasons:
# - we really want to run dnf/apt/... only once, updating on the test runner for
#   each job takes forever. So we create a container image for each distribution
#   tested, then run the tests on this container image.
#
#   Creating a container image is time-consuming, so we only do so for pushes to
#   libinput directly (not merge requests) and if the current image is 'old'.
#
# - GitLab only allows one script: set per job but we have a bunch of commands
#   we need to re-run for each build (meson && ninja && etc). YAML cannot merge
#   arrays templates so we're screwed.
#
#   So instead we use a default_build template and override everything with
#   variables. The only two variables that matter:
#     MESON_ARGS=-Denable-something=true
#     NINJA_ARGS=dist ... to run 'ninja -C builddir dist'
#   Note that you cannot use scripts: in any target if you expect default_build
#   to work.
#
#
# All jobs must follow the naming scheme of
# <distribution>:<version>@activity:
#  e.g. fedora:31@build-default

36
.templates_sha: &template_sha 395535ce90eb48e260c0dff12c35d9237e22c539 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
37 38

include:
39
  {% for distro in distributions|sort(attribute="name") %}
40
  {% if not distro.does_not_have_ci_templates %}
41
  # {{ distro.name.capitalize() }} container builder template
42
  - project: 'freedesktop/ci-templates'
43
    ref: *template_sha
44 45
    file: '/templates/{{distro.name}}.yml'
  {% endif %}
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
  {% endfor %}

stages:
  - prep             # prep work like rebuilding the container images if there is a change
  - build            # for actually building and testing things in a container
  - VM               # for running the test suite in a VM
  - valgrind         # for running the test suite under valgrind in a VM
  - distro           # distribs test
  - deploy           # trigger wayland's website generation
  - container_clean  # clean up unused container images

variables:
  ###############################################################################
  # This is the list of packages required to build libinput with the default    #
  # configuration.                                                              #
  #                                                                             #
  # Run dnf install/apt-get install/.. with the list of packages for your       #
  # distribution                                                                #
  #                                                                             #
  # See the documentation here:                                                 #
  # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html  #
  ###############################################################################
68
  FEDORA_PACKAGES:    'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx_rtd_theme python3-pytest-xdist libwacom-devel cairo-devel   gtk3-devel   glib2-devel    mtdev-devel diffutils'
69
  FEDORA_QEMU_RPMS:   'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx_rtd_theme python3-pytest-xdist libwacom-devel cairo-devel   gtk3-devel   glib2-devel    mtdev-devel diffutils valgrind'
70 71
  UBUNTU_PACKAGES:    'git gcc g++     pkg-config         meson check       libudev-dev   libevdev-dev   doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme python3-pytest-xdist libwacom-dev   libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev'
  ARCH_PACKAGES:      'git gcc         pkgconfig          meson check       libsystemd    libevdev       doxygen graphviz python-sphinx  python-recommonmark  python-sphinx_rtd_theme  python-pytest-xdist  libwacom                     gtk3                        mtdev      diffutils'
72 73
  FREEBSD_BUILD_PKGS: 'meson'
  FREEBSD_PKGS:       'libepoll-shim                                        libudev-devd  libevdev                                                                                     libwacom                     gtk3                        libmtdev   '
74
  ALPINE_PACKAGES:    'git gcc build-base pkgconfig       meson check-dev   eudev-dev     libevdev-dev                                                                                 libwacom-dev   cairo-dev     gtk+3.0-dev  mtdev-dev bash'
75 76 77 78 79 80
  ############################ end of package lists #############################

  # these tags should be updated each time the list of packages is updated
  # changing these will force rebuilding the associated image
  # Note: these tags have no meaning and are not tied to a particular
  # libinput version
81 82 83 84 85 86 87 88
{% for distro in distributions %}
  {{"%-13s"| format(distro.name.upper() + '_TAG:')}}'{{distro.tag}}'
{% endfor %}
{% for distro in distributions %}
{% if distro.want_qemu %}
  QEMU_TAG:    'qemu-vm-{{distro.tag}}'
{% endif %}
{% endfor %}
89 90 91 92

  UBUNTU_EXEC: "bash .gitlab-ci/ubuntu_install.sh $UBUNTU_CUSTOM_DEBS"

  FREEBSD_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/freebsd/11.2:$FREEBSD_TAG
93
  FDO_UPSTREAM_REPO: libinput/libinput
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136

  MESON_BUILDDIR: "build dir"
  NINJA_ARGS: ''
  MESON_ARGS: ''
  MESON_TEST_ARGS: '--no-suite=hardware'

  # udev isn't available/working properly in the containers
  UDEV_NOT_AVAILABLE: 1
  GIT_DEPTH: 1

.policy:
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
  # cancel run when a newer version is pushed to the branch
  interruptible: true

.default_artifacts:
  artifacts:
    name: "meson-logs-$CI_JOB_NAME"
    when: always
    expire_in: 1 week
    paths:
      - $MESON_BUILDDIR/meson-logs
    reports:
      junit: $MESON_BUILDDIR/junit-*.xml

#################################################################
#                                                               #
#                          prep stage                           #
#                                                               #
#################################################################

# Re-generate the CI script and make sure it's the one currently checked in
# If this job fails, re-generate the gitlab-ci.yml script, see
# $SRCDIR/.gitlab-ci/generate-gitlab-ci.py
#
check-ci-script:
  image: golang:alpine
  stage: prep
  before_script:
137
    - apk add python3 py-pip git
138
    - pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
139
  script:
140
    - ci-fairy generate-template
141 142 143 144 145 146 147 148 149 150 151 152
    - git diff --exit-code && exit 0 || true
    - echo "Committed gitlab-ci.yml differs from generated gitlab-ci.yml. Please verify"
    - exit 1

#
# Verify that commit messages are as expected, signed-off, etc.
#

check-commit:
  image: golang:alpine
  stage: prep
  before_script:
153
    - apk add python3 py-pip git
154
    - pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
155
  script:
156
    - ci-fairy check-commits --signed-off-by --junit-xml=results.xml
157 158 159 160 161 162 163 164
  except:
    - master@libinput/libinput
  variables:
    GIT_DEPTH: 100
  artifacts:
    reports:
      junit: results.xml

165 166 167 168 169 170
#
# Verify that the merge request has the allow-collaboration checkbox ticked
#

check-merge-request:
  image: golang:alpine
171
  stage: deploy
172 173 174 175 176 177 178 179 180 181 182
  before_script:
    - apk add python3 py-pip git
    - pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
  script:
    - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
  artifacts:
    when: on_failure
    reports:
      junit: results.xml
  allow_failure: true

183
#
184 185
# Note: images are rebuilt weekly with a scheduled pipeline with FDO_FORCE_REBUILD set
#
186
#
187 188 189 190
{# qemu builds are only done for the latest version of any distribution #}
{% for distro in distributions if distro.want_qemu %}
{% set version = "{}".format(distro.versions|last()) %}
{{distro.name}}:{{version}}@qemu-prep:
191
  extends:
192
    - .fdo.qemu-build@{{distro.name}}
193 194 195 196 197 198
    - .policy
  stage: prep
  tags:
    - kvm
  variables:
    GIT_STRATEGY: none
199
    FDO_DISTRIBUTION_VERSION: {{version}}
200
    FDO_DISTRIBUTION_TAG: $QEMU_TAG
201
    FDO_DISTRIBUTION_PACKAGES: ${{distro.name.upper()}}_QEMU_RPMS
202
  allow_failure: true
203
{% endfor %}
204 205

{% for distro in distributions %}
206 207
{% for version in distro.versions %}
{{distro.name}}:{{version}}@container-prep:
208
  extends:
209
    - .fdo.container-build@{{distro.name}}
210 211 212 213
    - .policy
  stage: prep
  variables:
    GIT_STRATEGY: none
214
    FDO_DISTRIBUTION_VERSION: '{{version}}'
215 216 217 218 219
    FDO_DISTRIBUTION_PACKAGES: ${{distro.name.upper()}}_PACKAGES
    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
 {% if version == 'ubuntu'%}
    FDO_DISTRIBUTION_EXEC: $UBUNTU_EXEC
 {% endif %}
220 221

{% endfor %}
222
{% endfor %}
223

224 225 226 227

# Note that we want to use the latest buildah image, and for that
# we use one of the .fdo.container-build@distribution by replacing the
# `script`.
228 229 230
.freebsd@container-prep:
  extends:
    - .policy
231
    - .fdo.container-build@fedora
232 233
  stage: prep
  script:
234 235 236 237 238 239
    # log in to the registry
    - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY

    # get the full container image name
    - export IMAGE=freebsd/$FREEBSD_VERSION:$FREEBSD_TAG

240
    - if [[ x"$FDO_FORCE_REBUILD" != x ]] ; then touch .rebuild; fi
241 242

    # pull the latest upstream image if it exists
243
    - test -e .rebuild || skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
244 245 246 247
                                 docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$IMAGE
                                 docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;

    # check if our image is already in the current registry
248
    - test -e .rebuild || skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
249

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
    - export BUILDAH_RUN="buildah run --isolation chroot"
    - export BUILDAH_COMMIT="buildah commit --format docker"
    - buildcntr=$(buildah from --quiet  myfreeweb/freebsd-cross:latest)
    - $BUILDAH_RUN $buildcntr apk add --no-cache $FREEBSD_BUILD_PKGS
    - $BUILDAH_RUN $buildcntr pkg -r /freebsd update -f
    - $BUILDAH_RUN $buildcntr pkg -r /freebsd install -y $FREEBSD_PKGS
    - buildah config --workingdir /app $buildcntr
    # tag the current container
    - $BUILDAH_COMMIT $buildcntr $FREEBSD_CONTAINER_IMAGE
    # clean up the working container
    - buildah rm $buildcntr

    # push the container image to the libinput registry
    - podman push --quiet $FREEBSD_CONTAINER_IMAGE
    - skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
        docker://$FREEBSD_CONTAINER_IMAGE
        docker://$CI_REGISTRY_IMAGE/freebsd/$FREEBSD_VERSION:$CI_JOB_ID

freebsd:11.2@container-prep:
  extends:
    - .freebsd@container-prep
  variables:
    GIT_STRATEGY: none
    FREEBSD_VERSION: "11.2"


#################################################################
#                                                               #
#                   container clean stage                       #
#                 run during the clean stage                    #
#                                                               #
#################################################################

#
# This stage will look for the container images we currently have in
# the registry and will remove any that are not tagged with the provided
# $container_image:$tag
#
.container-clean:
289
  stage: container_clean
290 291
  extends:
    - .policy
292 293
  image: golang:alpine
  before_script:
294
    - apk add python3 py-pip git
295
    - pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
296
  script:
297 298 299 300 301 302 303 304
    # Go to your Profile, Settings, Access Tokens
    # Create a personal token with 'api' scope, copy the value.
    # Go to CI/CD, Schedules, schedule a new monthly job (or edit the existing one)
    # Define a variable of type File named AUTHFILE. Content is that token
    # value.
    - ci-fairy -v --authfile $AUTHFILE delete-image
            --repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
            --exclude-tag $FDO_DISTRIBUTION_TAG
305 306 307 308 309 310
  dependencies: []
  allow_failure: true
  only:
    - schedules

{% for distro in distributions %}
311 312
{% for version in distro.versions %}
{{distro.name}}:{{version}}@container-clean:
313 314 315 316
  extends:
    - .container-clean
  variables:
    GIT_STRATEGY: none
317
    {{distro.name.upper()}}_VERSION: '{{version}}'
318
    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/{{distro.name}}/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
319
    FDO_DISTRIBUTION_VERSION: '{{version}}'
320
    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
321 322

{% endfor %}
323
{% endfor %}
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362

freebsd:11.2@container-clean:
  extends:
    - .container-clean
  variables:
    GIT_STRATEGY: none
    CURRENT_CONTAINER_IMAGE: $FREEBSD_CONTAINER_IMAGE

#################################################################
#                                                               #
#                       build stage                             #
#                                                               #
#################################################################

.build@template:
  extends:
    - .policy
    - .default_artifacts
  stage: build
  script:
    - .gitlab-ci/meson-build.sh
  dependencies: []

#
# Fedora
#

.check_tainted: &check_tainted |
  # make sure the kernel is not tainted
  if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
  then
    echo tainted kernel ;
    exit 1 ;
  fi

# Run in a test suite. Special variables:
# - SUITES: the meson test suites to run, or
# - SUITE_NAMES: all elements will be expanded to libinput-test-suite-$value
# Set one or the other, not both.
363
.test-suite-vm:
364 365
  extends:
    - .policy
366
    - .fdo.distribution-image@fedora
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
  stage: VM
  tags:
    - kvm
  variables:
    MESON_BUILDDIR: build_dir
    # remove the global --no-suite=hardware
    MESON_TEST_ARGS: ''
  before_script:
    - if ! [[ -z $SUITE_NAMES ]]; then SUITES=$(echo $SUITE_NAMES | sed 's/\([^ ]*\)/libinput-test-suite-\1/g'); fi
    - echo "Testing $SUITES"
  script:
    # start our vm, no args required
    - /app/start_vm.sh || (echo "Error - Failed to start the VM." && exit 1)

    - *check_tainted

    - "scp -P 5555 -r $PWD localhost:"
    - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
    - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
386
    - echo "MESON_ARGS=\"$MESON_ARGS\"" >> sshenv
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
    - echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
    - echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS $SUITES\"" >> sshenv
    - echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
    - "scp -P 5555 sshenv localhost:~/$CI_PROJECT_NAME/.meson_environment"
    - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
    # no matter the results of the tests, we want to fetch the logs
    - scp -P 5555 -r localhost:$CI_PROJECT_NAME/$MESON_BUILDDIR .

    - *check_tainted

    - ssh localhost -p 5555 halt || true
    - sleep 2
    - pkill qemu || true

    - if [[ ! -e .success ]] ;
      then
        exit 1 ;
      fi
  artifacts:
    name: "qemu-meson-logs-$CI_JOB_NAME"
    when: always
    expire_in: 1 week
    paths:
      - $MESON_BUILDDIR/meson-logs
      - console.out
    reports:
      junit: $MESON_BUILDDIR/junit-*.xml

  allow_failure: true
  retry:
    max: 2
    when: script_failure
419 420


421 422 423 424
{# qemu tests are only done for the latest version of any distribution #}
{% for distro in distributions if distro.want_qemu %}
{% set version = "{}".format(distro.versions|last()) %}
.{{distro.name}}:{{version}}@test-suite-vm:
425 426
  extends:
    - .test-suite-vm
427
  variables:
428
    FDO_DISTRIBUTION_VERSION: {{version}}
429
    FDO_DISTRIBUTION_TAG: $QEMU_TAG
430
  needs:
431
    - "{{distro.name}}:{{version}}@qemu-prep"
432

433

434
{% for suite in test_suites %}
435
vm-{{suite.name}}:
436
  extends:
437
    - .{{distro.name}}:{{version}}@test-suite-vm
438
  variables:
439
    SUITE_NAMES: '{{suite.suites}}'
440

441
vm-{{suite.name}}-no-libwacom:
442
  extends:
443
    - vm-{{suite.name}}
444 445 446
  variables:
    MESON_ARGS: '-Dlibwacom=false'

447
{% endfor %}
448

449
{% for suite in test_suites %}
450
vm-valgrind-{{suite.name}}:
451 452
  stage: valgrind
  extends:
453
    - vm-{{suite.name}}
454 455 456
  variables:
    MESON_TEST_ARGS: '--setup=valgrind'

457
{% endfor %}
458
{% endfor %}{# for if distro.want_qemu #}
459

460 461 462
{% for distro in distributions if distro.use_for_custom_build_tests %}
{% set version = "{}".format(distro.versions|last()) %}
.{{distro.name}}-build@template:
463
  extends:
464
    - .fdo.distribution-image@fedora
465
    - .build@template
466
  variables:
467 468
    FDO_DISTRIBUTION_VERSION: '{{version}}'
    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
469
  needs:
470
    - "{{distro.name}}:{{version}}@container-prep"
471

472
default-build-release@{{distro.name}}:{{version}}:
473 474
  stage: distro
  extends:
475
    - .{{distro.name}}-build@template
476 477 478 479
  variables:
    MESON_ARGS: "-Dbuildtype=release"
    CFLAGS: "-Werror"

480
scan-build@{{distro.name}}:{{version}}:
481
  extends:
482
    - .{{distro.name}}-build@template
483 484
  variables:
    NINJA_ARGS: scan-build
485
    MESON_TEST_ARGS: ''
486 487 488 489 490 491 492 493 494 495 496 497
  before_script:
    - dnf install -y clang-analyzer findutils
  after_script:
    - test ! -d "$MESON_BUILDDIR"/meson-logs/scanbuild && exit 0
    - test $(find "$MESON_BUILDDIR"/meson-logs/scanbuild -maxdepth 0 ! -empty -exec echo "not empty" \; | wc -l) -eq 0 && exit 0
    - echo "Check scan-build results"
    - /bin/false

# Below jobs are build option combinations. We only
# run them on one image, they shouldn't fail on one distro
# when they succeed on another.

498
build-no-libwacom@{{distro.name}}:{{version}}:
499
  extends:
500
    - .{{distro.name}}-build@template
501 502 503
  variables:
    MESON_ARGS: "-Dlibwacom=false"

504
build-no-libwacom-nodeps@{{distro.name}}:{{version}}:
505
  extends:
506
    - .{{distro.name}}-build@template
507 508 509 510 511
  variables:
    MESON_ARGS: "-Dlibwacom=false"
  before_script:
    - dnf remove -y libwacom libwacom-devel

512
build-no-docs@{{distro.name}}:{{version}}:
513
  extends:
514
    - .{{distro.name}}-build@template
515 516 517
  variables:
    MESON_ARGS: "-Ddocumentation=false"

518
build-no-docs-nodeps@{{distro.name}}:{{version}}:
519
  extends:
520
    - .{{distro.name}}-build@template
521 522 523 524 525
  variables:
    MESON_ARGS: "-Ddocumentation=false"
  before_script:
    - dnf remove -y doxygen graphviz

526
build-no-debuggui@{{distro.name}}:{{version}}:
527
  extends:
528
    - .{{distro.name}}-build@template
529 530 531
  variables:
    MESON_ARGS: "-Ddebug-gui=false"

532
build-no-debuggui-nodeps@{{distro.name}}:{{version}}:
533
  extends:
534
    - .{{distro.name}}-build@template
535 536 537 538 539
  variables:
    MESON_ARGS: "-Ddebug-gui=false"
  before_script:
    - dnf remove -y gtk3-devel

540
build-no-tests@{{distro.name}}:{{version}}:
541
  extends:
542
    - .{{distro.name}}-build@template
543 544 545
  variables:
    MESON_ARGS: "-Dtests=false"

546
build-no-tests-nodeps@{{distro.name}}:{{version}}:
547
  extends:
548
    - .{{distro.name}}-build@template
549 550 551 552 553
  variables:
    MESON_ARGS: "-Dtests=false"
  before_script:
    - dnf remove -y check-devel

554
valgrind@{{distro.name}}:{{version}}:
555
  extends:
556
    - .{{distro.name}}-build@template
557 558 559 560 561 562 563
  variables:
    MESON_TEST_ARGS: '--suite=valgrind --no-suite=hardware --setup=valgrind'
  before_script:
    - dnf install -y valgrind

# Python checks, only run on Fedora

564
usr-bin-env-python@{{distro.name}}:{{version}}:
565
  extends:
566
    - .{{distro.name}}-build@template
567 568 569 570 571 572 573
  script:
    - |
      if git grep -l '^#!/usr/bin/python'; then
        echo "Use '/usr/bin/env python3' in the above files";
        /bin/false
      fi

574
flake8@{{distro.name}}:{{version}}:
575
  extends:
576
    - .{{distro.name}}-build@template
577 578 579 580 581
  before_script:
    - dnf install -y python3-flake8
  script:
    - flake8-3 --ignore=W501,E501,W504 $(git grep -l '^#!/usr/bin/env python3')

582
{% endfor %}
Peter Hutterer's avatar
Peter Hutterer committed
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605

#
# coverity run
#
# This requires the COVERITY_SCAN_TOKEN. Log into scan.coverity.com and get
# the token from the respective project settings page.
# Schedule a pipeline and set a variable COVERITY_SCAN_TOKEN with the token value.
# https://gitlab.freedesktop.org/$CI_PROJECT_PATH/-/pipeline_schedules
# Email from coverity will be sent to the GITLAB_USER_EMAIL that scheduled the
# job.
#
# Coverity ratelimits submissions and the coverity tools download is about
# 700M, do not run this too often.
#
coverity:
  extends:
    - .fdo.distribution-image@fedora
    - .policy
  stage: build
  variables:
    # coverity doesn't work on Fedora 32
    FDO_DISTRIBUTION_VERSION: '31'
    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
606 607
    # so git-describe works, or should work
    GIT_DEPTH: 200
Peter Hutterer's avatar
Peter Hutterer committed
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
  only:
    variables:
      - $COVERITY_SCAN_TOKEN
  script:
    - curl https://scan.coverity.com/download/linux64
        -o /tmp/cov-analysis-linux64.tgz
        --form project=$CI_PROJECT_NAME
        --form token=$COVERITY_SCAN_TOKEN
    - tar xfz /tmp/cov-analysis-linux64.tgz
    # coverity has special build options in meson, make sure we enable those
    - meson coverity-build -Ddocumentation=false -Dcoverity=true
    - cov-analysis-linux64-*/bin/cov-build --dir cov-int  ninja -C coverity-build
    - tar cfz cov-int.tar.gz cov-int
    - curl https://scan.coverity.com/builds?project=$CI_PROJECT_NAME
        --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
        --form file=@cov-int.tar.gz --form version="$(git describe --tags)"
        --form description="$(git describe --tags) / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
625 626 627 628 629 630
  artifacts:
    name: "coverity-submit-data"
    when: always
    expire_in: 1 week
    paths:
      - cov-int.tar.gz
Peter Hutterer's avatar
Peter Hutterer committed
631 632 633
  needs:
    - "fedora:31@container-prep"

634 635 636 637 638
#################################################################
#                                                               #
#                        distro stage                           #
#                                                               #
#################################################################
639

640
{% for distro in distributions %}
641 642
{% for version in distro.versions %}
{{distro.name}}:{{version}}@default-build:
643 644 645
  stage: distro
  extends:
    - .build@template
646
    - .fdo.distribution-image@{{distro.name}}
647
  variables:
648
    FDO_DISTRIBUTION_VERSION: '{{version}}'
649
    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
650 651 652 653 654 655
    {# Where we have extra_variables defined, add them to the list #}
    {% if distro.build is defined and distro.build.extra_variables is defined %}
    {% for var in distro.build.extra_variables %}
    {{var}}
    {% endfor %}
    {% endif %}
656 657
  needs:
    - "{{distro.name}}:{{version}}@container-prep"
658 659


660
{% endfor %}
661
{% endfor %}
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678

#
# FreeBSD
#
.freebsd@template:
  stage: distro
  extends:
    - .build@template
  image: $FREEBSD_CONTAINER_IMAGE
  variables:
    MESON_ARGS: '--cross-file freebsd -Ddocumentation=false -Dtests=false -Depoll-dir=/freebsd/usr/local/'
    # Can't run FreeBSD tests on Linux machine, so MESON_TEST_ARGS shouldn't be "test"
    MESON_TEST_ARGS: ''

freebsd:11.2@default-build:
  extends:
    - .freebsd@template
679 680
  needs:
    - "freebsd:11.2@container-prep"
681 682 683 684 685

#
# deploy
#

686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
build rpm:
  extends:
    - .fdo.distribution-image@fedora
    - .policy
  stage: deploy
  variables:
    FDO_DISTRIBUTION_VERSION: '32'
    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
  needs:
    - "fedora:32@container-prep"
  script:
    - dnf install -y rpmdevtools jq
    - meson "$MESON_BUILDDIR"
    - VERSION=$(meson introspect "$MESON_BUILDDIR" --projectinfo | jq -r .version)
    - sed -e "s/@PIPELINEID@/${CI_PIPELINE_ID}/"
          -e "s/@GITVERSION@/${CI_COMMIT_SHA}/"
          -e "s/@VERSION@/${VERSION}/" .gitlab-ci/libinput.spec.in > libinput.spec
    - git config --local user.name 'gitlab CI'
    - git config --local user.email 'noreply@nowhere'
    - git add libinput.spec && git commit -m 'Add libinput.spec for build testing' libinput.spec
    - cd "$MESON_BUILDDIR"
    - meson dist --no-test
    - rpmbuild -ta meson-dist/libinput*.tar.xz

710
wayland-web:
711
  image: alpine:latest
712 713
  stage: deploy
  script:
714
    - apk add curl
715 716 717 718 719 720 721 722
    # Requirements:
    # - variable WAYLAND_WEB_TOKEN defined as type File in libinput's CI/CD settings
    # - content of that file is the token value, as generated by the Pipeline Triggers
    #   of the wayland.freedesktop.org project.
    - curl --request POST
           --form "token=<$WAYLAND_WEB_TOKEN"
           --form ref=master
           https://gitlab.freedesktop.org/api/v4/projects/wayland${SLASH}wayland${DOT}freedesktop${DOT}org/trigger/pipeline
723 724 725
  except:
    refs:
      - schedules
726 727 728 729 730 731 732 733 734 735
  only:
    refs:
      - master
    variables:
      - $CI_PROJECT_PATH == "libinput/libinput"
  dependencies: []
  variables:
    DOT: "%2E"
    SLASH: "%2F"