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