Revert "Revert "docker/windows: build rust image in the ci""
[platform/upstream/gstreamer.git] / gitlab / ci_template.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   - 'build docker stage 2'
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   CERBERO_TAG: '2020-10-22.0'
27   ANDROID_TAG: '2020-10-22.0'
28   MANIFEST_TAG: '2020-10-22.0'
29   TEST_MANIFEST_TAG: '2020-10-22.0'
30   INDENT_TAG: '2020-10-22.0'
31   WINDOWS_TAG: "2021-07-12.0"
32
33   GST_UPSTREAM_REPO: 'gstreamer/gst-ci'
34
35   FEDORA_AMD64_SUFFIX:  'amd64/fedora'
36   CERBERO_AMD64_SUFFIX: 'amd64/cerbero-fedora'
37   ANDROID_AMD64_SUFFIX: 'amd64/android-fedora'
38   MANIFEST_AMD64_SUFFIX: 'amd64/build-manifest'
39   TEST_MANIFEST_AMD64_SUFFIX: 'amd64/test-manifest'
40   INDENT_AMD64_SUFFIX: 'amd64/gst-indent'
41   WINDOWS_AMD64_SUFFIX: 'amd64/windows'
42   WINDOWS_RUST_AMD64_SUFFIX: 'amd64/windows-rust'
43
44   FEDORA_IMAGE:   "$CI_REGISTRY_IMAGE/$FEDORA_AMD64_SUFFIX:$FEDORA_TAG-$GST_UPSTREAM_BRANCH"
45   FEDORA_DOCS_IMAGE: "registry.freedesktop.org/gstreamer/gst-ci/amd64/fedora:2020-07-03.0-master"
46   CERBERO_IMAGE:  "$CI_REGISTRY_IMAGE/$CERBERO_AMD64_SUFFIX:$CERBERO_TAG-$GST_UPSTREAM_BRANCH"
47   ANDROID_IMAGE:  "$CI_REGISTRY_IMAGE/$ANDROID_AMD64_SUFFIX:$ANDROID_TAG-$GST_UPSTREAM_BRANCH"
48   MANIFEST_IMAGE: "$CI_REGISTRY_IMAGE/$MANIFEST_AMD64_SUFFIX:$MANIFEST_TAG-$GST_UPSTREAM_BRANCH"
49   TEST_MANIFEST_IMAGE: "$CI_REGISTRY_IMAGE/$TEST_MANIFEST_AMD64_SUFFIX:$TEST_MANIFEST_TAG-$GST_UPSTREAM_BRANCH"
50   INDENT_IMAGE:   "$CI_REGISTRY_IMAGE/$INDENT_AMD64_SUFFIX:$INDENT_TAG-$GST_UPSTREAM_BRANCH"
51   WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
52   WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
53   WINDOWS_RUST_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
54   WINDOWS_RUST_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
55
56   # Current windows image doesn't seem to be able to spawn procceses for reason,
57   # use a different image until this is debuged
58   # Running command 'c:/builds/alatiera/gst-ci/cerbero-build/build-tools/bin/meson --prefix=c:/builds/alatiera/gst-ci/cerbero-build/dist/msvc_x86_64 --libdir=lib -Ddebug=true --default-library=both -Doptimization=2 --backend=ninja --wrap-mode=nodownload -Db_vscrt=md --native-file c:/builds/alatiera/gst-ci/cerbero-build/sources/msvc_x86_64/gstreamer-1.0-1.19.0.1/_builddir/meson-native-file.txt -Dlibunwind=disabled -Ddbghelp=enabled -Dintrospection=disabled -Dexamples=disabled'
59   # failed to create process
60   CERBERO_WINDOWS_IMAGE: 'registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:v13-master'
61
62   # Can't use $CI_* variables since we use this template in all repos, not just gst-ci
63   CERBERO_SCRIPT_URL: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/gitlab/cerbero_setup.sh"
64   # FIXME: fix the file path url to point to the upstram once merged
65   # WINDOWS_CONTAINER_SCRIPT_URL: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/docker/windows/container.ps1"
66   WINDOWS_CONTAINER_SCRIPT_URL: "https://gitlab.freedesktop.org/alatiera/gst-ci/raw/alatiera/windows-rs-wip/docker/windows/container.ps1"
67
68   GIT_STRATEGY: none
69   MESON_BUILDTYPE_ARGS: --default-library=both
70   DEFAULT_MESON_ARGS: >
71     -Dlibnice:tests=disabled
72     -Dlibnice:examples=disabled
73     -Dopenh264:tests=disabled
74     -Dpygobject:tests=false
75     -Dpython=enabled
76     -Dlibav=enabled
77     -Dugly=enabled
78     -Dbad=enabled
79     -Ddevtools=enabled
80     -Dges=enabled
81     -Drtsp_server=enabled
82     -Dvaapi=enabled
83     -Dsharp=disabled
84
85   MESON_GST_WERROR: >
86     -Dgstreamer:werror=true
87     -Dgst-plugins-base:werror=true
88     -Dgst-plugins-good:werror=true
89     -Dgst-plugins-ugly:werror=true
90     -Dgst-plugins-bad:werror=true
91     -Dgst-rtsp-server:werror=true
92     -Dgst-libav:werror=true
93     -Dgst-examples:werror=true
94     -Dgst-editing-services:werror=true
95     -Dgst-docs:werror=true
96     -Dgst-omx:werror=true
97     -Dgst-devtools:werror=true
98     -Dgst-python:werror=true
99     -Dgstreamer-vaapi:werror=true
100     -Dgstreamer-sharp:werror=true
101
102   DEFAULT_CERBERO_ARGS: >
103     --variants werror
104     --timestamps
105
106 workflow:
107   rules:
108     - if: $CI_MERGE_REQUEST_IID
109     # don't create a pipeline if its a commit pipeline, on a branch and that branch has
110     # open merge requests (bc we will get a MR build instead)
111     - if: $CI_OPEN_MERGE_REQUESTS
112       when: never
113     - if: $CI_COMMIT_TAG
114     - if: $CI_COMMIT_BRANCH
115
116 #
117 # Global CI policy
118 #
119 # This can be used to configure global behaviour our our jobs.
120 #
121 default:
122   retry:
123     max: 2
124     when:
125       - 'runner_system_failure'
126       - 'stuck_or_timeout_failure'
127       - 'scheduler_failure'
128       - 'api_failure'
129   interruptible: true
130
131
132 # Script to check if a docker image exists in the upstream registry
133 # and if so copy it to the forked registry so we can use it
134 #
135 # This is copied/adapted from citemplates/templates/fedora.yml
136 # https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/96b621fe9f57ec2464f8d1a0940446afbf6c8f59/templates/fedora.yml
137 .check_image: &check_image_exists |
138   # if-not-exists steps
139   set -x
140
141   if [[ -z "$GST_FORCE_REBUILD" ]]
142   then
143     # disable exit on failure
144     set +e
145
146     # check if our image is already in the current registry
147     # we store the sha of the digest and the layers
148     skopeo inspect docker://$LOCAL_IMAGE | jq '[.Digest, .Layers]' > local_sha
149
150     # check if our image is already in our gst-ci registry fork
151     skopeo inspect docker://$LOCAL_GST_CI_IMAGE | jq '[.Digest, .Layers]' > local_gst_ci_sha
152
153     # check if our image is already in the upstream registry
154     if [[ -z "$GST_UPSTREAM_REPO" ]]
155     then
156       echo "WARNING! Variable \$GST_UPSTREAM_REPO is undefined, cannot check for images"
157     else
158       skopeo inspect docker://$GST_UPSTREAM_IMAGE | jq '[.Digest, .Layers]' > upstream_sha
159     fi
160
161     # reenable exit on failure
162     set -e
163
164     # if the upstream repo has an image, ensure we use the same
165     if [ -s upstream_sha ]
166     then
167
168       echo "Checking if $LOCAL_IMAGE is up to date"
169       # ensure we use the same image from upstream
170       diff upstream_sha local_sha && exit 0 || true
171
172       echo "Copying image from gstreamer/gst-ci to local registry"
173       # copy the original image into the current project registry namespace
174       # we do 2 attempts with skopeo copy at most
175       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
176                   docker://$GST_UPSTREAM_IMAGE \
177                   docker://$LOCAL_IMAGE || \
178       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
179                   docker://$GST_UPSTREAM_IMAGE \
180                   docker://$LOCAL_IMAGE
181
182       exit 0
183     fi
184
185     set +x
186
187     # if the local ci fork repo has an image, ensure we use the same
188     if [ -s local_gst_ci_sha ]
189     then
190       echo "Checking if $LOCAL_GST_CI_IMAGE is up to date"
191       # ensure we use the same image from upstream
192       diff local_gst_ci_sha local_sha && exit 0 || true
193
194       echo "Copying image from $CI_PROJECT_NAMESPACE/gst-ci to local registry"
195       # copy the original image into the current project registry namespace
196       # we do 2 attempts with skopeo copy at most
197       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
198                   docker://$LOCAL_GST_CI_IMAGE \
199                   docker://$LOCAL_IMAGE || \
200       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
201                   docker://$LOCAL_GST_CI_IMAGE \
202                   docker://$LOCAL_IMAGE
203
204       exit 0
205     fi
206
207     # if we have a local image but none in the upstream repo, use our
208     if [ -s local_sha ]
209     then
210       echo "Using $LOCAL_IMAGE"
211       exit 0
212     fi
213   fi
214
215
216 # Build docker images from Dockerfiles
217 #
218 # This is copied/adapted from citemplates/templates/fedora.yml
219 # https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/96b621fe9f57ec2464f8d1a0940446afbf6c8f59/templates/fedora.yml
220 #
221 # CITemplates builds uses buildah run/commit workflow to build the images which doesn't
222 # fit us atm and our images need further adjustment to make use of it. Porting to
223 # ci-templates is the next step though.
224 #
225 # All the documentation from citemplates should be applicable here, so please refer there
226 .base:
227   image: "$CI_REGISTRY/freedesktop/ci-templates/buildah:2020-07-20.1"
228   variables:
229     STORAGE_DRIVER: 'vfs'
230     BUILDAH_FORMAT: 'docker'
231     BUILDAH_ISOLATION: 'chroot'
232
233     GIT_STRATEGY: fetch
234   script:
235     - export LOCAL_IMAGE="$CI_REGISTRY_IMAGE/$REPO_SUFFIX:$TAG"
236     - export LOCAL_GST_CI_IMAGE="$CI_REGISTRY/$CI_PROJECT_NAMESPACE/gst-ci/$REPO_SUFFIX:$TAG"
237     - export GST_UPSTREAM_IMAGE="$CI_REGISTRY/$GST_UPSTREAM_REPO/$REPO_SUFFIX:$TAG"
238
239     # check if the docker registry is enabled, else the variable will be missing
240     - |
241       if [[ -z "$CI_REGISTRY_IMAGE" ]]
242       then
243         echo "ERROR! Looks like your repository/fork has disabled Docker Registries."
244         echo "Pleae enable them by following the documentation from here:"
245         echo "https://docs.gitlab.com/ee/user/packages/container_registry/#enable-the-container-registry-for-your-project"
246         exit 1
247       fi
248
249     # Newer versions of podman/buildah try to set overlayfs mount options when
250     # using the vfs driver, and this causes errors.
251     - sed -i '/^mountopt =.*/d' /etc/containers/storage.conf
252
253     - *check_image_exists
254
255     # This part of the job should only ever be possible to be reach in a gst-ci fork
256     - |
257       if [[ "$CI_PROJECT_NAME" != 'gst-ci' ]]
258       then
259         echo "ERROR! Something is wrong!"
260         echo "This part of the job is supposed to be executed only in gst-ci forks, and its probably going to fail else"
261         exit 1
262       fi
263
264     - echo "Building image $LOCAL_IMAGE"
265
266     - >
267       buildah bud
268       --build-arg DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH
269       --label ci.job_id=$CI_JOB_ID
270       --label pipeline.url=$CI_PIPELINE_URL
271       --label git.ref_name=$CI_COMMIT_REF_NAME
272       --label git.sha=$CI_COMMIT_SHA
273       --label gitlab.project_path=$CI_PROJECT_PATH
274       --label gitlab.project_url=$CI_PROJECT_URL
275       --label fdo.upstream-repo=$GST_UPSTREAM_REPO
276       -f $DOCKERFILE
277       -t $LOCAL_IMAGE
278       $CONTEXT_DIR
279
280     - buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
281
282     # Sanity check
283     - |
284       if [ "$CI_PROJECT_PATH" = "gstreamer/gst-ci" ]; then
285         if [ "$LOCAL_IMAGE" != "$GST_UPSTREAM_IMAGE" ]; then
286           echo "ERROR!!! AAAAA! THE IMAGE URI DOES NOT MATCH THE EXPECTED UPSTREAM ONE"
287           echo $LOCAL_IMAGE
288           echo $GST_UPSTREAM_IMAGE
289           exit 1
290         fi
291       fi
292
293     -  buildah push $LOCAL_IMAGE
294
295 fedora amd64 docker:
296   stage: "build docker"
297   variables:
298     REPO_SUFFIX: "$FEDORA_AMD64_SUFFIX"
299     TAG: "$FEDORA_TAG-$GST_UPSTREAM_BRANCH"
300
301     CONTEXT_DIR: "./docker/fedora/"
302     DOCKERFILE: "docker/fedora/Dockerfile"
303   extends: .base
304
305 cerbero fedora amd64 docker:
306   stage: "build docker"
307   variables:
308     REPO_SUFFIX: "$CERBERO_AMD64_SUFFIX"
309     TAG: "$CERBERO_TAG-$GST_UPSTREAM_BRANCH"
310
311     CONTEXT_DIR: "docker/cerbero/"
312     DOCKERFILE: "docker/cerbero/Dockerfile-fedora"
313   extends: .base
314
315 android docker:
316   stage: "build docker"
317   variables:
318     REPO_SUFFIX: "$ANDROID_AMD64_SUFFIX"
319     TAG: "$ANDROID_TAG-$GST_UPSTREAM_BRANCH"
320
321     CONTEXT_DIR: "docker/android/"
322     DOCKERFILE: "docker/android/Dockerfile"
323   extends: .base
324
325 alpine amd64 manifest builder docker:
326   stage: "build docker"
327   variables:
328     REPO_SUFFIX: "$MANIFEST_AMD64_SUFFIX"
329     TAG: '$MANIFEST_TAG-$GST_UPSTREAM_BRANCH'
330
331     CONTEXT_DIR: "docker/build_manifest/"
332     DOCKERFILE: "docker/build_manifest/Dockerfile"
333   extends: .base
334
335 gst-indent amd64 docker:
336   stage: "build docker"
337   variables:
338     REPO_SUFFIX: "$INDENT_AMD64_SUFFIX"
339     TAG: "$INDENT_TAG-$GST_UPSTREAM_BRANCH"
340
341     CONTEXT_DIR: "docker/indent/"
342     DOCKERFILE: "docker/indent/Dockerfile"
343   extends: .base
344
345 windows amd64 docker:
346   stage: "build docker"
347   variables:
348     GIT_STRATEGY: fetch
349     REPO_SUFFIX: "$WINDOWS_AMD64_SUFFIX"
350     TAG: "$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
351
352     # Unlike the buildah/linux jobs, this file
353     # needs to be relative to docker/windows/ subdir
354     # as it makes life easier in the powershell script
355     #
356     # We also don't need a CONTEXT_DIR var as its also
357     # hardcoded to be docker/windows/
358     DOCKERFILE: "docker/windows/Dockerfile"
359   tags:
360     - windows
361     - shell
362     - "1809"
363   script:
364     # We need to pass an array and to resolve the env vars, so we can't use a variable:
365     - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH")
366
367     - $env:WINDOWS_CONTAINER_SCRIPT_PATH = "$env:CI_PROJECT_DIR\container.ps1"
368     - echo "Fetching $env:WINDOWS_CONTAINER_SCRIPT_URL"
369     - Invoke-WebRequest -Uri $env:WINDOWS_CONTAINER_SCRIPT_URL -OutFile $env:WINDOWS_CONTAINER_SCRIPT_PATH
370
371     - "& $env:WINDOWS_CONTAINER_SCRIPT_PATH $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE"
372     - |
373       if (!($?)) {
374         echo "Failed to build the image"
375         Exit 1
376       }
377
378 windows rust amd64 docker:
379   stage: 'build docker stage 2'
380   needs:
381     - job: 'windows amd64 docker'
382       artifacts: false
383   variables:
384     GIT_STRATEGY: 'fetch'
385     REPO_SUFFIX: "$WINDOWS_RUST_AMD64_SUFFIX"
386     TAG: "$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
387
388     # Unlike the buildah/linux jobs, this file
389     # needs to be relative to docker/windows/ subdir
390     # as it makes life easier in the powershell script
391     #
392     # We also don't need a CONTEXT_DIR var as its also
393     # hardcoded to be docker/windows/
394     DOCKERFILE: 'docker/windows/rust.Dockerfile'
395   tags:
396     - 'windows'
397     - 'shell'
398     - '1809'
399   script:
400     # We need to pass an array and to resolve the env vars, so we can't use a variable:
401     - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH", "--build-arg", "BASE_IMAGE=$WINDOWS_IMAGE")
402
403     - $env:WINDOWS_CONTAINER_SCRIPT_PATH = "$env:CI_PROJECT_DIR\container.ps1"
404     - echo "Fetching $env:WINDOWS_CONTAINER_SCRIPT_URL"
405     - Invoke-WebRequest -Uri $env:WINDOWS_CONTAINER_SCRIPT_URL -OutFile $env:WINDOWS_CONTAINER_SCRIPT_PATH
406
407     - "& $env:WINDOWS_CONTAINER_SCRIPT_PATH $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_RUST_IMAGE $WINDOWS_RUST_UPSTREAM_IMAGE $DOCKERFILE"
408     - |
409       if (!($?)) {
410         echo "Failed to build the image"
411         Exit 1
412       }
413
414
415 #
416 # Job to create the manifest.xml to used for our builds
417 #
418 manifest:
419   image: $MANIFEST_IMAGE
420   rules:
421     # Always have automatic pipeline for branchs in cerbero and docs
422     # cause they need to update artifacts, like the docs site or cerbero deps
423     - if: '$CI_PROJECT_PATH == "gstreamer/cerbero"'
424     - if: '$CI_PROJECT_PATH == "gstreamer/gst-docs"'
425
426     # If the MR is assigned to the Merge bot, trigger the pipeline automatically
427     - if: '$CI_MERGE_REQUEST_ASSIGNEES == "gstreamer-merge-bot"'
428     # When the assignee isn't the merge bot, require an explicit action to trigger the pipeline
429     # to avoid wasting CI resources
430     - if: '$CI_MERGE_REQUEST_ASSIGNEES != "gstreamer-merge-bot"'
431       when: 'manual'
432       allow_failure: false
433     # If this matches, it means the pipeline is running against either the main
434     # or a stable branch, so make it manual
435     - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
436       when: 'manual'
437       allow_failure: false
438
439   stage: 'preparation'
440   script:
441     - cd /gst-ci
442     - gitlab/build_manifest.py --self-update
443     - gitlab/build_manifest.py ${CI_PROJECT_DIR}/manifest.xml
444     - cat ${CI_PROJECT_DIR}/manifest.xml
445   artifacts:
446     expire_in: "7 days"
447     paths:
448       - "manifest.xml"
449
450 #
451 # gst-indent!!
452 #
453 gst indent:
454   image: $INDENT_IMAGE
455   stage: 'preparation'
456   variables:
457     GIT_STRATEGY: 'fetch'
458   rules:
459     - if: '$CI_PROJECT_NAME !~ /^(gstreamer-sharp|gst-integration-testsuites|cerbero|gst-docs)$/'
460   script:
461     # man indent. grep RETURN VALUE, grab a beer on my behalf...
462     - indent --version || true
463     - |
464       filter_cmd=("cat")
465       if test -f ".indentignore"; then
466           filter_args=()
467           while read -r line; do
468               if test -n "$line"; then
469                   filter_args+=("-e" "$line")
470               fi
471           done < ".indentignore"
472           if [[ ${#filter_args[@]} -gt 0 ]]; then
473               filter_cmd=("grep" "-v" "${filter_args[@]}")
474           fi
475       fi
476       find . -name '*.c' | "${filter_cmd[@]}" | xargs -d '\n' gst-indent
477     - |
478       if git diff --quiet; then
479           echo "Code is properly formatted"
480       else
481           git diff --color=always
482           echo 'style diverges, please run gst-indent first'
483           exit 1
484       fi
485
486 #
487 # Check "allow-edit" checkbox on merge requests with ci-fairy
488 #
489 check allow-edit:
490   extends: '.fdo.ci-fairy'
491   needs: []
492   stage: 'preparation'
493   variables:
494     GIT_STRATEGY: 'none'
495   script:
496     - ci-fairy check-merge-request --require-allow-collaboration
497   rules:
498     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
499
500 #
501 # gst-build setup templates
502 #
503 .gst_build_template: &gst_build
504   - echo $MESON_ARGS
505   # Sometimes, gitlab-runner want to reuse
506   # existing docker volumes without cleaning them up...
507   # Make sure the docker volume is clean
508   - rm -rf gst-build || true
509   - rm -rf meson-logs || true
510   - rm -rf validate-logs || true
511
512   - curl -L -o clone_manifest_ref.py "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/gitlab/clone_manifest_ref.py"
513   - python3 clone_manifest_ref.py --manifest manifest.xml --project gst-build --destination gst-build
514   - cd gst-build/
515   # only copy immediate directories. We don't want to modify .wrap files
516   - find /gst-build/subprojects/ -mindepth 1 -maxdepth 1 -type d -exec cp -r \{\} subprojects/ \;
517
518   # Reset the state of the subprojects to what gst-build expects
519   - meson subprojects update --reset
520   - ./git-update --no-interaction --manifest="${CI_PROJECT_DIR}/manifest.xml"
521
522   - meson build/ $MESON_ARGS
523   - ninja -C build/
524   - ccache --show-stats
525
526 .gst_build_ccache_vars:
527   variables:
528     CCACHE_COMPILERCHECK: 'content'
529     CCACHE_COMPRESS: 'true'
530     CCACHE_BASEDIR: '/cache/gstreamer/gst-build'
531     CCACHE_DIR: '/cache/gstreamer/gst-build/ccache/'
532     # shared across everything really
533     CCACHE_MAXSIZE: '10G'
534     CARGO_HOME: '/cache/gstreamer/cargo'
535
536 .simple_fedora_build: &simple_build >-
537   ${DEFAULT_MESON_ARGS}
538   -Dsharp=enabled
539   -Domx=enabled
540   -Dgst-omx:target=generic
541   -Ddoc=disabled
542   -Drs=disabled
543   ${MESON_BUILDTYPE_ARGS}
544   ${MESON_GST_WERROR}
545
546 .build:
547   stage: 'build'
548   extends:
549     - '.gst_build_ccache_vars'
550   needs:
551     - "manifest"
552   # Taking into account the slowest shared runner + time needed to upload the binaries to artifacts
553   # Also need to take into account I/O of pulling docker images and uploading artifacts
554   timeout: '45min'
555   variables:
556     MESON_ARGS: "${DEFAULT_MESON_ARGS} ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"
557   rules:
558     - if: '$CI_PROJECT_NAME != "cerbero"'
559   script:
560     *gst_build
561   after_script:
562     - mv gst-build/build/meson-logs/ meson-logs
563     # Cleanup everything else to reduce the size
564     # of the docker volume we leave behind
565     - rm -rf gst-build
566   artifacts:
567     expire_in: "7 days"
568     when: "always"
569     paths:
570       - 'meson-logs/'
571       - 'manifest.xml'
572
573 .build fedora x86_64:
574   extends: '.build'
575   image: $FEDORA_IMAGE
576   variables:
577     MESON_ARGS: *simple_build
578   rules:
579     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-omx|gst-plugins-rs)$/'
580
581 build nodebug fedora x86_64:
582   extends: '.build'
583   image: $FEDORA_IMAGE
584   variables:
585     MESON_ARGS: "${DEFAULT_MESON_ARGS} -Dsharp=enabled -Dgstreamer:gst_debug=false -Domx=enabled -Dgst-omx:target=generic ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"
586   rules:
587     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs)$/'
588
589 build static fedora x86_64:
590   extends: '.build fedora x86_64'
591   variables:
592     MESON_BUILDTYPE_ARGS: "--default-library=static -Dintrospection=disabled -Ddoc=disabled"
593   rules:
594     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs)$/'
595
596 build static nodebug fedora x86_64:
597   extends: 'build nodebug fedora x86_64'
598   variables:
599     MESON_BUILDTYPE_ARGS: "--default-library=static -Dintrospection=disabled -Ddoc=disabled"
600   rules:
601     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs)$/'
602
603 build clang fedora x86_64:
604   extends: '.build fedora x86_64'
605   variables:
606     CC: 'ccache clang'
607     CXX: 'ccache clang++'
608   rules:
609     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs)$/'
610
611 .test:
612   stage: 'test'
613   extends:
614     - '.gst_build_ccache_vars'
615   needs:
616     - "manifest"
617   variables:
618     MESON_ARGS: *simple_build
619
620     # Disable colored output to avoid weird rendering issues
621     GST_DEBUG_NO_COLOR: "true"
622     CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/validate-logs/"
623     GST_VALIDATE_LAUNCHER_FORCE_COLORS: "true"
624     TIMEOUT_FACTOR: "2"
625     CARGO_HOME: "/cache/gstreamer/cargo"
626     # Enable the fault handler so we get backtraces on segfaults.
627     # any non-empty string will do
628     PYTHONFAULTHANDLER: "enabled"
629   rules:
630     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-examples|gst-docs)$/'
631   script:
632     - *gst_build
633
634     - echo "-> Running ${TEST_SUITE}"
635     - >
636       ./gst-uninstalled.py
637       gst-validate-launcher ${TEST_SUITE}
638       --dump-on-failure
639       --mute
640       --shuffle
641       --no-display
642       --meson-no-rebuild
643       --timeout-factor "${TIMEOUT_FACTOR}"
644       --fail-on-testlist-change
645       -l "${CI_PROJECT_DIR}/validate-logs/"
646       --xunit-file "${CI_PROJECT_DIR}/validate-logs/xunit.xml"
647       ${EXTRA_VALIDATE_ARGS}
648   after_script:
649     - mv gst-build/build/meson-logs/ meson-logs
650     # Cleanup everything else to reduce the size
651     # of the docker volume we leave behind
652     - rm -rf gst-build
653   artifacts:
654     expire_in: '14 days'
655     when: always
656     paths:
657       - 'meson-logs/'
658       - 'validate-logs'
659       - 'manifest.xml'
660     reports:
661       junit:
662         - "validate-logs/*.xml"
663
664 .test fedora x86_64:
665   image: $FEDORA_IMAGE
666   extends: '.test'
667   tags: ['gstreamer']
668
669 check fedora:
670   extends: '.test fedora x86_64'
671   variables:
672     TEST_SUITE: "check.gst*"
673   rules:
674     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs)$/'
675
676 integration testsuites fedora:
677   extends: '.test fedora x86_64'
678   parallel: 4
679   variables:
680     EXTRA_VALIDATE_ARGS: "--timeout-factor=2 --retry-on-failures --check-bugs --parts=${CI_NODE_TOTAL} --part-index=${CI_NODE_INDEX}"
681     TEST_SUITE: "validate ges"
682   rules:
683     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-examples|gst-omx|gstreamer-sharp|gst-plugins-rs)$/'
684
685 # gstreamer-full:
686 # introspection has been disabled as the static build does not support it.
687 # See https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/162
688 gstreamer-full:
689   extends: 'build static fedora x86_64'
690   stage: integrate
691   variables:
692     MESON_ARGS: >
693       --default-library=static
694       -Dintrospection=disabled
695       $MESON_GST_WERROR
696   rules:
697     - if: '$CI_PROJECT_NAME =~ /^(gst-build|gst-ci)$/'
698
699   script:
700   - *gst_build
701   - meson test -C build -v test-gst-full
702   artifacts:
703     expire_in: "7 days"
704     when: "always"
705     paths:
706       - 'meson-logs/'
707
708 gstreamer-full-minimal:
709   extends: 'build static fedora x86_64'
710   stage: integrate
711   variables:
712     MESON_ARGS: >
713       --default-library=static
714       -Dauto_features=disabled
715       -Dgstreamer:check=enabled
716       -Dtests=enabled
717       -Dgst-plugins-base:alsa=enabled
718       -Dgst-plugins-base:typefind=enabled
719       -Dgst-plugins-base:pbtypes=enabled
720       -Dgst-full-elements=coreelements:filesrc,fakesink,identity,input-selector
721       -Dgst-full-typefind-functions=typefindfunctions:wav,flv
722       -Dgst-full-device-providers=alsa:alsadeviceprovider
723       -Dgst-full-dynamic-types=pbtypes:video_multiview_flagset
724       $MESON_GST_WERROR
725   rules:
726     - if: '$CI_PROJECT_NAME =~ /^(gst-build|gst-ci)$/'
727
728   script:
729   - *gst_build
730   - meson test -C build -v test-gst-full
731   - 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"
732   - strip build/libgstreamer-full-1.0.so
733   - ls -l build/libgstreamer-full-1.0.so
734   artifacts:
735     expire_in: "7 days"
736     when: "always"
737     paths:
738       - 'meson-logs/'
739
740 # Valgrind
741 .valgrind fedora x86_64:
742   extends: '.test fedora x86_64'
743   stage: 'test'
744   variables:
745     EXTRA_VALIDATE_ARGS: "--valgrind"
746
747 valgrind core:
748   extends: '.valgrind fedora x86_64'
749   variables:
750     TEST_SUITE: "check.gstreamer\\..*"
751   rules:
752     - if: '$CI_PROJECT_NAME =~ /^(gstreamer|gst-ci|gst-devtools)$/'
753
754 valgrind base:
755   extends: '.valgrind fedora x86_64'
756   variables:
757     TEST_SUITE: "check.gst-plugins-base\\..*"
758   rules:
759     - if: '$CI_PROJECT_NAME =~ /^(gstreamer|gst-plugins-base|gst-ci|gst-devtools)$/'
760
761 valgrind good:
762   extends: '.valgrind fedora x86_64'
763   variables:
764     TEST_SUITE: "check.gst-plugins-good\\..*"
765     # take longer time due to splitmux unit test
766     TIMEOUT_FACTOR: "4"
767   rules:
768     - if: '$CI_PROJECT_NAME =~ /^(gstreamer|gst-plugins-base|gst-plugins-good|gst-ci|gst-devtools)$/'
769
770 valgrind ugly:
771   extends: '.valgrind fedora x86_64'
772   variables:
773     TEST_SUITE: "check.gst-plugins-ugly\\..*"
774   rules:
775     - if: '$CI_PROJECT_NAME =~ /^(gstreamer|gst-plugins-base|gst-plugins-ugly|gst-ci|gst-devtools)$/'
776
777 valgrind bad:
778   extends: '.valgrind fedora x86_64'
779   variables:
780     TEST_SUITE: "check.gst-plugins-bad\\..*"
781   rules:
782     - if: '$CI_PROJECT_NAME =~ /^(gstreamer|gst-plugins-base|gst-plugins-good|gst-plugins-bad|gst-ci|gst-devtools)$/'
783
784 valgrind ges:
785   extends: '.valgrind fedora x86_64'
786   variables:
787     TEST_SUITE: "check.gst-editing-services\\..*"
788   rules:
789     - if: '$CI_PROJECT_NAME =~ /^(gstreamer|gst-plugins-base|gst-plugins-good|gst-editing-services|gst-ci|gst-devtools)$/'
790
791 # Template for Cerbero GStreamer Build
792 #
793 # Parameters:
794 # CONFIG: The name of the configuration file to use
795 # ARCH: The cerbero <os>_<cpu> (used in cache key)
796 #
797 .cerbero:
798   stage: "build"
799   image: $CERBERO_IMAGE
800   rules:
801     - if: '$CI_PROJECT_NAME == "cerbero"'
802   needs:
803     - "manifest"
804   # Ensure that the runners it will be executed on
805   # will have plenty of space for the cache
806   tags: ['gstreamer']
807   timeout: '3h'
808   variables:
809     CCACHE_COMPILERCHECK: "content"
810     CCACHE_COMPRESS: "true"
811     CCACHE_BASEDIR: "/cache/gstreamer/cerbero/"
812     CCACHE_DIR: "/cache/gstreamer/cerbero/ccache/"
813     # shared across everything really
814     CCACHE_MAXSIZE: "50G"
815
816     CERBERO_HOME: "cerbero-build"
817     CERBERO_SOURCES: "cerbero-sources"
818     CERBERO_ARGS: "${DEFAULT_CERBERO_ARGS}"
819     CERBERO: "./cerbero-uninstalled -c config/${CONFIG} -c localconf.cbc -m manifest.xml"
820     CERBERO_PACKAGE_ARGS: "-t"
821     CERBERO_RUN_WRAPPER: "" # 'wine' on cross-winXX
822     CERBERO_RUN_SUFFIX: "" # '.exe' on cross-winXX
823     HAVE_CCACHE: "yes"
824     # used by macos packages as we only ever install to a fixed directory
825     CERBERO_OVERRIDDEN_DIST_DIR: ""
826     # location where the cerbero git repo is stored on the image
827     CERBERO_HOST_DIR: "/cerbero/"
828   before_script:
829     - echo "Fetching ${CERBERO_SCRIPT_URL}"
830     - curl -L -o cerbero_setup.sh "${CERBERO_SCRIPT_URL}"
831     - chmod +x cerbero_setup.sh
832     - ./cerbero_setup.sh cerbero_before_script
833   script:
834     - ./cerbero_setup.sh cerbero_script
835   cache:
836     key: "${CI_JOB_NAME}"
837     paths:
838       - "${CERBERO_SOURCES}"
839   artifacts:
840     name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
841     expire_in: '5 days'
842     when: 'always'
843     paths:
844       - "manifest.xml"
845       - "${CERBERO_HOME}/logs"
846       - "*.tar.*"
847
848 .build windows:
849   image: $WINDOWS_IMAGE
850   stage: 'build'
851   needs:
852     - 'manifest'
853   tags:
854     - 'docker'
855     - 'windows'
856     - '1809'
857   timeout: '45min'
858   variables:
859     MESON_ARGS: >
860       ${DEFAULT_MESON_ARGS}
861       -Dpython=disabled
862       -Dlibav=disabled
863       -Dvaapi=disabled
864       -Dgst-plugins-base:pango=enabled
865       -Dgst-plugins-good:cairo=enabled
866   rules:
867     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs|gstreamer-vaapi)$/'
868   script:
869     # Sometimes there's seems to be an existing gst-build clone that comes either from the ether or
870     # from a previous job due to some gitlab bug or implicit behavior?
871     # So let's always check and clear it out if its there
872     # https://gitlab.freedesktop.org/tpm/gstreamer-sharp/-/jobs/1672137
873     - if (Test-Path $env:CI_PROJECT_DIR/gst-build) { Remove-Item -Recurse -Force $env:CI_PROJECT_DIR/gst-build }
874
875     # Make sure powershell exists on errors
876     # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6
877     - $ErrorActionPreference = "Stop"
878
879     - Invoke-WebRequest -Uri "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/$env:GST_UPSTREAM_BRANCH/gitlab/clone_manifest_ref.py" -OutFile $env:CI_PROJECT_DIR/clone_manifest_ref.py
880     - python clone_manifest_ref.py --manifest manifest.xml --project gst-build --destination $env:CI_PROJECT_DIR/gst-build
881     - cd $env:CI_PROJECT_DIR/gst-build
882
883     # Update meson
884     # FIXME: remove this once the windows image is rebuilt/updated
885     - pip install -U meson==0.56.2
886
887     - cp -r C:/subprojects/* subprojects/
888     - cd $env:CI_PROJECT_DIR/gst-build
889     # Reset the subprojects to invalidate the cache if needed
890     - meson subprojects update --reset
891     # Run the git-update script and feed it the manifest to setup the environment
892     - python git-update --no-interaction --manifest=$env:CI_PROJECT_DIR/manifest.xml
893
894     # For some reason, options are separated by newline instead of space, so we
895     # have to replace them first.
896     - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
897     # Gitlab executes PowerShell in docker, but VsDevCmd.bat is a batch script.
898     # Environment variables substitutions is done by PowerShell before calling
899     # cmd.exe, that's why we use $env:FOO instead of %FOO%
900     - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
901         meson build $env:MESON_ARGS &&
902         ninja -C build"
903   artifacts:
904     expire_in: "7 days"
905     when: "always"
906     paths:
907       - 'gst-build/build/meson-logs/'
908
909 build vs2017 amd64:
910   extends: '.build windows'
911   variables:
912     ARCH: 'amd64'
913
914 build vs2017 x86:
915   extends: '.build windows'
916   variables:
917     ARCH: 'x86'
918
919 build msys2 :
920   extends: '.build windows'
921   timeout: '60min'
922   rules:
923     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-docs|gst-integration-testsuites|gst-omx|gst-plugins-rs|gstreamer-vaapi)$/'
924       allow_failure: true
925       when: 'manual'
926   script:
927     # Sometimes there's seems to be an existing gst-build clone that comes either from the ether or
928     # from a previous job due to some gitlab bug or implicit behavior?
929     # So let's always check and clear it out if its there
930     # https://gitlab.freedesktop.org/tpm/gstreamer-sharp/-/jobs/1672137
931     - if (Test-Path $env:CI_PROJECT_DIR/gst-build) { Remove-Item -Recurse -Force $env:CI_PROJECT_DIR/gst-build }
932
933     # Make sure powershell exists on errors
934     # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6
935     - $ErrorActionPreference = "Stop"
936
937     # For some reason docker build hangs if this is included in the image, needs more troubleshooting
938     - $env:PATH += ';C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\mingw32\bin'
939     # Copied from https://github.com/msys2/setup-msys2/blob/master/main.js#L98
940     - C:\msys64\usr\bin\bash -c "pacman-key --init && pacman-key --populate msys2 && pacman-key --refresh-keys || true"
941     - C:\msys64\usr\bin\bash -c "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
942     - echo "Updating MSYS2"
943     - C:\msys64\usr\bin\bash -c "pacman -Syuu --noconfirm || echo Update failed, ignoring"
944     - echo "Killing all MSYS2 processes"
945     - taskkill /F /FI "MODULES eq msys-2.0.dll"
946     - echo "Completing MSYS2 update"
947     - C:\msys64\usr\bin\bash -c "pacman -Suu --noconfirm"
948     - echo "Installing needed MSYS2 packages"
949     - C:\msys64\usr\bin\bash -c "pacman -Sy --noconfirm --needed mingw-w64-x86_64-toolchain ninja"
950
951     - Invoke-WebRequest -Uri "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/$env:GST_UPSTREAM_BRANCH/gitlab/clone_manifest_ref.py" -OutFile $env:CI_PROJECT_DIR/clone_manifest_ref.py
952     - python clone_manifest_ref.py --manifest manifest.xml --project gst-build --destination $env:CI_PROJECT_DIR/gst-build
953     - cd $env:CI_PROJECT_DIR/gst-build
954
955     - cp -r C:\subprojects\* subprojects\
956
957     # Run the git-update script and feed it the manifest to setup the environment
958     - cd $env:CI_PROJECT_DIR/gst-build; python git-update --no-interaction --manifest=$env:CI_PROJECT_DIR/manifest.xml
959     # For some reason, options are separated by newline instead of space, so we
960     # have to replace them first.
961     - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
962     # Replace forward slashes with backwards so bash doesn't complain
963     - $env:_PROJECT_DIR = $env:CI_PROJECT_DIR.replace('\','/')
964     - C:\msys64\usr\bin\bash -c "cd $env:_PROJECT_DIR/gst-build &&
965         meson build $env:MESON_ARGS &&
966         ninja -C build"
967
968
969 # Template for Cerbero GStreamer Deps
970 #
971 # This template is used by cerbero/ project to pre-built the GStreamer
972 # dependencies. When available, the .cerbero jobs will download this artifact
973 # in order to speed up the build.
974 #
975 # Parameters:
976 # CONFIG: The name of the configuration file to use
977 # ARCH: The cerbero <os>_<cpu> (used in cache key)
978 #
979 # Produce an artifact with the dist/ and .cache along
980 # with the associated build-tools.
981 .cerbero deps:
982   extends: .cerbero
983   rules:
984     - if: '$CI_PROJECT_NAME == "cerbero"'
985   script:
986     - ./cerbero_setup.sh cerbero_deps_script
987
988 #
989 # Cerbero Linux X86_64 build
990 #
991 cerbero deps fedora x86_64:
992   extends: '.cerbero deps'
993   variables:
994     CONFIG: "linux.config"
995     ARCH: "linux_x86_64"
996
997 build cerbero fedora x86_64:
998   extends: '.cerbero'
999   rules:
1000     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-omx|gstreamer-vaapi|gst-docs|gst-integration-testsuites|gst-plugins-rs)$/'
1001   variables:
1002     CONFIG: "linux.config"
1003
1004 #
1005 # Cerbero Android Universal build
1006 #
1007 .cerbero cross-android universal:
1008   variables:
1009     CONFIG: "cross-android-universal.cbc"
1010     ARCH: "android_universal"
1011   artifacts:
1012     name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
1013     expire_in: '5 days'
1014     when: 'always'
1015     paths:
1016       - "manifest.xml"
1017       - "${CERBERO_HOME}/logs"
1018       - "*[0-9].tar.*"
1019
1020 cerbero deps cross-android universal:
1021   extends:
1022     - '.cerbero deps'
1023     - '.cerbero cross-android universal'
1024
1025 build cerbero cross-android universal:
1026   extends:
1027     - '.cerbero'
1028     - '.cerbero cross-android universal'
1029   rules:
1030     - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_NAME == "gst-docs"'
1031     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gstreamer-vaapi|gst-integration-testsuites|gst-plugins-rs)$/'
1032
1033 #
1034 # Cerbero Cross Windows builds
1035 #
1036 cerbero deps cross-windows x86:
1037   extends: '.cerbero deps'
1038   variables:
1039     CONFIG: "cross-win32.cbc"
1040     ARCH: "mingw_x86"
1041
1042 build cerbero cross win32:
1043   extends: '.cerbero'
1044   rules:
1045     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gstreamer-vaapi|gst-docs|gst-integration-testsuites|gst-plugins-rs)$/'
1046   variables:
1047     CONFIG: "cross-win32.cbc"
1048     CERBERO_RUN_WRAPPER: "wine"
1049     CERBERO_RUN_SUFFIX: ".exe"
1050
1051
1052 cerbero deps cross-windows x86_64:
1053   extends: '.cerbero deps'
1054   variables:
1055     CONFIG: "cross-win64.cbc"
1056     ARCH: "mingw_x86_64"
1057
1058 build cerbero cross win64:
1059   extends: '.cerbero'
1060   rules:
1061     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-omx|gstreamer-vaapi|gst-docs|gst-integration-testsuites|gst-plugins-rs)$/'
1062   variables:
1063     CONFIG: "cross-win64.cbc"
1064     CERBERO_RUN_WRAPPER: "wine"
1065     CERBERO_RUN_SUFFIX: ".exe"
1066
1067 #
1068 # Build an Android App using the android binaries
1069 #
1070 .cross-android universal examples:
1071   image: $ANDROID_IMAGE
1072   stage: 'integrate'
1073   variables:
1074     EXAMPLES_HOME: ${CI_PROJECT_DIR}/examples
1075     GSTREAMER_ROOT_ANDROID: ${CI_PROJECT_DIR}/examples/cerbero-android-universal
1076   script:
1077     - mkdir -p ${EXAMPLES_HOME}/outputs
1078     - curl -L -o clone_manifest_ref.py https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/gitlab/clone_manifest_ref.py
1079     - chmod +x clone_manifest_ref.py
1080     - ./clone_manifest_ref.py --manifest manifest.xml --project gst-examples --destination ${EXAMPLES_HOME}/gst-examples
1081     - ./clone_manifest_ref.py --manifest manifest.xml --project gst-docs --destination ${EXAMPLES_HOME}/gst-docs
1082     - rm clone_manifest_ref.py
1083
1084     # extract our binaries
1085     - rm -f gstreamer-1.0-android-universal-*-runtime.tar.*
1086     - mkdir ${GSTREAMER_ROOT_ANDROID}
1087     - time tar -C ${GSTREAMER_ROOT_ANDROID} -xf gstreamer-1.0-android-universal-*.tar.*
1088
1089     # gst-examples - player
1090     - chmod +x ${EXAMPLES_HOME}/gst-examples/playback/player/android/gradlew
1091     - ${EXAMPLES_HOME}/gst-examples/playback/player/android/gradlew --no-daemon --project-dir ${EXAMPLES_HOME}/gst-examples/playback/player/android assembleDebug
1092     - cp ${EXAMPLES_HOME}/gst-examples/playback/player/android/app/build/outputs/apk/debug/*.apk ${EXAMPLES_HOME}/outputs/
1093
1094     # gst-examples - vulkan
1095     - chmod +x ${EXAMPLES_HOME}/gst-examples/vulkan/android/gradlew
1096     - ${EXAMPLES_HOME}/gst-examples/vulkan/android/gradlew --no-daemon --project-dir ${EXAMPLES_HOME}/gst-examples/vulkan/android assembleDebug
1097     - cp ${EXAMPLES_HOME}/gst-examples/vulkan/android/build/outputs/apk/debug/*.apk ${EXAMPLES_HOME}/outputs/
1098
1099     # gst-docs android tutorials
1100     - chmod +x ${EXAMPLES_HOME}/gst-docs/examples/tutorials/android/gradlew
1101     - ${EXAMPLES_HOME}/gst-docs/examples/tutorials/android/gradlew --no-daemon --project-dir ${EXAMPLES_HOME}/gst-docs/examples/tutorials/android assembleDebug
1102     - cp ${EXAMPLES_HOME}/gst-docs/examples/tutorials/android/android-tutorial-*/build/outputs/apk/debug/*.apk ${EXAMPLES_HOME}/outputs/
1103   after_script:
1104     - rm -rf ${GSTREAMER_ROOT_ANDROID}
1105     - rm -rf ${EXAMPLES_HOME}/gst-examples ${EXAMPLES_HOME}/gst-docs
1106   artifacts:
1107     name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
1108     expire_in: '5 days'
1109     when: 'always'
1110     paths:
1111       - "manifest.xml"
1112       - "${EXAMPLES_HOME}/outputs"
1113
1114 cross-android universal examples:
1115   extends: ".cross-android universal examples"
1116   rules:
1117     - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_NAME == "gst-docs"'
1118     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gstreamer-vaapi|gst-integration-testsuites|gst-plugins-rs)$/'
1119   needs:
1120     - "build cerbero cross-android universal"
1121
1122 cerbero cross-android universal examples:
1123   extends: ".cross-android universal examples"
1124   rules:
1125     - if: '$CI_PROJECT_NAME == "cerbero"'
1126   needs:
1127     - "cerbero deps cross-android universal"
1128
1129 #
1130 # Cerbero macOS X86_64 build
1131 #
1132 .cerbero macos x86_64:
1133   variables:
1134     ARCH: "darwin_x86_64"
1135     CONFIG: "osx-x86-64.cbc"
1136     CERBERO_PACKAGE_ARGS: ""
1137     HAVE_CCACHE: ""
1138     CERBERO_OVERRIDDEN_DIST_DIR: "/Library/Frameworks/GStreamer.framework/Versions/1.0"
1139     CERBERO_HOST_DIR: "/Users/gst-ci/cerbero/"
1140   tags:
1141     - gst-macos-11.1
1142   artifacts:
1143     name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
1144     expire_in: '5 days'
1145     when: 'always'
1146     paths:
1147       - "manifest.xml"
1148       - "${CERBERO_HOME}/logs"
1149       - "gstreamer-1.0-1.*.pkg"
1150       - "gstreamer-1.0-devel-1.*.pkg"
1151
1152 cerbero deps macos x86_64:
1153   extends:
1154     - '.cerbero deps'
1155     - '.cerbero macos x86_64'
1156
1157 build cerbero macos x86_64:
1158   extends:
1159     - '.cerbero'
1160     - '.cerbero macos x86_64'
1161   rules:
1162     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gst-sharp|gstreamer-vaapi|gst-integration-testsuites|gst-plugins-rs)$/'
1163
1164 #
1165 # Cerbero macOS Universal build
1166 #
1167 .cerbero cross-macos universal:
1168   variables:
1169     ARCH: "darwin_universal"
1170     CONFIG: "cross-macos-universal.cbc"
1171     CERBERO_PACKAGE_ARGS: ""
1172     HAVE_CCACHE: ""
1173     CERBERO_HOST_DIR: "/Users/gst-ci/cerbero/"
1174   tags:
1175     - gst-macos-11.1
1176   artifacts:
1177     name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
1178     expire_in: '5 days'
1179     when: 'always'
1180     paths:
1181       - "manifest.xml"
1182       - "${CERBERO_HOME}/logs"
1183       - "gstreamer-1.0-1.*.pkg"
1184       - "gstreamer-1.0-devel-1.*.pkg"
1185
1186 cerbero deps cross-macos universal:
1187   extends:
1188     - '.cerbero deps'
1189     - '.cerbero cross-macos universal'
1190
1191 build cerbero cross-macos universal:
1192   extends:
1193     - '.cerbero'
1194     - '.cerbero cross-macos universal'
1195   script:
1196     # We have build-tools that have fixed paths pointing to the upstream
1197     # repository.  We need to point
1198     - pwd
1199     - mkdir -p "../../gstreamer"
1200     - ln -sf "$(pwd)" "../../gstreamer/cerbero"
1201     - mkdir -p "../../${CI_PROJECT_NAMESPACE}"
1202     - ln -sf "$(pwd)" "../../${CI_PROJECT_NAMESPACE}/cerbero"
1203
1204     - ./cerbero_setup.sh cerbero_script
1205   rules:
1206     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gst-sharp|gstreamer-vaapi|gst-integration-testsuites|gst-plugins-rs)$/'
1207
1208 #
1209 # Cerbero iOS build
1210 #
1211 .cerbero cross-ios universal:
1212   variables:
1213     ARCH: "ios_universal"
1214     CONFIG: "cross-ios-universal.cbc"
1215     CERBERO_ARGS: "${DEFAULT_CERBERO_ARGS} -v nowerror"
1216     CERBERO_PACKAGE_ARGS: ""
1217     HAVE_CCACHE: ""
1218     CERBERO_HOST_DIR: "/Users/gst-ci/cerbero/"
1219   tags:
1220     - gst-ios-14.3
1221   artifacts:
1222     name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
1223     expire_in: '5 days'
1224     when: 'always'
1225     paths:
1226       - "manifest.xml"
1227       - "${CERBERO_HOME}/logs"
1228       - "gstreamer-1.0-*-ios-universal.pkg"
1229
1230 cerbero deps cross-ios universal:
1231   extends:
1232     - '.cerbero deps'
1233     - '.cerbero cross-ios universal'
1234
1235 build cerbero cross-ios universal:
1236   extends:
1237     - '.cerbero'
1238     - '.cerbero cross-ios universal'
1239   rules:
1240     - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_NAME == "gst-docs"'
1241     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gst-sharp|gstreamer-vaapi|gst-integration-testsuites|gst-plugins-rs)$/'
1242
1243 documentation:
1244   image: $FEDORA_DOCS_IMAGE
1245   extends:
1246     - '.gst_build_ccache_vars'
1247   rules:
1248     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-integration-testsuites|gst-plugins-rs|gst-python)$/'
1249   needs:
1250     - "manifest"
1251   stage: integrate
1252   variables:
1253     MESON_ARGS: *simple_build
1254     MESON_BUILDTYPE_ARGS: "-Ddoc=enabled"
1255     CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/"
1256   script:
1257   - pip3 install --upgrade hotdoc
1258
1259   # FIXME: remove this once the docs image is updated
1260   - pip3 install -U meson==0.56.2
1261
1262   - *gst_build
1263   - ./gst-uninstalled.py ninja -C build/ plugins_doc_caches
1264   - |
1265     python3 -c "import os, subprocess, sys
1266     subprojects = [os.environ['CI_PROJECT_NAME']]
1267     if subprojects[0]  in ['gst-ci', 'gst-build']:
1268         subprojects = ['gstreamer', 'gst-plugins-ugly', 'gst-omx', 'gst-plugins-good', 'gst-plugins-base', 'gstreamer-vaapi', 'gst-libav', 'gst-editing-services', 'gst-rtsp-server', 'gst-plugins-bad',]
1269
1270     diffsdir = '../plugins-cache-diffs'
1271     os.makedirs(diffsdir, exist_ok=True)
1272     res = 0
1273     for subproject in subprojects:
1274         cwd = os.path.join('subprojects', subproject)
1275         try:
1276             subprocess.check_call(['git', 'diff', '--quiet'], cwd=cwd)
1277         except subprocess.CalledProcessError:
1278             diffname = os.path.join(diffsdir, '%s_cache.diff' % subproject)
1279             res += 1
1280             with open(diffname, 'w') as diff:
1281                 subprocess.check_call(['git', 'diff'], stdout=diff, cwd=cwd)
1282                 print('\033[91mYou have a diff in the %s documentation cache. Please update with:\033[0m' % subproject)
1283                 print('     $ curl %s/%s | git apply -' % (os.environ['CI_ARTIFACTS_URL'], diffname.replace('../', '')))
1284     if res != 0:
1285         print('(note that it might take a few minutes for artefacts to be available on the server)\n')
1286         sys.exit(res)"
1287
1288   - ./gst-uninstalled.py hotdoc run --conf-file=build/subprojects/gst-docs/GStreamer-doc.json --fatal-warnings
1289   - cd -
1290   - mv gst-build/build/subprojects/gst-docs/GStreamer-doc/html documentation/
1291
1292   artifacts:
1293     when: always
1294     paths:
1295     - documentation/
1296     - plugins-cache-diffs/
1297
1298 #
1299 # Build an iOS App using the iOS binaries
1300 #
1301 .cross-ios universal examples:
1302   stage: 'integrate'
1303   variables:
1304     EXAMPLES_HOME: ${CI_PROJECT_DIR}/examples
1305     # disable codesigning so we don't need developer identities on the CI
1306     # machines
1307     XCODE_BUILD_ARGS: >
1308       CODE_SIGNING_REQUIRED="NO"
1309       CODE_SIGN_IDENTITY=""
1310       CODE_SIGNING_ALLOWED="NO"
1311       CODE_SIGN_ENTITLEMENTS=""
1312   script:
1313     # install the binaries
1314     - installer -pkg gstreamer-1.0-devel-*-ios-universal.pkg -target CurrentUserHomeDirectory -verbose
1315
1316     - curl -L -o clone_manifest_ref.py https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/${GST_UPSTREAM_BRANCH}/gitlab/clone_manifest_ref.py
1317     - chmod +x clone_manifest_ref.py
1318     - ./clone_manifest_ref.py --manifest manifest.xml --project gst-examples --destination ${EXAMPLES_HOME}/gst-examples
1319     - ./clone_manifest_ref.py --manifest manifest.xml --project gst-docs --destination ${EXAMPLES_HOME}/gst-docs
1320     - rm clone_manifest_ref.py
1321
1322     # dump some useful information
1323     - xcodebuild -version
1324     - xcodebuild -showsdks
1325
1326     # gst-docs ios tutorials
1327     - xcodebuild -showBuildSettings -alltargets -project ${EXAMPLES_HOME}/gst-docs/examples/tutorials/xcode\ iOS/GStreamer\ iOS\ Tutorials.xcodeproj
1328     - xcodebuild -alltargets -destination generic/platform=iOS -project ${EXAMPLES_HOME}/gst-docs/examples/tutorials/xcode\ iOS/GStreamer\ iOS\ Tutorials.xcodeproj ${XCODE_BUILD_ARGS}
1329
1330     # gst-examples
1331     - xcodebuild -showBuildSettings -alltargets -project ${EXAMPLES_HOME}/gst-examples/playback/player/ios/GstPlay.xcodeproj
1332     - xcodebuild -alltargets -destination generic/platform=iOS -project ${EXAMPLES_HOME}/gst-examples/playback/player/ios/GstPlay.xcodeproj ${XCODE_BUILD_ARGS}
1333   after_script:
1334     - rm -rf ${EXAMPLES_HOME}/gst-examples ${EXAMPLES_HOME}/gst-docs
1335   tags:
1336     - gst-ios-14.3
1337
1338 cross-ios universal examples:
1339   extends: ".cross-ios universal examples"
1340   rules:
1341     - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_NAME == "gst-docs"'
1342     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-docs|gst-omx|gstreamer-vaapi|gst-integration-testsuites|gst-plugins-rs)$/'
1343   needs:
1344     - "build cerbero cross-ios universal"
1345
1346 cerbero cross-ios universal examples:
1347   extends: ".cross-ios universal examples"
1348   rules:
1349     - if: '$CI_PROJECT_NAME == "cerbero"'
1350   needs:
1351     - "cerbero deps cross-ios universal"
1352
1353 build gst-omx zynq fedora x86_64:
1354   extends: '.build fedora x86_64'
1355   variables:
1356     MESON_ARGS: "-Domx=enabled -Dgst-omx:target=zynqultrascaleplus -Dgst-omx:header_path=${CI_PROJECT_DIR}/vcu-omx-il/omx_header -Dpython=disabled -Dlibav=disabled -Dlibnice=disabled -Dugly=disabled -Dbad=disabled -Ddevtools=disabled -Dges=disabled -Drtsp_server=disabled -Dvaapi=disabled -Dsharp=disabled -Dgst-examples=disabled -Drs=disabled ${MESON_BUILDTYPE_ARGS} $MESON_GST_WERROR"
1357   rules:
1358     - if: '$CI_PROJECT_NAME =~ /^(gst-omx|gst-ci)$/'
1359   before_script:
1360     - git clone https://github.com/Xilinx/vcu-omx-il.git --branch=release-2020.1 ${CI_PROJECT_DIR}/vcu-omx-il
1361
1362 build gst-omx tizonia fedora x86_64:
1363   extends: '.build fedora x86_64'
1364   variables:
1365     MESON_ARGS: "-Domx=enabled -Dgst-omx:target=tizonia -Dpython=disabled -Dlibav=disabled -Dlibnice=disabled -Dugly=disabled -Dbad=disabled -Ddevtools=disabled -Dges=disabled -Drtsp_server=disabled -Dvaapi=disabled -Dsharp=disabled -Dgst-examples=disabled -Drs=disabled ${MESON_BUILDTYPE_ARGS} $MESON_GST_WERROR"
1366     PKG_CONFIG_PATH: ${PKG_CONFIG_PATH}:${CI_PROJECT_DIR}/tizonia-install/lib64/pkgconfig/
1367   rules:
1368     - if: '$CI_PROJECT_NAME =~ /^(gst-omx|gst-ci)$/'
1369   before_script:
1370     - git clone https://github.com/tizonia/tizonia-openmax-il --branch v0.20.2
1371     - cd tizonia-openmax-il
1372     - meson build -Dclients=false -Dplugins='' -Dplayer=false -Dprefix=${CI_PROJECT_DIR}/tizonia-install
1373     - ninja -C build
1374     - ninja -C build install
1375     - cd ..
1376
1377 #
1378 # Cerbero Native Windows builds
1379 #
1380 .cerbero windows native:
1381   needs: ['manifest']
1382   image: $CERBERO_WINDOWS_IMAGE
1383   tags:
1384     - 'docker'
1385     - 'windows'
1386     - 'gstreamer-windows'
1387     - '1809'
1388   variables:
1389     CONFIG: 'win64.cbc'
1390     ARCH: 'msvc_x86_64'
1391     CERBERO_HOST_DIR: "C:/cerbero"
1392     CERBERO_ARGS: "${DEFAULT_CERBERO_ARGS} -v visualstudio -v nowerror"
1393     CERBERO_RUN_SUFFIX: ".exe"
1394     HAVE_CCACHE: ""
1395   before_script:
1396     - $env:CI_PROJECT_DIR = $env:CI_PROJECT_DIR.replace('\', '/')
1397     - $env:CERBERO_SCRIPTS_PATH = "$env:CI_PROJECT_DIR/cerbero_setup.sh"
1398     - echo "Fetching $env:CERBERO_SCRIPT_URL"
1399     - Invoke-WebRequest -Uri $env:CERBERO_SCRIPT_URL -OutFile $env:CERBERO_SCRIPTS_PATH
1400     - C:\MinGW\msys\1.0\bin\bash.exe --login -c "cd $env:CI_PROJECT_DIR && $env:CERBERO_SCRIPTS_PATH cerbero_before_script"
1401
1402 cerbero deps msvc x86_64:
1403   extends: ['.cerbero deps', '.cerbero windows native']
1404   script:
1405     - C:\MinGW\msys\1.0\bin\bash.exe --login -c "cd $env:CI_PROJECT_DIR && $env:CERBERO_SCRIPTS_PATH cerbero_deps_script"
1406
1407 build cerbero msvc x86_64:
1408   extends: ['.cerbero', '.cerbero windows native']
1409   script:
1410     - C:\MinGW\msys\1.0\bin\bash.exe --login -c "cd $env:CI_PROJECT_DIR && $env:CERBERO_SCRIPTS_PATH cerbero_script"
1411   rules:
1412     - if: '$CI_PROJECT_NAME !~ /^(cerbero|gst-build|gst-omx|gstreamer-vaapi|gst-docs|gst-integration-testsuites|gst-plugins-rs)$/'