summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: e235934c597da0bfdb410919bdf82a9e4fe5a736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
include:
  - remote: "https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/14731f78c23c7b523a85a26a068ade9ac1ecd2f3/templates/fedora.yml"
  - remote: "https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/14731f78c23c7b523a85a26a068ade9ac1ecd2f3/templates/debian.yml"

stages:
  - 'trigger'
  - 'build docker'
  - 'preparation'
  - 'pre-build'
  - 'build'
  - 'test'
  # Use the resulting binaries
  - 'integrate'

variables:
  # Branch to track for modules that have no ref specified in the manifest
  GST_UPSTREAM_BRANCH: 'main'
  ORC_UPSTREAM_BRANCH: 'master'

  ###
  # IMPORTANT
  # These are the version tags for the docker images the CI runs against.
  # If you are hacking on them or need a them to rebuild, its enough
  # to change any part of the string of the image you want.
  ###
  FEDORA_TAG:  '2021-10-05.0'
  INDENT_TAG: '2021-10-04.0'
  WINDOWS_TAG: "2021-10-12.0"

  GST_UPSTREAM_REPO: 'gstreamer/gstreamer'
  FDO_UPSTREAM_REPO: 'gstreamer/gstreamer'

  FEDORA_AMD64_SUFFIX:  'amd64/fedora'
  INDENT_AMD64_SUFFIX: 'amd64/gst-indent'
  WINDOWS_AMD64_SUFFIX: 'amd64/windows'
  WINDOWS_RUST_AMD64_SUFFIX: 'amd64/windows-rust'

  FEDORA_DOCS_IMAGE: "registry.freedesktop.org/gstreamer/gst-ci/amd64/fedora:2020-07-03.0-master"
  WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
  WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"

  RUST_MINIMUM_VERSION: '1.54.0'
  RUST_LATEST_VERSION: '1.55.0'

  WINDOWS_RUST_MINIMUM_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_MINIMUM_VERSION"
  WINDOWS_RUST_MINIMUM_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_MINIMUM_VERSION"

  WINDOWS_RUST_LATEST_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_LATEST_VERSION"
  WINDOWS_RUST_LATEST_UPSTREAM_IMAGE: "$CI_REGISTRY/$GST_UPSTREAM_REPO/$WINDOWS_RUST_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH-rust-$RUST_LATEST_VERSION"

  MESON_BUILDTYPE_ARGS: --default-library=both
  DEFAULT_MESON_ARGS: >
    -Dlibnice:tests=disabled
    -Dlibnice:examples=disabled
    -Dopenh264:tests=disabled
    -Dpygobject:tests=false
    -Dpython=enabled
    -Dlibav=enabled
    -Dugly=enabled
    -Dbad=enabled
    -Ddevtools=enabled
    -Dges=enabled
    -Drtsp_server=enabled
    -Dvaapi=enabled
    -Dsharp=disabled

  MESON_GST_WERROR: >
    -Dgstreamer:werror=true
    -Dgst-plugins-base:werror=true
    -Dgst-plugins-good:werror=true
    -Dgst-plugins-ugly:werror=true
    -Dgst-plugins-bad:werror=true
    -Dgst-rtsp-server:werror=true
    -Dgst-libav:werror=true
    -Dgst-examples:werror=true
    -Dgst-editing-services:werror=true
    -Dgst-docs:werror=true
    -Dgst-omx:werror=true
    -Dgst-devtools:werror=true
    -Dgst-python:werror=true
    -Dgstreamer-vaapi:werror=true
    -Dgstreamer-sharp:werror=true

workflow:
  # https://docs.gitlab.com/ee/ci/yaml/index.html#switch-between-branch-pipelines-and-merge-request-pipelines
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
      when: never
    - if: '$CI_COMMIT_BRANCH'

#
# Global CI policy
#
# This can be used to configure global behaviour our our jobs.
#
default:
  retry:
    max: 2
    when:
      - 'runner_system_failure'
      - 'stuck_or_timeout_failure'
      - 'scheduler_failure'
      - 'api_failure'
  interruptible: true

# This is an empty job that is used to trigger the pipeline.
trigger:
  image: alpine:latest
  stage: 'trigger'
  script:
    - echo "Trigger job done, now running the pipeline."
  rules:
    # If the MR is assigned to the Merge bot, trigger the pipeline automatically
    - if: '$CI_MERGE_REQUEST_ASSIGNEES == "gstreamer-merge-bot"'
    # Alway run tests post merged
    - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
    # When the assignee isn't the merge bot, require an explicit action to trigger the pipeline
    # to avoid wasting CI resources
    - if: '$CI_MERGE_REQUEST_ASSIGNEES != "gstreamer-merge-bot"'
      when: 'manual'
      allow_failure: false

.fedora image:
  variables:
    FDO_DISTRIBUTION_VERSION: '31'
    FDO_REPO_SUFFIX: "$FEDORA_AMD64_SUFFIX"
    FDO_DISTRIBUTION_TAG: "$FEDORA_TAG-$GST_UPSTREAM_BRANCH"
    FDO_DISTRIBUTION_EXEC: 'DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH bash ci/docker/fedora/prepare.sh'

fedora amd64 docker:
  extends:
    - '.fedora image'
    - '.fdo.container-build@fedora'
  stage: 'build docker'
  needs:
    - "trigger"

.gst-indent image:
  variables:
    FDO_DISTRIBUTION_VERSION: 'stretch'
    FDO_REPO_SUFFIX: "$INDENT_AMD64_SUFFIX"
    FDO_DISTRIBUTION_TAG: "$INDENT_TAG-$GST_UPSTREAM_BRANCH"
    FDO_DISTRIBUTION_PACKAGES: 'curl indent git findutils'

gst-indent amd64 docker:
  extends:
    - '.gst-indent image'
    - '.fdo.container-build@debian'
  stage: 'build docker'
  # Do not depend on the trigger, as we want to run indent always
  needs: []

windows amd64 docker:
  stage: "build docker"
  needs:
    - "trigger"
  variables:
    # Unlike the buildah/linux jobs, this file
    # needs to be relative to docker/windows/ subdir
    # as it makes life easier in the powershell script
    #
    # We also don't need a CONTEXT_DIR var as its also
    # hardcoded to be docker/windows/
    DOCKERFILE: "ci/docker/windows/Dockerfile"
  tags:
    - windows
    - shell
    - "1809"
  script:
    # We need to pass an array and to resolve the env vars, so we can't use a variable:
    - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH")

    - "& ci/docker/windows/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE"
    - |
      if (!($?)) {
        echo "Failed to build the image"
        Exit 1
      }

.windows rust docker build:
  stage: 'build docker'
  needs:
    - job: 'windows amd64 docker'
      artifacts: false
  rules:
    - if: '$CI_PROJECT_NAME == "gst-ci"'
  variables:
    # Unlike the buildah/linux jobs, this file
    # needs to be relative to docker/windows/ subdir
    # as it makes life easier in the powershell script
    #
    # We also don't need a CONTEXT_DIR var as its also
    # hardcoded to be docker/windows/
    DOCKERFILE: 'docker/windows/rust.Dockerfile'
  tags:
    - 'windows'
    - 'shell'
    - '1809'
  script:
    # We need to pass an array and to resolve the env vars, so we can't use a variable:
    - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH", "--build-arg", "BASE_IMAGE=$WINDOWS_IMAGE", "--build-arg", "RUST_VERSION=$RUST_VERSION")

    - $env:WINDOWS_CONTAINER_SCRIPT_PATH = "$env:CI_PROJECT_DIR\container.ps1"
    - echo "Fetching $env:WINDOWS_CONTAINER_SCRIPT_URL"
    - Invoke-WebRequest -Uri $env:WINDOWS_CONTAINER_SCRIPT_URL -OutFile $env:WINDOWS_CONTAINER_SCRIPT_PATH

    - "& $env:WINDOWS_CONTAINER_SCRIPT_PATH $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $RUST_IMAGE $RUST_UPSTREAM_IMAGE $DOCKERFILE"
    - |
      if (!($?)) {
        echo "Failed to build the image"
        Exit 1
      }

windows rust amd64 docker latest stable:
  extends: '.windows rust docker build'
  variables:
    RUST_IMAGE: !reference [variables, "WINDOWS_RUST_LATEST_IMAGE"]
    RUST_UPSTREAM_IMAGE: !reference [variables, "WINDOWS_RUST_LATEST_UPSTREAM_IMAGE"]
    RUST_VERSION: !reference [variables, "RUST_LATEST_VERSION"]

