ci: Move cargo invocations to shell scripts

And pass RUST_VERSION to the scripts too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2007>
This commit is contained in:
Sebastian Dröge 2024-12-23 11:44:48 +02:00
parent d79eac417d
commit f5a87faa87
4 changed files with 65 additions and 22 deletions

View file

@ -86,14 +86,20 @@ trigger:
.debian:12-stable:
extends: .debian:12
variables:
RUST_VERSION: '$GST_RS_STABLE'
image: "registry.freedesktop.org/gstreamer/gstreamer-rs/debian/bookworm-slim:$GST_RS_STABLE-$GST_RS_IMG_TAG"
.debian:12-msrv:
extends: .debian:12
variables:
RUST_VERSION: '$GST_RS_MSRV'
image: "registry.freedesktop.org/gstreamer/gstreamer-rs/debian/bookworm-slim:$GST_RS_MSRV-$GST_RS_IMG_TAG"
.debian:12-nightly:
extends: .debian:12
variables:
RUST_VERSION: 'nightly'
image: "registry.freedesktop.org/gstreamer/gstreamer-rs/debian/bookworm-slim:nightly-$GST_RS_IMG_TAG"
.cargo test:
@ -103,23 +109,7 @@ trigger:
CSOUND_LIB_DIR: '/usr/lib/x86_64-linux-gnu/'
RUST_BACKTRACE: 'full'
script:
- rustc --version
- CARGO_FLAGS="-j${FDO_CI_CONCURRENT:-$(nproc)} --locked --color=always --all --all-targets"
- new_report_dir="$CI_PROJECT_DIR/junit_reports"
- mkdir -p "$new_report_dir"
- cargo build $CARGO_FLAGS
- RUST_BACKTRACE=1 G_DEBUG=fatal_warnings cargo nextest run --profile=ci --no-tests=pass $CARGO_FLAGS
- mv "$CI_PROJECT_DIR/target/nextest/ci/junit.xml" "$new_report_dir/junit-tests-default.xml"
- cargo build $CARGO_FLAGS --all-features --exclude gst-plugin-gtk4
- RUST_BACKTRACE=1 G_DEBUG=fatal_warnings cargo nextest run --profile=ci --no-tests=pass $CARGO_FLAGS --all-features --exclude gst-plugin-gtk4
- mv "$CI_PROJECT_DIR/target/nextest/ci/junit.xml" "$new_report_dir/junit-tests-all.xml"
- cargo build $CARGO_FLAGS --no-default-features
- RUST_BACKTRACE=1 G_DEBUG=fatal_warnings cargo nextest run --profile=ci --no-tests=pass $CARGO_FLAGS --no-default-features
- mv "$CI_PROJECT_DIR/target/nextest/ci/junit.xml" "$new_report_dir/junit-tests-no-default.xml"
- ./ci/run-cargo-test.sh
artifacts:
reports:
junit: "junit_reports/*.xml"
@ -302,10 +292,14 @@ test windows msrv:
extends: '.msvc2019 build'
image: $WINDOWS_RUST_MINIMUM_IMAGE
when: 'manual'
variables:
RUST_VERSION: !reference [variables, "GST_RS_MSRV"]
test windows stable:
extends: '.msvc2019 build'
image: "$WINDOWS_RUST_STABLE_IMAGE"
variables:
RUST_VERSION: !reference [variables, "GST_RS_STABLE"]
rustfmt:
extends: '.debian:12-stable'
@ -351,13 +345,11 @@ clippy:
- "test stable"
stage: 'extras'
variables:
CLIPPY_LINTS: -D warnings -W unknown-lints
# csound-sys only looks at /usr/lib and /usr/local top levels
CSOUND_LIB_DIR: '/usr/lib/x86_64-linux-gnu/'
script:
- CARGO_FLAGS="-j${FDO_CI_CONCURRENT:-$(nproc)} --locked --color=always --all --all-targets"
- cargo clippy $CARGO_FLAGS -- -D warnings -A unknown-lints
- cargo clippy $CARGO_FLAGS --all-features --exclude gst-plugin-gtk4 -- -D warnings -A unknown-lints
- cargo clippy $CARGO_FLAGS --no-default-features -- -D warnings -A unknown-lints
- ./ci/run-clippy.sh
deny:
extends: .debian:12-stable

31
ci/run-cargo-test.sh Executable file
View file

@ -0,0 +1,31 @@
#! /bin/bash
set -ex
rustc --version
cargo --version
cpus=$(nproc || sysctl -n hw.ncpu)
CARGO_FLAGS="--color=always -j${FDO_CI_CONCURRENT:-$cpus}"
if [ "$RUST_VERSION" = "1.71.1" ]; then
CARGO_NEXTEST_FLAGS="--profile=ci"
else
CARGO_NEXTEST_FLAGS="--profile=ci --no-tests=pass"
fi
parent="${CI_PROJECT_DIR:-$(pwd)}"
new_report_dir="$parent/junit_reports"
mkdir -p "$new_report_dir"
for cfg in "",default "--all-features --exclude gst-plugin-gtk4",all "--no-default-features",no-default; do
IFS="," read cfg junit <<< "${cfg}"
echo "Building and testing with $cfg"
cargo build $CARGO_FLAGS --locked --all --all-targets $cfg
RUST_BACKTRACE=1 G_DEBUG=fatal_warnings cargo nextest run $CARGO_NEXTEST_FLAGS $CARGO_FLAGS --locked --all --all-targets $cfg
mv "$parent/target/nextest/ci/junit.xml" "$new_report_dir/junit-$junit.xml"
done

14
ci/run-clippy.sh Executable file
View file

@ -0,0 +1,14 @@
#! /bin/bash
set -ex
rustc --version
cargo --version
cargo clippy --version
cpus=$(nproc || sysctl -n hw.ncpu)
CARGO_FLAGS="--color=always -j${FDO_CI_CONCURRENT:-$cpus}"
for cfg in "" "--all-features --exclude gst-plugin-gtk4" "--no-default-features"; do
cargo clippy $CARGO_FLAGS --locked --all --all-targets $cfg -- $CLIPPY_LINTS
done

View file

@ -24,6 +24,12 @@ else
Write-Host "Build Jobs: $ncpus"
$cargo_opts = @("--color=always", "--jobs=$ncpus", "--all-targets")
if ("$env:RUST_VERSION" -eq "1.71.1") {
$cargo_nextest_opts=@("--profile=ci", "--no-fail-fast")
} else {
$cargo_nextest_opts=@("--profile=ci", "--no-fail-fast", "--no-tests=pass")
}
function Run-Tests {
param (
$Features
@ -48,7 +54,7 @@ function Run-Tests {
$env:G_DEBUG="fatal_warnings"
$env:RUST_BACKTRACE="1"
cargo nextest run $cargo_opts --profile=ci --no-tests=pass --no-fail-fast --workspace $local_exclude $Features
cargo nextest run $cargo_opts $cargo_nextest_opts --workspace $local_exclude $Features
if (!$?) {
Write-Host "Tests failed"
Exit 1