gst-plugins-rs/.gitlab-ci.yml
Nirbheek Chauhan 8cdb30bd39 meson: Add options for all plugins
Required a slight rework of the build file, and how options are passed
to cargo_wrapper.py

Necessitated a bump of the required gstreamer version to 1.20, which
should be fine for the meson build since its primary function is to be
built as part of the gstreamer monorepo build to get a dev env.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1038>
2023-01-07 13:23:41 +02:00

459 lines
13 KiB
YAML

.templates_sha: &templates_sha 567700e483aabed992d0a4fea84994a0472deff6
include:
- project: 'freedesktop/ci-templates'
ref: *templates_sha
file: '/templates/debian.yml'
- project: 'gstreamer/gstreamer-rs'
ref: main
file: '/ci/images_template.yml'
- project: 'gstreamer/gstreamer'
ref: main
file: '/.gitlab-image-tags.yml'
variables:
FDO_UPSTREAM_REPO: gstreamer/gst-plugins-rs
# We use GStreamer image to build the documentation as it is the simplest way
# to ensure that we are testing against the same thing as GStreamer itself.
# The tag name is included above from the main repo.
GSTREAMER_DOC_IMAGE: "registry.freedesktop.org/gstreamer/gstreamer/amd64/fedora:$FEDORA_TAG-main"
WINDOWS_BASE: "registry.freedesktop.org/gstreamer/gstreamer-rs/windows"
WINDOWS_RUST_MINIMUM_IMAGE: "$WINDOWS_BASE:$GST_RS_IMG_TAG-main-$GST_RS_MSRV"
WINDOWS_RUST_STABLE_IMAGE: "$WINDOWS_BASE:$GST_RS_IMG_TAG-main-$GST_RS_STABLE"
workflow:
rules:
- if: $CI_MERGE_REQUEST_IID
# don't create a pipeline if its a commit pipeline, on a branch and that branch has
# open merge requests (bc we will get a MR build instead)
- if: $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
default:
interruptible: true
stages:
- "trigger"
- "prep"
- "lint"
- "test"
- "extras"
- "integration"
# This is an empty job that is used to trigger the pipeline.
trigger:
image: alpine:latest
stage: 'trigger'
variables:
GIT_STRATEGY: none
script:
- echo "Trigger job done, now running the pipeline."
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
# If the MR is assigned to the Merge bot, trigger the pipeline automatically
- if: '$CI_MERGE_REQUEST_ASSIGNEES == "gstreamer-merge-bot"'
# Require explicit action to trigger tests post merge
- if: '$CI_PROJECT_NAMESPACE == "gstreamer" && $CI_COMMIT_BRANCH == "main"'
when: 'manual'
# 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
.debian:11:
variables:
FDO_DISTRIBUTION_VERSION: 'bullseye-slim'
before_script:
- source ./ci/env.sh
- mkdir .cargo && echo -e "[net]\ngit-fetch-with-cli = true" > .cargo/config
.debian:11-stable:
extends: .debian:11
variables:
FDO_DISTRIBUTION_TAG: '$GST_RS_STABLE-${GST_RS_IMG_TAG}_2022-11-05.0'
FDO_BASE_IMAGE: "registry.freedesktop.org/gstreamer/gstreamer-rs/debian/bullseye-slim:$GST_RS_STABLE-$GST_RS_IMG_TAG"
.debian:11-msrv:
extends: .debian:11
variables:
FDO_DISTRIBUTION_TAG: '$GST_RS_MSRV-${GST_RS_IMG_TAG}_2022-11-05.0'
FDO_BASE_IMAGE: "registry.freedesktop.org/gstreamer/gstreamer-rs/debian/bullseye-slim:$GST_RS_MSRV-$GST_RS_IMG_TAG"
.debian:11-nightly:
extends: .debian:11
variables:
FDO_DISTRIBUTION_TAG: 'nightly-${GST_RS_IMG_TAG}_2022-11-05.0'
FDO_BASE_IMAGE: "registry.freedesktop.org/gstreamer/gstreamer-rs/debian/bullseye-slim:nightly-$GST_RS_IMG_TAG"
.build-debian-container:
extends:
- .fdo.container-build@debian
stage: prep
variables:
FDO_DISTRIBUTION_PACKAGES: "libcsound64-dev llvm clang nasm libsodium-dev libwebp-dev python3-pip"
FDO_DISTRIBUTION_EXEC: >-
bash ci/install-dav1d.sh &&
apt clean &&
bash ./ci/install-rust-ext.sh &&
pip install tomli
needs:
- "trigger"
rules:
- if: '$UPDATE_IMG == null'
build-stable:
extends:
- .build-debian-container
- .debian:11-stable
build-msrv:
extends:
- .build-debian-container
- .debian:11-msrv
build-nightly:
extends:
- .build-debian-container
- .debian:11-nightly
# Those jobs are triggered by gstreamer-rs when updating its images
update-stable:
extends: build-stable
rules:
- if: '$UPDATE_IMG == "stable"'
variables:
FDO_FORCE_REBUILD: 1
update-msrv:
extends: build-msrv
rules:
- if: '$UPDATE_IMG == "msrv"'
variables:
FDO_FORCE_REBUILD: 1
update-nightly:
extends: build-nightly
rules:
- if: '$UPDATE_IMG == "nightly"'
variables:
FDO_FORCE_REBUILD: 1
.dist-debian-container:
extends:
- .fdo.distribution-image@debian
variables:
SODIUM_USE_PKG_CONFIG: "true"
after_script:
- rm -rf target
.img-stable:
extends:
- .dist-debian-container
- .debian:11-stable
needs:
- job: 'build-stable'
optional: true
- job: 'update-stable'
optional: true
.img-msrv:
extends:
- .dist-debian-container
- .debian:11-msrv
needs:
- job: 'build-msrv'
optional: true
- job: 'update-msrv'
optional: true
.img-nightly:
extends:
- .dist-debian-container
- .debian:11-nightly
needs:
- job: 'build-nightly'
optional: true
- job: 'update-nightly'
optional: true
.cargo test:
stage: "test"
variables:
# csound-sys only looks at /usr/lib and /usr/local top levels
CSOUND_LIB_DIR: '/usr/lib/x86_64-linux-gnu/'
RUST_BACKTRACE: 'full'
script:
- rustc --version
- cargo build --locked --color=always --workspace --all-targets
- G_DEBUG=fatal_warnings cargo test --locked --color=always --workspace --all-targets
- cargo build --locked --color=always --workspace --all-targets --all-features
- G_DEBUG=fatal_warnings cargo test --locked --color=always --workspace --all-targets --all-features
- cargo build --locked --color=always --workspace --all-targets --no-default-features
- G_DEBUG=fatal_warnings cargo test --locked --color=always --workspace --all-targets --no-default-features
test msrv:
extends:
- '.cargo test'
- .img-msrv
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "msrv"'
test stable:
extends:
- '.cargo test'
- .img-stable
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"'
test nightly:
allow_failure: true
extends:
- '.cargo test'
- .img-nightly
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "nightly"'
.meson:
extends: .img-stable
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"'
variables:
# csound-sys only looks at /usr/lib and /usr/local top levels
CSOUND_LIB_DIR: '/usr/lib/x86_64-linux-gnu/'
meson shared:
extends: .meson
variables:
CI_ARTIFACTS_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/"
script:
- meson build --default-library=shared --prefix=$(pwd)/install
- ninja -C build install
- ./ci/check-installed.py install
- ninja -C build docs/gst_plugins_cache.json
- ci/check-documentation-diff.py
artifacts:
when: always
expire_in: "7 days"
paths:
- plugins-cache-diffs/
- 'build/meson-logs/'
meson static:
extends: .meson
script:
- meson build --default-library=static --prefix=$(pwd)/install -Dsodium-source=built-in
- ninja -C build install
- ./ci/generate-static-test.py test-static-link-all
- cd test-static-link-all
- PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)/../install/lib/x86_64-linux-gnu/pkgconfig meson build
- ninja -C build
- ./build/test-gst-static
artifacts:
when: always
expire_in: "7 days"
paths:
- 'build/meson-logs/'
# Check that the gstreamer documentation keeps working
documentation:
image: $GSTREAMER_DOC_IMAGE
stage: 'integration'
variables:
MESON_ARGS: >
-Ddoc=enabled
-Domx=disabled
-Dpython=disabled
-Dlibav=disabled
-Dlibnice=disabled
-Ddevtools=disabled
-Dges=disabled
-Dsharp=disabled
-Dgst-examples=disabled
-Drs=enabled
-Dgst-plugins-rs:sodium-source=system
-Dgst-docs:fatal_warnings=true
-Dorc=disabled
script:
- export PATH=/usr/local/cargo/bin/:/usr/local/bin/:$PATH
- export RUSTUP_HOME='/usr/local/rustup'
- P=$(pwd)
- cd ..
- rm -rf gstreamer
- git clone --depth 1 https://gitlab.freedesktop.org/gstreamer/gstreamer.git --branch main
- cd gstreamer
- ln -s $P subprojects/gst-plugins-rs
- meson build $MESON_ARGS
- ./gst-env.py ninja -C build subprojects/gst-docs/GStreamer-doc
- mv build/subprojects/gst-docs/GStreamer-doc/html $P/documentation/
artifacts:
expire_in: '7 days'
when: always
paths:
- documentation/
needs: []
rules:
# Run job if the MR is assigned to the Merge bot or it a post-merge pipeline on main branch
- if: '$CI_MERGE_REQUEST_ASSIGNEES == "gstreamer-merge-bot"'
when: 'always'
- if: '$CI_PROJECT_NAMESPACE == "gstreamer" && $CI_COMMIT_BRANCH == "main"'
when: 'always'
# Require explicit action to trigger otherwise
- if: '$CI_PROJECT_NAMESPACE != "gstreamer" || $CI_COMMIT_BRANCH != "main"'
when: 'manual'
# build gst-plugins-rs as a gst-build subproject
# Disabled because of https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/262
#gst-build:
# extends: .meson
# rules:
# - if: '$CI_PIPELINE_SOURCE == "schedule"'
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# when: 'manual'
# allow_failure: true
# variables:
# MESON_ARGS: >
# -Domx=disabled
# -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=enabled
# -Dgst-plugins-rs:sodium-source=system
# script:
# - P=$(pwd)
# - cd ..
# - rm -rf gstreamer
# - git clone --depth 1 https://gitlab.freedesktop.org/gstreamer/gstreamer.git --branch main
# - cd gstreamer
# - ln -s $P subprojects/gst-plugins-rs
# - meson build $MESON_ARGS
# - ninja -C build
# # Check static Rust plugins can be linked into gst-full
# - meson build-gst-full --default-library=static $MESON_ARGS
# - ninja -C build-gst-full
# - meson devenv -C build-gst-full ./gst-inspect-1.0 rsaudiofx
# artifacts:
# expire_in: '7 days'
# when: always
# paths:
# - 'build/meson-logs/'
# - 'build-gst-full/meson-logs/'
.msvc2019 build:
stage: 'test'
needs:
- 'trigger'
tags:
- 'docker'
- 'windows'
- '2022'
script:
# Set the code page to UTF-8
- chcp 65001
# We need to build each crate separately to choose that can build on windows
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 &&
powershell ./ci/run_windows_tests.ps1"
- |
if (!$?) {
Write-Host "Tests Failed!"
Exit 1
}
test windows msrv:
extends: '.msvc2019 build'
image: $WINDOWS_RUST_MINIMUM_IMAGE
when: 'manual'
test windows stable:
extends: '.msvc2019 build'
image: "$WINDOWS_RUST_STABLE_IMAGE"
rustfmt:
extends: .img-stable
stage: "lint"
rules:
- when: 'always'
script:
- cargo fmt --version
- cargo fmt -- --color=always --check
check commits:
extends: .img-stable
stage: "lint"
rules:
- when: 'always'
script:
- ci-fairy check-commits --textwidth 0 --no-signed-off-by
clippy:
extends: .img-stable
stage: 'extras'
variables:
# csound-sys only looks at /usr/lib and /usr/local top levels
CSOUND_LIB_DIR: '/usr/lib/x86_64-linux-gnu/'
rules:
- when: 'always'
script:
- cargo clippy --locked --color=always --all --all-features --all-targets -- -D warnings
deny:
extends: .img-stable
stage: 'extras'
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
script:
- cargo deny check
outdated:
extends: .img-stable
allow_failure: true
stage: 'extras'
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
script:
- cargo outdated --root-deps-only --exit-code 1 -v
coverage:
allow_failure: true
extends:
- .img-stable
stage: 'extras'
rules:
- when: 'always'
variables:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "gst-plugins-rs-%p-%m.profraw"
# csound-sys only looks at /usr/lib and /usr/local top levels
CSOUND_LIB_DIR: '/usr/lib/x86_64-linux-gnu/'
script:
- cargo test --locked --color=always --all --all-features
# generate html report
- grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --ignore "*target*" --ignore "*/build.rs" -o ./coverage/
# generate cobertura report for gitlab integration
- grcov . --binary-path ./target/debug/ -s . -t cobertura --branch --ignore-not-existing --ignore "*target*" --ignore "*/build.rs" -o coverage.xml
# output coverage summary for gitlab parsing.
# TODO: use grcov once https://github.com/mozilla/grcov/issues/556 is fixed
- grep "%" coverage/index.html | head -1 || true
artifacts:
paths:
- 'coverage'
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml