ci: Add a dummy trigger job/stage
[platform/upstream/gstreamer.git] / .gitlab-ci.yml
1 include:
2   - remote: "https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/7ea696055e322cc7aa4bcbe5422b56a198c4bdff/templates/ci-fairy.yml"
3
4 stages:
5   - 'trigger'
6   - 'build docker'
7   - 'preparation'
8   - 'pre-build'
9   - 'build'
10   - 'test'
11   # Use the resulting binaries
12   - 'integrate'
13
14 variables:
15   # Branch to track for modules that have no ref specified in the manifest
16   GST_UPSTREAM_BRANCH: 'master'
17   ORC_UPSTREAM_BRANCH: 'master'
18
19   ###
20   # IMPORTANT
21   # These are the version tags for the docker images the CI runs against.
22   # If you are hacking on them or need a them to rebuild, its enough
23   # to change any part of the string of the image you want.
24   ###
25   FEDORA_TAG:  '2021-06-30.0'
26   INDENT_TAG: '2020-10-22.0'
27   WINDOWS_TAG: "2021-10-01.0"
28
29   GST_UPSTREAM_REPO: 'gstreamer/gst-ci'
30
31   FEDORA_AMD64_SUFFIX:  'amd64/fedora'
32   INDENT_AMD64_SUFFIX: 'amd64/gst-indent'
33   WINDOWS_AMD64_SUFFIX: 'amd64/windows'
34   WINDOWS_RUST_AMD64_SUFFIX: 'amd64/windows-rust'
35
36   FEDORA_IMAGE:   "$CI_REGISTRY_IMAGE/$FEDORA_AMD64_SUFFIX:$FEDORA_TAG-$GST_UPSTREAM_BRANCH"
37   FEDORA_DOCS_IMAGE: "registry.freedesktop.org/gstreamer/gst-ci/amd64/fedora:2020-07-03.0-master"
38   INDENT_IMAGE:   "$CI_REGISTRY_IMAGE/$INDENT_AMD64_SUFFIX:$INDENT_TAG-$GST_UPSTREAM_BRANCH"
39   WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
40   WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
41
42   RUST_MINIMUM_VERSION: '1.54.0'
43   RUST_LATEST_VERSION: '1.55.0'
44
45   WINDOWS_RUST_MINIMUM_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_MINIMUM_VERSION"
46   WINDOWS_RUST_MINIMUM_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_MINIMUM_VERSION"
47
48   WINDOWS_RUST_LATEST_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_LATEST_VERSION"
49   WINDOWS_RUST_LATEST_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_LATEST_VERSION"
50
51   MESON_BUILDTYPE_ARGS: --default-library=both
52   DEFAULT_MESON_ARGS: >
53     -Dlibnice:tests=disabled
54     -Dlibnice:examples=disabled
55     -Dopenh264:tests=disabled
56     -Dpygobject:tests=false
57     -Dpython=enabled
58     -Dlibav=enabled
59     -Dugly=enabled
60     -Dbad=enabled
61     -Ddevtools=enabled
62     -Dges=enabled
63     -Drtsp_server=enabled
64     -Dvaapi=enabled
65     -Dsharp=disabled
66
67   MESON_GST_WERROR: >
68     -Dgstreamer:werror=true
69     -Dgst-plugins-base:werror=true
70     -Dgst-plugins-good:werror=true
71     -Dgst-plugins-ugly:werror=true
72     -Dgst-plugins-bad:werror=true
73     -Dgst-rtsp-server:werror=true
74     -Dgst-libav:werror=true
75     -Dgst-examples:werror=true
76     -Dgst-editing-services:werror=true
77     -Dgst-docs:werror=true
78     -Dgst-omx:werror=true
79     -Dgst-devtools:werror=true
80     -Dgst-python:werror=true
81     -Dgstreamer-vaapi:werror=true
82     -Dgstreamer-sharp:werror=true
83
84 workflow:
85   # https://docs.gitlab.com/ee/ci/yaml/index.html#switch-between-branch-pipelines-and-merge-request-pipelines
86   rules:
87     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
88     - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
89       when: never
90     - if: '$CI_COMMIT_BRANCH'
91
92 #
93 # Global CI policy
94 #
95 # This can be used to configure global behaviour our our jobs.
96 #
97 default:
98   retry:
99     max: 2
100     when:
101       - 'runner_system_failure'
102       - 'stuck_or_timeout_failure'
103       - 'scheduler_failure'
104       - 'api_failure'
105   interruptible: true
106
107 # This is an empty job that is used to trigger the pipeline.
108 trigger:
109   image: alpine:latest
110   stage: 'trigger'
111   script:
112     - echo "Trigger job done, now running the pipeline."
113   rules:
114     # If the MR is assigned to the Merge bot, trigger the pipeline automatically
115     - if: '$CI_MERGE_REQUEST_ASSIGNEES == "gstreamer-merge-bot"'
116     # When the assignee isn't the merge bot, require an explicit action to trigger the pipeline
117     # to avoid wasting CI resources
118     - if: '$CI_MERGE_REQUEST_ASSIGNEES != "gstreamer-merge-bot"'
119       when: 'manual'
120       allow_failure: false
121     # If this matches, it means the pipeline is running against either the main
122     # or a stable branch, so make it manual
123     - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
124       when: 'manual'
125
126
127 # Script to check if a docker image exists in the upstream registry
128 # and if so copy it to the forked registry so we can use it
129 #
130 # This is copied/adapted from citemplates/templates/fedora.yml
131 # https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/96b621fe9f57ec2464f8d1a0940446afbf6c8f59/templates/fedora.yml
132 .check_image: &check_image_exists |
133   # if-not-exists steps
134   set -x
135
136   if [[ -z "$GST_FORCE_REBUILD" ]]
137   then
138     # disable exit on failure
139     set +e
140
141     # check if our image is already in the current registry
142     # we store the sha of the digest and the layers
143     skopeo inspect docker://$LOCAL_IMAGE | jq '[.Digest, .Layers]' > local_sha
144
145     # check if our image is already in our gst-ci registry fork
146     skopeo inspect docker://$LOCAL_GST_CI_IMAGE | jq '[.Digest, .Layers]' > local_gst_ci_sha
147
148     # check if our image is already in the upstream registry
149     if [[ -z "$GST_UPSTREAM_REPO" ]]
150     then
151       echo "WARNING! Variable \$GST_UPSTREAM_REPO is undefined, cannot check for images"
152     else
153       skopeo inspect docker://$GST_UPSTREAM_IMAGE | jq '[.Digest, .Layers]' > upstream_sha
154     fi
155
156     # reenable exit on failure
157     set -e
158
159     # if the upstream repo has an image, ensure we use the same
160     if [ -s upstream_sha ]
161     then
162
163       echo "Checking if $LOCAL_IMAGE is up to date"
164       # ensure we use the same image from upstream
165       diff upstream_sha local_sha && exit 0 || true
166
167       echo "Copying image from gstreamer/gst-ci to local registry"
168       # copy the original image into the current project registry namespace
169       # we do 2 attempts with skopeo copy at most
170       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
171                   docker://$GST_UPSTREAM_IMAGE \
172                   docker://$LOCAL_IMAGE || \
173       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
174                   docker://$GST_UPSTREAM_IMAGE \
175                   docker://$LOCAL_IMAGE
176
177       exit 0
178     fi
179
180     set +x
181
182     # if the local ci fork repo has an image, ensure we use the same
183     if [ -s local_gst_ci_sha ]
184     then
185       echo "Checking if $LOCAL_GST_CI_IMAGE is up to date"
186       # ensure we use the same image from upstream
187       diff local_gst_ci_sha local_sha && exit 0 || true
188
189       echo "Copying image from $CI_PROJECT_NAMESPACE/gst-ci to local registry"
190       # copy the original image into the current project registry namespace
191       # we do 2 attempts with skopeo copy at most
192       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
193                   docker://$LOCAL_GST_CI_IMAGE \
194                   docker://$LOCAL_IMAGE || \
195       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
196                   docker://$LOCAL_GST_CI_IMAGE \
197                   docker://$LOCAL_IMAGE
198
199       exit 0
200     fi
201
202     # if we have a local image but none in the upstream repo, use our
203     if [ -s local_sha ]
204     then
205       echo "Using $LOCAL_IMAGE"
206       exit 0
207     fi
208   fi
209
210
211 # Build docker images from Dockerfiles
212 #
213 # This is copied/adapted from citemplates/templates/fedora.yml
214 # https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/96b621fe9f57ec2464f8d1a0940446afbf6c8f59/templates/fedora.yml
215 #
216 # CITemplates builds uses buildah run/commit workflow to build the images which doesn't
217 # fit us atm and our images need further adjustment to make use of it. Porting to
218 # ci-templates is the next step though.
219 #
220 # All the documentation from citemplates should be applicable here, so please refer there
221 .base:
222   image: "$CI_REGISTRY/freedesktop/ci-templates/buildah:2020-07-20.1"
223   variables:
224     STORAGE_DRIVER: 'vfs'
225     BUILDAH_FORMAT: 'docker'
226     BUILDAH_ISOLATION: 'chroot'
227   script:
228     - export LOCAL_IMAGE="$CI_REGISTRY_IMAGE/$REPO_SUFFIX:$TAG"
229     - export LOCAL_GST_CI_IMAGE="$CI_REGISTRY/$CI_PROJECT_NAMESPACE/gst-ci/$REPO_SUFFIX:$TAG"
230     - export GST_UPSTREAM_IMAGE="$CI_REGISTRY/$GST_UPSTREAM_REPO/$REPO_SUFFIX:$TAG"
231
232     # check if the docker registry is enabled, else the variable will be missing
233     - |
234       if [[ -z "$CI_REGISTRY_IMAGE" ]]
235       then
236         echo "ERROR! Looks like your repository/fork has disabled Docker Registries."
237         echo "Pleae enable them by following the documentation from here:"
238         echo "https://docs.gitlab.com/ee/user/packages/container_registry/#enable-the-container-registry-for-your-project"
239         exit 1
240       fi
241
242     # Newer versions of podman/buildah try to set overlayfs mount options when
243     # using the vfs driver, and this causes errors.
244     - sed -i '/^mountopt =.*/d' /etc/containers/storage.conf
245
246     - *check_image_exists
247
248     - echo "Building image $LOCAL_IMAGE"
249
250     - >
251       buildah bud
252       --build-arg DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH
253       --label ci.job_id=$CI_JOB_ID
254       --label pipeline.url=$CI_PIPELINE_URL
255       --label git.ref_name=$CI_COMMIT_REF_NAME
256       --label git.sha=$CI_COMMIT_SHA
257       --label gitlab.project_path=$CI_PROJECT_PATH
258       --label gitlab.project_url=$CI_PROJECT_URL
259       --label fdo.upstream-repo=$GST_UPSTREAM_REPO
260       -f $DOCKERFILE
261       -t $LOCAL_IMAGE
262       $CONTEXT_DIR
263
264     - buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
265
266     # Sanity check
267     - |
268       if [ "$CI_PROJECT_PATH" = "gstreamer/gstreamer" ]; then
269         if [ "$LOCAL_IMAGE" != "$GST_UPSTREAM_IMAGE" ]; then
270           echo "ERROR!!! AAAAA! THE IMAGE URI DOES NOT MATCH THE EXPECTED UPSTREAM ONE"
271           echo $LOCAL_IMAGE
272           echo $GST_UPSTREAM_IMAGE
273           exit 1
274         fi
275       fi
276
277     -  buildah push $LOCAL_IMAGE
278
279 fedora amd64 docker:
280   stage: "build docker"
281   needs:
282     - "trigger"
283   variables:
284     REPO_SUFFIX: "$FEDORA_AMD64_SUFFIX"
285     TAG: "$FEDORA_TAG-$GST_UPSTREAM_BRANCH"
286
287     CONTEXT_DIR: "ci/docker/fedora/"
288     DOCKERFILE: "ci/docker/fedora/Dockerfile"
289   extends: .base
290
291 gst-indent amd64 docker:
292   stage: "build docker"
293   # Do not depend on the trigger, as we want to run indent always
294   needs: []
295   variables:
296     REPO_SUFFIX: "$INDENT_AMD64_SUFFIX"
297     TAG: "$INDENT_TAG-$GST_UPSTREAM_BRANCH"
298
299     CONTEXT_DIR: "ci/docker/indent/"
300     DOCKERFILE: "ci/docker/indent/Dockerfile"
301   extends: .base
302
303 windows amd64 docker:
304   stage: "build docker"
305   needs:
306     - "trigger"
307   variables:
308     # Unlike the buildah/linux jobs, this file
309     # needs to be relative to docker/windows/ subdir
310     # as it makes life easier in the powershell script
311     #
312     # We also don't need a CONTEXT_DIR var as its also
313     # hardcoded to be docker/windows/
314     DOCKERFILE: "ci/docker/windows/Dockerfile"
315   tags:
316     - windows
317     - shell
318     - "1809"
319   script:
320     # We need to pass an array and to resolve the env vars, so we can't use a variable:
321     - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH")
322
323     - "& ci/docker/windows/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE"
324     - |
325       if (!($?)) {
326         echo "Failed to build the image"
327         Exit 1
328       }
329
330 .windows rust docker build:
331   stage: 'build docker'
332   needs:
333     - job: 'windows amd64 docker'
334       artifacts: false
335   rules:
336     - if: '$CI_PROJECT_NAME == "gst-ci"'
337   variables:
338     # Unlike the buildah/linux jobs, this file
339     # needs to be relative to docker/windows/ subdir
340     # as it makes life easier in the powershell script
341     #
342     # We also don't need a CONTEXT_DIR var as its also
343     # hardcoded to be docker/windows/
344     DOCKERFILE: 'docker/windows/rust.Dockerfile'
345   tags:
346     - 'windows'
347     - 'shell'
348     - '1809'
349   script:
350     # We need to pass an array and to resolve the env vars, so we can't use a variable:
351     - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH", "--build-arg", "BASE_IMAGE=$WINDOWS_IMAGE", "--build-arg", "RUST_VERSION=$RUST_VERSION")
352
353     - $env:WINDOWS_CONTAINER_SCRIPT_PATH = "$env:CI_PROJECT_DIR\container.ps1"
354     - echo "Fetching $env:WINDOWS_CONTAINER_SCRIPT_URL"
355     - Invoke-WebRequest -Uri $env:WINDOWS_CONTAINER_SCRIPT_URL -OutFile $env:WINDOWS_CONTAINER_SCRIPT_PATH
356
357     - "& $env:WINDOWS_CONTAINER_SCRIPT_PATH $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $RUST_IMAGE $RUST_UPSTREAM_IMAGE $DOCKERFILE"
358     - |
359       if (!($?)) {
360         echo "Failed to build the image"
361         Exit 1
362       }
363
364 windows rust amd64 docker latest stable:
365   extends: '.windows rust docker build'
366   variables:
367     RUST_IMAGE: !reference [variables, "WINDOWS_RUST_LATEST_IMAGE"]
368     RUST_UPSTREAM_IMAGE: !reference [variables, "WINDOWS_RUST_LATEST_UPSTREAM_IMAGE"]
369     RUST_VERSION: !reference [variables, "RUST_LATEST_VERSION"]
370
371 windows rust amd64 docker minimum supported version:
372   extends: '.windows rust docker build'
373   variables:
374     RUST_IMAGE: !reference [variables, "WINDOWS_RUST_MINIMUM_IMAGE"]
375     RUST_UPSTREAM_IMAGE: !reference [variables, "WINDOWS_RUST_MINIMUM_UPSTREAM_IMAGE"]
376     RUST_VERSION: !reference [variables, "RUST_MINIMUM_VERSION"]
377
378
379
380 # ---- Preparation ----- #
381 #
382 # gst-indent!!
383 #
384 gst indent:
385   image: $INDENT_IMAGE
386   stage: 'preparation'
387   needs:
388     - job: 'gst-indent amd64 docker'
389       artifacts: false
390   script:
391     # man indent. grep RETURN VALUE, grab a beer on my behalf...
392     - indent --version || true
393     - ./scripts/gst-indent-all
394     - |
395       if git diff --quiet -- ':!subprojects/gst-integration-testsuites/medias' .; then
396           echo "Code is properly formatted"
397       else
398           git diff --color=always -- ':!subprojects/gst-integration-testsuites/medias' .
399           echo 'style diverges, please run gst-indent first'
400           exit 1
401       fi
402
403 #
404 # Check "allow-edit" checkbox on merge requests with ci-fairy
405 #
406 check allow-edit:
407   extends: '.fdo.ci-fairy'
408   needs: []
409   stage: 'preparation'
410   script:
411     - ci-fairy check-merge-request --require-allow-collaboration
412   rules:
413     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
414
415 #
416 # build setup templates
417 #
418 .build_template: &build
419   - echo $MESON_ARGS
420
421   - meson build/ $MESON_ARGS
422   - ninja -C build/
423   - ccache --show-stats
424
425 .build_ccache_vars:
426   variables:
427     CCACHE_COMPILERCHECK: 'content'
428     CCACHE_COMPRESS: 'true'
429     CCACHE_BASEDIR: '/cache/gstreamer/gstreamer'
430     CCACHE_DIR: '/cache/gstreamer/gstreamer/ccache/'
431     # shared across everything really
432     CCACHE_MAXSIZE: '10G'
433     CARGO_HOME: '/cache/gstreamer/cargo'
434
435 .simple_fedora_build: &simple_build >-
436   ${DEFAULT_MESON_ARGS}
437   -Dsharp=enabled
438   -Domx=enabled
439   -Dgst-omx:target=generic
440   -Ddoc=disabled
441   -Drs=disabled
442   ${MESON_BUILDTYPE_ARGS}
443   ${MESON_GST_WERROR}
444
445 .build:
446   stage: 'build'
447   extends:
448     - '.build_ccache_vars'
449   needs:
450     - "trigger"
451   # Taking into account the slowest shared runner + time needed to upload the binaries to artifacts
452   # Also need to take into account I/O of pulling docker images and uploading artifacts
453   timeout: '45min'
454   variables:
455     MESON_ARGS: "${DEFAULT_MESON_ARGS} ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"
456   script:
457     *build
458   after_script:
459     - mv build/meson-logs/ meson-logs
460   artifacts:
461     expire_in: "7 days"
462     when: "always"
463     paths:
464       - 'meson-logs/'
465
466 .base_modules_changes: &modules_changes
467   - .gitlab-ci.yml
468   - meson.build
469   - subprojects/*.wrap
470   - subprojects/gst-devtools/**/*
471   - subprojects/gst-editing-services/**/*
472   - subprojects/gst-integration-testsuites/**/*
473   - subprojects/gst-libav/**/*
474   - subprojects/gst-omx/**/*
475   - subprojects/gst-plugins-bad/**/*
476   - subprojects/gst-plugins-base/**/*
477   - subprojects/gst-plugins-good/**/*
478   - subprojects/gst-plugins-ugly/**/*
479   - subprojects/gst-python/**/*
480   - subprojects/gstreamer/**/*
481   - subprojects/gstreamer-sharp/**/*
482   - subprojects/gstreamer-vaapi/**/*
483   - subprojects/gst-rtsp-server/**/*
484
485 .simple_fedora_build: &simple_build >-
486   ${DEFAULT_MESON_ARGS}
487   -Dsharp=enabled
488   -Domx=enabled
489   -Dgst-omx:target=generic
490   -Ddoc=disabled
491   -Drs=disabled
492   ${MESON_BUILDTYPE_ARGS}
493   ${MESON_GST_WERROR}
494
495 .build:
496   stage: 'build'
497   extends:
498     - '.build_ccache_vars'
499   # Taking into account the slowest shared runner + time needed to upload the binaries to artifacts
500   # Also need to take into account I/O of pulling docker images and uploading artifacts
501   timeout: '45min'
502   variables:
503     MESON_ARGS: "${DEFAULT_MESON_ARGS} ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"
504   before_script:
505     - ci/scripts/handle-subprojects-cache.py subprojects/
506     # Update subprojects to respect `.wrap` content
507     - meson subprojects update --reset
508   script:
509     *build
510   after_script:
511     - mv build/meson-logs/ meson-logs
512   artifacts:
513     expire_in: "7 days"
514     when: "always"
515     paths:
516       - 'meson-logs/'
517
518 .build fedora x86_64:
519   extends: '.build'
520   image: $FEDORA_IMAGE
521   needs:
522     - "fedora amd64 docker"
523   variables:
524     MESON_ARGS: *simple_build
525   rules:
526     - changes:
527         *modules_changes
528
529 build nodebug fedora x86_64:
530   extends: '.build'
531   image: $FEDORA_IMAGE
532   needs:
533     - "fedora amd64 docker"
534   variables:
535     MESON_ARGS: "${DEFAULT_MESON_ARGS} -Dsharp=enabled -Dgstreamer:gst_debug=false -Domx=enabled -Dgst-omx:target=generic ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"
536
537 build static fedora x86_64:
538   extends: '.build fedora x86_64'
539   variables:
540     MESON_BUILDTYPE_ARGS: "--default-library=static -Dintrospection=disabled -Ddoc=disabled"
541
542 build static nodebug fedora x86_64:
543   extends: 'build nodebug fedora x86_64'
544   variables:
545     MESON_BUILDTYPE_ARGS: "--default-library=static -Dintrospection=disabled -Ddoc=disabled"
546
547 build clang fedora x86_64:
548   extends: '.build fedora x86_64'
549   variables:
550     CC: 'ccache clang'
551     CXX: 'ccache clang++'
552
553 .build windows:
554   image: $WINDOWS_IMAGE
555   stage: 'build'
556   tags:
557     - 'docker'
558     - 'windows'
559     - '1809'
560   needs:
561     - "windows amd64 docker"
562   timeout: '45min'
563   variables:
564     MESON_ARGS: >
565       ${DEFAULT_MESON_ARGS}
566       -Dpython=disabled
567       -Dlibav=disabled
568       -Dvaapi=disabled
569       -Dgst-plugins-base:pango=enabled
570       -Dgst-plugins-good:cairo=enabled
571   rules:
572     - changes:
573         *modules_changes
574   before_script:
575     - ci/scripts/handle-subprojects-cache.py subprojects/
576   script:
577     # For some reason, options are separated by newline instead of space, so we
578     # have to replace them first.
579     - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
580     - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
581         meson build $env:MESON_ARGS &&
582         ninja -C build"
583   # XXX: Re-enable when uploading stops timing out
584   #artifacts:
585   #  expire_in: "7 days"
586   #  when: "always"
587   #  paths:
588   #    - 'build/meson-logs/'
589
590 build vs2017 amd64:
591   extends: '.build windows'
592   variables:
593     ARCH: 'amd64'
594
595 build vs2017 x86:
596   extends: '.build windows'
597   variables:
598     ARCH: 'x86'
599
600 build msys2 :
601   extends: '.build windows'
602   timeout: '60min'
603   rules:
604     - changes:
605         *modules_changes
606       allow_failure: true
607       when: 'manual'
608   script:
609     # Make sure powershell exists on errors
610     # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6
611     - $ErrorActionPreference = "Stop"
612
613     # For some reason docker build hangs if this is included in the image, needs more troubleshooting
614     - $env:PATH += ';C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\mingw32\bin'
615     # Copied from https://github.com/msys2/setup-msys2/blob/master/main.js#L98
616     - C:\msys64\usr\bin\bash -c "pacman-key --init && pacman-key --populate msys2 && pacman-key --refresh-keys || true"
617     - C:\msys64\usr\bin\bash -c "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
618     - echo "Updating MSYS2"
619     - C:\msys64\usr\bin\bash -c "pacman -Syuu --noconfirm || echo Update failed, ignoring"
620     - echo "Killing all MSYS2 processes"
621     - taskkill /F /FI "MODULES eq msys-2.0.dll"
622     - echo "Completing MSYS2 update"
623     - C:\msys64\usr\bin\bash -c "pacman -Suu --noconfirm"
624     - echo "Installing needed MSYS2 packages"
625     - C:\msys64\usr\bin\bash -c "pacman -Sy --noconfirm --needed mingw-w64-x86_64-toolchain ninja"
626
627     # For some reason, options are separated by newline instead of space, so we
628     # have to replace them first.
629     - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
630     # Replace forward slashes with backwards so bash doesn't complain
631     - $env:_PROJECT_DIR = $env:CI_PROJECT_DIR.replace('\','/')
632     - C:\msys64\usr\bin\bash -c "meson build $env:MESON_ARGS && ninja -C build"
633
634 # ---- Tests ----- #
635
636 .test:
637   stage: 'test'
638   extends:
639     - '.build_ccache_vars'
640   needs:
641     - "trigger"
642   variables:
643     MESON_ARGS: *simple_build
644
645     # Disable colored output to avoid weird rendering issues
646     GST_DEBUG_NO_COLOR: "true"
647     CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/validate-logs/"
648     GST_VALIDATE_LAUNCHER_FORCE_COLORS: "true"
649     TIMEOUT_FACTOR: "2"
650     CARGO_HOME: "/cache/gstreamer/cargo"
651     # Enable the fault handler so we get backtraces on segfaults.
652     # any non-empty string will do
653     PYTHONFAULTHANDLER: "enabled"
654   rules:
655     - changes:
656         *modules_changes
657   script:
658     - *build
659
660     - echo "-> Running ${TEST_SUITE}"
661     - >
662       ./gst-env.py
663       gst-validate-launcher ${TEST_SUITE}
664       --dump-on-failure
665       --mute
666       --shuffle
667       --no-display
668       --meson-no-rebuild
669       --timeout-factor "${TIMEOUT_FACTOR}"
670       --fail-on-testlist-change
671       -l "${CI_PROJECT_DIR}/validate-logs/"
672       --xunit-file "${CI_PROJECT_DIR}/validate-logs/xunit.xml"
673       ${EXTRA_VALIDATE_ARGS}
674   after_script:
675     - mv build/meson-logs/ meson-logs
676   artifacts:
677     expire_in: '14 days'
678     when: always
679     paths:
680       - 'meson-logs/'
681       - 'validate-logs'
682     reports:
683       junit:
684         - "validate-logs/*.xml"
685
686 .test fedora x86_64:
687   image: $FEDORA_IMAGE
688   needs:
689     - "fedora amd64 docker"
690   extends: '.test'
691   tags: ['gstreamer']
692
693 check fedora:
694   extends: '.test fedora x86_64'
695   variables:
696     TEST_SUITE: "check.gst*"
697
698 integration testsuites fedora:
699   extends: '.test fedora x86_64'
700   parallel: 4
701   variables:
702     EXTRA_VALIDATE_ARGS: "--timeout-factor=2 --retry-on-failures --check-bugs --parts=${CI_NODE_TOTAL} --part-index=${CI_NODE_INDEX}"
703     TEST_SUITE: "validate ges"
704
705 # gstreamer-full:
706 # introspection has been disabled as the static build does not support it.
707 # See https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/162
708 gstreamer-full:
709   extends: 'build static fedora x86_64'
710   stage: integrate
711   variables:
712     MESON_ARGS: >
713       --default-library=static
714       -Dintrospection=disabled
715       $MESON_GST_WERROR
716   rules:
717     - changes:
718       - "*"
719       - scripts/*
720       - subprojects/gst-ci/**/*
721
722   script:
723   - *build
724   - meson test -C build -v test-gst-full
725   artifacts:
726     expire_in: "7 days"
727     when: "always"
728     paths:
729       - 'meson-logs/'
730
731 gstreamer-full-minimal:
732   extends: 'build static fedora x86_64'
733   stage: integrate
734   variables:
735     MESON_ARGS: >
736       --default-library=static
737       -Dauto_features=disabled
738       -Dgstreamer:check=enabled
739       -Dtests=enabled
740       -Dgst-plugins-base:alsa=enabled
741       -Dgst-plugins-base:typefind=enabled
742       -Dgst-plugins-base:pbtypes=enabled
743       -Dgst-full-elements=coreelements:filesrc,fakesink,identity,input-selector
744       -Dgst-full-typefind-functions=typefindfunctions:wav,flv
745       -Dgst-full-device-providers=alsa:alsadeviceprovider
746       -Dgst-full-dynamic-types=pbtypes:video_multiview_flagset
747       $MESON_GST_WERROR
748   rules:
749     - if: '$CI_PROJECT_NAME =~ /^(gst-build|gst-ci)$/'
750
751   script:
752   - *build
753   - meson test -C build -v test-gst-full
754   - meson test -C build test-gst-full-features --test-args "-e filesrc,identity,fakesink -E filesink,capsfilter -t audio/x-wav -T video/vivo -d alsadeviceprovider -D v4l2deviceprovider -l GstVideoMultiviewFlagsSet"
755   - strip build/libgstreamer-full-1.0.so
756   - ls -l build/libgstreamer-full-1.0.so
757   artifacts:
758     expire_in: "7 days"
759     when: "always"
760     paths:
761       - 'meson-logs/'
762
763 # Valgrind
764 .valgrind fedora x86_64:
765   extends: '.test fedora x86_64'
766   stage: 'test'
767   variables:
768     EXTRA_VALIDATE_ARGS: "--valgrind"
769
770 valgrind core:
771   extends: '.valgrind fedora x86_64'
772   variables:
773     TEST_SUITE: "check.gstreamer\\..*"
774   rules:
775     - changes:
776       - "*"
777       - scripts/*
778       - subprojects/gst-ci/**/*
779       - subprojects/gst-devtools/**/*
780       - subprojects/gstreamer/**/*
781
782 valgrind base:
783   extends: '.valgrind fedora x86_64'
784   variables:
785     TEST_SUITE: "check.gst-plugins-base\\..*"
786   rules:
787     - changes:
788       - "*"
789       - scripts/*
790       - subprojects/gst-ci/**/*
791       - subprojects/gst-devtools/**/*
792       - subprojects/gstreamer/**/*
793       - subprojects/gst-plugins-base/**/*
794
795 valgrind good:
796   extends: '.valgrind fedora x86_64'
797   variables:
798     TEST_SUITE: "check.gst-plugins-good\\..*"
799     # take longer time due to splitmux unit test
800     TIMEOUT_FACTOR: "4"
801   rules:
802     - changes:
803       - "*"
804       - scripts/*
805       - subprojects/gst-ci/**/*
806       - subprojects/gst-devtools/**/*
807       - subprojects/gstreamer/**/*
808       - subprojects/gst-plugins-base/**/*
809       - subprojects/gst-plugins-good/**/*
810
811 valgrind ugly:
812   extends: '.valgrind fedora x86_64'
813   variables:
814     TEST_SUITE: "check.gst-plugins-ugly\\..*"
815   rules:
816     - changes:
817       - "*"
818       - scripts/*
819       - subprojects/gst-ci/**/*
820       - subprojects/gst-devtools/**/*
821       - subprojects/gstreamer/**/*
822       - subprojects/gst-plugins-base/**/*
823       - subprojects/gst-plugins-good/**/*
824       - subprojects/gst-plugins-ugly/**/*
825
826 valgrind bad:
827   extends: '.valgrind fedora x86_64'
828   variables:
829     TEST_SUITE: "check.gst-plugins-bad\\..*"
830   rules:
831     - changes:
832       - "*"
833       - scripts/*
834       - subprojects/gst-ci/**/*
835       - subprojects/gst-devtools/**/*
836       - subprojects/gstreamer/**/*
837       - subprojects/gst-plugins-base/**/*
838       - subprojects/gst-plugins-good/**/*
839       - subprojects/gst-plugins-bad/**/*
840
841 valgrind ges:
842   extends: '.valgrind fedora x86_64'
843   variables:
844     TEST_SUITE: "check.gst-editing-services\\..*"
845   rules:
846     - changes:
847       - "*"
848       - scripts/*
849       - subprojects/gst-ci/**/*
850       - subprojects/gst-devtools/**/*
851       - subprojects/gstreamer/**/*
852       - subprojects/gst-plugins-base/**/*
853       - subprojects/gst-plugins-good/**/*
854       - subprojects/gst-plugins-bad/**/*
855       - subprojects/gst-editing-services/**/*
856
857 # ---- Integration ----- #
858
859 .documentation:
860   image: $FEDORA_DOCS_IMAGE
861   extends:
862     - '.build_ccache_vars'
863   variables:
864     MESON_ARGS: *simple_build
865     MESON_BUILDTYPE_ARGS: "-Ddoc=enabled"
866     CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/"
867   script:
868   - pip3 install --upgrade hotdoc
869   - *build
870   - ./gst-env.py ninja -C build/ plugins_doc_caches
871   - ./ci/scripts/check-documentation-diff.py
872   - ./gst-env.py hotdoc run --conf-file=build/subprojects/gst-docs/GStreamer-doc.json --fatal-warnings
873   - mv build/subprojects/gst-docs/GStreamer-doc/html documentation/
874
875   artifacts:
876     when: always
877     expire_in: "7 days"
878     paths:
879     - documentation/
880     - plugins-cache-diffs/
881
882 #
883 # This jobs runs in gsrtreamer namespace when after the merge into main branch.
884 # The produced artifact is later used to automatically update the web page.
885 #
886 documentation:
887   stage: integrate
888   extends:
889     - '.documentation'
890   needs: []
891   rules:
892     - if: '$CI_PROJECT_NAMESPACE == "gstreamer" && $CI_COMMIT_BRANCH == "main"'
893
894 #
895 # This job is run in users namespace to validate documentation before merging
896 # MR.
897 #
898 build documentation:
899   extends:
900     - '.documentation'
901   stage: build
902   needs:
903     - "trigger"
904
905   stage: build
906   rules:
907     - changes:
908       - .gitlab-ci.yml
909       - ci/gitlab/freedesktop_doc_importer.sh
910       - subprojects/*.wrap
911       - subprojects/gst-docs/**/*
912       - subprojects/gst-devtools/**/*
913       - subprojects/gst-editing-services/**/*
914       - subprojects/gst-libav/**/*
915       - subprojects/gst-omx/**/*
916       - subprojects/gst-plugins-bad/**/*
917       - subprojects/gst-plugins-base/**/*
918       - subprojects/gst-plugins-good/**/*
919       - subprojects/gst-plugins-ugly/**/*
920       - subprojects/gstreamer/**/*
921       - subprojects/gstreamer-vaapi/**/*
922       - subprojects/gst-rtsp-server/**/*
923
924 # FIXME: Using trigger: causes permission issues, workaround using old REST API.
925 # https://gitlab.com/gitlab-org/gitlab/-/issues/341737
926 cerbero trigger:
927   stage: build
928   image: $FEDORA_IMAGE
929   needs:
930     - "fedora amd64 docker"
931   script:
932     - python3 -m pip install --user python-gitlab
933     - ci/gitlab/trigger_cerbero_pipeline.py
934
935   variables:
936     # Use GST_UPSTREAM_BRANCH
937     UPSTREAM_BRANCH: 'main'
938
939   rules:
940     - changes:
941       - .gitlab-ci.yml
942       - ci/gitlab/tigger_cerbero_pipeline.py
943       - subprojects/gst-devtools/**/*
944       - subprojects/gst-editing-services/**/*
945       - subprojects/gst-libav/**/*
946       - subprojects/gst-plugins-bad/**/*
947       - subprojects/gst-plugins-base/**/*
948       - subprojects/gst-plugins-good/**/*
949       - subprojects/gst-plugins-ugly/**/*
950       - subprojects/gst-python/**/*
951       - subprojects/gstreamer/**/*
952       - subprojects/gst-rtsp-server/**/*
953       - subprojects/gst-examples/**/*