windows rust amd64 docker minimum supported version:
  extends: '.windows rust docker build'
  variables:
    RUST_IMAGE: !reference [variables, "WINDOWS_RUST_MINIMUM_IMAGE"]
    RUST_UPSTREAM_IMAGE: !reference [variables, "WINDOWS_RUST_MINIMUM_UPSTREAM_IMAGE"]
    RUST_VERSION: !reference [variables, "RUST_MINIMUM_VERSION"]



# ---- Preparation ----- #
#
# gst-indent!!
#
gst indent:
  extends:
    - '.gst-indent image'
    - '.fdo.suffixed-image@debian'
  stage: 'preparation'
  needs:
    - job: 'gst-indent amd64 docker'
      artifacts: false
  script:
    # man indent. grep RETURN VALUE, grab a beer on my behalf...
    - indent --version || true
    - ./scripts/gst-indent-all
    - |
      if git diff --quiet -- ':!subprojects/gst-integration-testsuites/medias' .; then
          echo "Code is properly formatted"
      else
          git diff --color=always -- ':!subprojects/gst-integration-testsuites/medias' .
          echo 'style diverges, please run gst-indent first'
          exit 1
      fi

#
# build setup templates
#
.build_template: &build
  - echo $MESON_ARGS

  - meson build/ $MESON_ARGS
  - ninja -C build/
  - ccache --show-stats

.build_ccache_vars:
  variables:
    CCACHE_COMPILERCHECK: 'content'
    CCACHE_COMPRESS: 'true'
    CCACHE_BASEDIR: '/cache/gstreamer/gstreamer'
    CCACHE_DIR: '/cache/gstreamer/gstreamer/ccache/'
    # shared across everything really
    CCACHE_MAXSIZE: '10G'
    CARGO_HOME: '/cache/gstreamer/cargo'

.base_modules_changes: &modules_changes
  - .gitlab-ci.yml
  - meson.build
  - subprojects/*.wrap
  - subprojects/gst-devtools/**/*
  - subprojects/gst-editing-services/**/*
  - subprojects/gst-integration-testsuites/**/*
  - subprojects/gst-libav/**/*
  - subprojects/gst-omx/**/*
  - subprojects/gst-plugins-bad/**/*
  - subprojects/gst-plugins-base/**/*
  - subprojects/gst-plugins-good/**/*
  - subprojects/gst-plugins-ugly/**/*
  - subprojects/gst-python/**/*
  - subprojects/gstreamer/**/*
  - subprojects/gstreamer-sharp/**/*
  - subprojects/gstreamer-vaapi/**/*
  - subprojects/gst-rtsp-server/**/*

.simple_fedora_build: &simple_build >-
  ${DEFAULT_MESON_ARGS}
  -Dsharp=enabled
  -Domx=enabled
  -Dgst-omx:target=generic
  -Ddoc=disabled
  -Drs=disabled
  ${MESON_BUILDTYPE_ARGS}
  ${MESON_GST_WERROR}

.build:
  stage: 'build'
  extends:
    - '.build_ccache_vars'
  needs:
    - "trigger"
  # Taking into account the slowest shared runner + time needed to upload the binaries to artifacts
  # Also need to take into account I/O of pulling docker images and uploading artifacts
  timeout: '45min'
  variables:
    MESON_ARGS: "${DEFAULT_MESON_ARGS} ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"
  before_script:
    - export RUSTUP_HOME="/usr/local/rustup"
    - export CARGO_HOME="/usr/local/cargo"
    - export PATH="/usr/local/cargo/bin:$PATH"

    - ci/scripts/handle-subprojects-cache.py subprojects/
    # Update subprojects to respect `.wrap` content
    - meson subprojects update --reset
  script:
    *build
  after_script:
    - mv build/meson-logs/ meson-logs
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - 'meson-logs/'

.build fedora x86_64:
  extends:
    - '.fedora image'
    - '.fdo.suffixed-image@fedora'
    - '.build'
  needs:
    - "fedora amd64 docker"
  variables:
    MESON_ARGS: *simple_build
  rules:
    # If this matches, it means the pipeline is running against either the main
    # or a stable branch, so make it manual
    - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
      when: manual
    - changes:
        *modules_changes

build nodebug fedora x86_64:
  extends:
    - '.fedora image'
    - '.fdo.suffixed-image@fedora'
    - '.build'
  needs:
    - "fedora amd64 docker"
  variables:
    MESON_ARGS: "${DEFAULT_MESON_ARGS} -Dsharp=enabled -Dgstreamer:gst_debug=false -Domx=enabled -Dgst-omx:target=generic ${MESON_BUILDTYPE_ARGS} ${MESON_GST_WERROR}"

build static fedora x86_64:
  extends: '.build fedora x86_64'
  variables:
    MESON_BUILDTYPE_ARGS: "--default-library=static -Dintrospection=disabled -Ddoc=disabled"

build static nodebug fedora x86_64:
  extends: 'build nodebug fedora x86_64'
  variables:
    MESON_BUILDTYPE_ARGS: "--default-library=static -Dintrospection=disabled -Ddoc=disabled"

build clang fedora x86_64:
  extends: '.build fedora x86_64'
  variables:
    CC: 'ccache clang'
    CXX: 'ccache clang++'

.build windows:
  image: $WINDOWS_IMAGE
  stage: 'build'
  tags:
    - 'docker'
    - 'windows'
    - '1809'
  needs:
    - "windows amd64 docker"
  timeout: '45min'
  variables:
    MESON_ARGS: >
      ${DEFAULT_MESON_ARGS}
      -Dpython=disabled
      -Dlibav=disabled
      -Dvaapi=disabled
      -Dgst-plugins-base:pango=enabled
      -Dgst-plugins-good:cairo=enabled
  rules:
    # If this matches, it means the pipeline is running against either the main
    # or a stable branch, so make it manual
    - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
      when: manual
    - changes:
        *modules_changes
  before_script:
    - ci/scripts/handle-subprojects-cache.py subprojects/
  script:
    # For some reason, options are separated by newline instead of space, so we
    # have to replace them first.
    - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
    - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
        meson build $env:MESON_ARGS &&
        ninja -C build"
  # XXX: Re-enable when uploading stops timing out
  #artifacts:
  #  expire_in: "7 days"
  #  when: "always"
  #  paths:
  #    - 'build/meson-logs/'

build vs2017 amd64:
  extends: '.build windows'
  variables:
    ARCH: 'amd64'

build vs2017 x86:
  extends: '.build windows'
  variables:
    ARCH: 'x86'

build msys2 :
  extends: '.build windows'
  timeout: '60min'
  rules:
    - changes:
        *modules_changes
      allow_failure: true
      when: 'manual'
  script:
    # Make sure powershell exists on errors
    # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6
    - $ErrorActionPreference = "Stop"

    # Configure MSYS2 to use the UCRT64 environment, start in the same directory
    # and inherit PATH
    - $env:MSYSTEM = "UCRT64"
    - $env:CHERE_INVOKING = "1"
    - $env:MSYS2_PATH_TYPE = "inherit"
    # For some reason, options are separated by newline instead of space, so we
    # have to replace them first.
    - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
    # Replace forward slashes with backwards so bash doesn't complain
    - $env:_PROJECT_DIR = $env:CI_PROJECT_DIR.replace('\','/')
    - C:\msys64\usr\bin\bash -lc "meson build $env:MESON_ARGS && ninja -C build"

# ---- Tests ----- #

.test:
  stage: 'test'
  extends:
    - '.build_ccache_vars'
  needs:
    - "trigger"
  variables:
    MESON_ARGS: *simple_build

    # Disable colored output to avoid weird rendering issues
    GST_DEBUG_NO_COLOR: "true"
    CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/validate-logs/"
    GST_VALIDATE_LAUNCHER_FORCE_COLORS: "true"
    TIMEOUT_FACTOR: "2"
    CARGO_HOME: "/cache/gstreamer/cargo"
    # Enable the fault handler so we get backtraces on segfaults.
    # any non-empty string will do
    PYTHONFAULTHANDLER: "enabled"
  rules:
    - changes:
        *modules_changes
  script:
    - *build

    - echo "-> Running ${TEST_SUITE}"
    - >
      ./gst-env.py
      gst-validate-launcher ${TEST_SUITE}
      --check-bugs
      --dump-on-failure
      --mute
      --shuffle
      --no-display
      --meson-no-rebuild
      --timeout-factor "${TIMEOUT_FACTOR}"
      --fail-on-testlist-change
      -l "${CI_PROJECT_DIR}/validate-logs/"
      --xunit-file "${CI_PROJECT_DIR}/validate-logs/xunit.xml"
      ${EXTRA_VALIDATE_ARGS}
  after_script:
    - mv build/meson-logs/ meson-logs
  artifacts:
    expire_in: '14 days'
    when: always
    paths:
      - 'meson-logs/'
      - 'validate-logs'
    reports:
      junit:
        - "validate-logs/*.xml"

.test fedora x86_64:
  extends:
    - '.fedora image'
    - '.fdo.suffixed-image@fedora'
    - '.test'
  needs:
    - "fedora amd64 docker"
  tags: ['gstreamer']

check fedora:
  extends: '.test fedora x86_64'
  variables:
    TEST_SUITE: "check.gst*"

integration testsuites fedora:
  extends: '.test fedora x86_64'
  parallel: 4
  variables:
    EXTRA_VALIDATE_ARGS: "--timeout-factor=2 --retry-on-failures --parts=${CI_NODE_TOTAL} --part-index=${CI_NODE_INDEX} --sync"
    TEST_SUITE: "validate ges"

# gstreamer-full:
# introspection has been disabled as the static build does not support it.
# See https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/162
gstreamer-full:
  extends: 'build static fedora x86_64'
  stage: integrate
  variables:
    MESON_ARGS: >
      --default-library=static
      -Dintrospection=disabled
      $MESON_GST_WERROR
  rules:
    # If this matches, it means the pipeline is running against either the main
    # or a stable branch, so make it manual
    - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
      when: manual
    - changes:
      - "*"
      - scripts/*
      - ci/**/*

  script:
  - *build
  - meson test -C build -v test-gst-full
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - 'meson-logs/'

gstreamer-full-minimal:
  extends: 'build static fedora x86_64'
  stage: integrate
  variables:
    MESON_ARGS: >
      --default-library=static
      -Dauto_features=disabled
      -Dgstreamer:check=enabled
      -Dtests=enabled
      -Dgst-plugins-base:alsa=enabled
      -Dgst-plugins-base:typefind=enabled
      -Dgst-plugins-base:pbtypes=enabled
      -Dgst-full-elements=coreelements:filesrc,fakesink,identity,input-selector
      -Dgst-full-typefind-functions=typefindfunctions:wav,flv
      -Dgst-full-device-providers=alsa:alsadeviceprovider
      -Dgst-full-dynamic-types=pbtypes:video_multiview_flagset
      $MESON_GST_WERROR

  script:
  - *build
  - meson test -C build -v test-gst-full
  - 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"
  - strip build/libgstreamer-full-1.0.so
  - ls -l build/libgstreamer-full-1.0.so
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - 'meson-logs/'

# Valgrind
.valgrind fedora x86_64:
  extends: '.test fedora x86_64'
  stage: 'test'
  variables:
    EXTRA_VALIDATE_ARGS: "--valgrind"

valgrind core:
  extends: '.valgrind fedora x86_64'
  parallel: 2
  variables:
    TEST_SUITE: "check.gstreamer\\..*"
    EXTRA_VALIDATE_ARGS: "--valgrind --parts=${CI_NODE_TOTAL} --part-index=${CI_NODE_INDEX}"
  rules:
    - changes:
      - "*"
      - scripts/*
      - ci/**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gstreamer/**/*

valgrind base:
  extends: '.valgrind fedora x86_64'
  parallel: 4
  variables:
    TEST_SUITE: "check.gst-plugins-base\\..*"
    EXTRA_VALIDATE_ARGS: "--valgrind --parts=${CI_NODE_TOTAL} --part-index=${CI_NODE_INDEX}"
  rules:
    - changes:
      - "*"
      - scripts/*
      - ci//**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gst-plugins-base/**/*

valgrind good:
  extends: '.valgrind fedora x86_64'
  variables:
    TEST_SUITE: "check.gst-plugins-good\\..*"
    # take longer time due to splitmux unit test
    TIMEOUT_FACTOR: "4"
  rules:
    - changes:
      - "*"
      - scripts/*
      - ci/**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gst-plugins-base/**/*
      - subprojects/gst-plugins-good/**/*

valgrind ugly:
  extends: '.valgrind fedora x86_64'
  variables:
    TEST_SUITE: "check.gst-plugins-ugly\\..*"
  rules:
    - changes:
      - "*"
      - scripts/*
      - ci/**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gst-plugins-base/**/*
      - subprojects/gst-plugins-good/**/*
      - subprojects/gst-plugins-ugly/**/*

valgrind bad:
  extends: '.valgrind fedora x86_64'
  variables:
    TEST_SUITE: "check.gst-plugins-bad\\..*"
  rules:
    - changes:
      - "*"
      - scripts/*
      - ci/**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gst-plugins-base/**/*
      - subprojects/gst-plugins-good/**/*
      - subprojects/gst-plugins-bad/**/*

valgrind ges:
  extends: '.valgrind fedora x86_64'
  variables:
    TEST_SUITE: "check.gst-editing-services\\..*"
  rules:
    - changes:
      - "*"
      - scripts/*
      - ci/**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gst-plugins-base/**/*
      - subprojects/gst-plugins-good/**/*
      - subprojects/gst-plugins-bad/**/*
      - subprojects/gst-editing-services/**/*

# ---- Integration ----- #

.documentation:
  image: $FEDORA_DOCS_IMAGE
  extends:
    - '.build_ccache_vars'
  variables:
    MESON_ARGS: *simple_build
    MESON_BUILDTYPE_ARGS: "-Ddoc=enabled"
    CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/"
  script:
  - pip3 install --upgrade hotdoc
  - *build
  - ./gst-env.py ninja -C build/ plugins_doc_caches
  - ./ci/scripts/check-documentation-diff.py
  - ./gst-env.py hotdoc run --conf-file=build/subprojects/gst-docs/GStreamer-doc.json --fatal-warnings
  - mv build/subprojects/gst-docs/GStreamer-doc/html documentation/

  artifacts:
    when: always
    expire_in: "7 days"
    paths:
    - documentation/
    - plugins-cache-diffs/

#
# This jobs runs in gsrtreamer namespace when after the merge into main branch.
# The produced artifact is later used to automatically update the web page.
#
documentation:
  stage: integrate
  extends:
    - '.documentation'
  needs: []
  rules:
    - if: '$CI_PROJECT_NAMESPACE == "gstreamer" && $CI_COMMIT_BRANCH == "main"'

#
# This job is run in users namespace to validate documentation before merging
# MR.
#
build documentation:
  extends:
    - '.documentation'
  stage: build
  needs:
    - "trigger"
  rules:
    - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
      when: never
    - changes:
      - .gitlab-ci.yml
      - ci/gitlab/freedesktop_doc_importer.sh
      - subprojects/*.wrap
      - subprojects/gst-docs/**/*
      - subprojects/gst-devtools/**/*
      - subprojects/gst-editing-services/**/*
      - subprojects/gst-libav/**/*
      - subprojects/gst-omx/**/*
      - subprojects/gst-plugins-bad/**/*
      - subprojects/gst-plugins-base/**/*
      - subprojects/gst-plugins-good/**/*
      - subprojects/gst-plugins-ugly/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gstreamer-vaapi/**/*
      - subprojects/gst-rtsp-server/**/*

# FIXME: Using trigger: causes permission issues, workaround using old REST API.
# https://gitlab.com/gitlab-org/gitlab/-/issues/341737
cerbero trigger:
  stage: build
  extends:
    - '.fedora image'
    - '.fdo.suffixed-image@fedora'
  needs:
    - "fedora amd64 docker"
  script:
    - ci/gitlab/trigger_cerbero_pipeline.py

  rules:
    - if: '$CI_COMMIT_BRANCH == $GST_UPSTREAM_BRANCH'
      when: never
    - changes:
      - .gitlab-ci.yml
      - ci/gitlab/trigger_cerbero_pipeline.py
      - subprojects/gst-devtools/**/*
      - subprojects/gst-editing-services/**/*
      - subprojects/gst-libav/**/*
      - subprojects/gst-plugins-bad/**/*
      - subprojects/gst-plugins-base/**/*
      - subprojects/gst-plugins-good/**/*
      - subprojects/gst-plugins-ugly/**/*
      - subprojects/gst-python/**/*
      - subprojects/gstreamer/**/*
      - subprojects/gst-rtsp-server/**/*
      - subprojects/gst-examples/**/*