From dfc6344f5977423e7ccee6512e55b21e07601607 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 23 Dec 2022 21:11:37 +0200 Subject: [PATCH] ci: move tests scripts to individual files Instead of inling bash scripts in yaml Part-of: --- .gitlab-ci.yml | 118 +-------------------------------------- ci/run-cargo-test.sh | 43 ++++++++++++++ ci/run-clippy.sh | 37 ++++++++++++ ci/run-sys-cargo-test.sh | 53 ++++++++++++++++++ 4 files changed, 136 insertions(+), 115 deletions(-) create mode 100755 ci/run-cargo-test.sh create mode 100755 ci/run-clippy.sh create mode 100755 ci/run-sys-cargo-test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d27a10ee9..e2b21bd88 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -257,44 +257,7 @@ plugins-update-nightly: UPDATE_IMG: "nightly" .cargo_test_var: &cargo_test - - rustc --version - # First build and test all the crates with their relevant features - # Keep features in sync with below - - | - get_features() { - crate=$1 - case "$crate" in - gstreamer-audio|gstreamer-editing-services|gstreamer-gl|gstreamer-pbutils|gstreamer-rtp|gstreamer-rtsp|gstreamer-video|gstreamer) - echo "--features=serde,v1_22" - ;; - gstreamer-validate) - echo "" - ;; - *) - echo "--features=v1_22" - ;; - esac - } - for crate in gstreamer* gstreamer-gl/{egl,wayland,x11}; do - if [ -e $crate/Cargo.toml ]; then - if [ -n "$ALL_FEATURES" ]; then - FEATURES="$(get_features $crate)" - else - FEATURES="" - fi - - echo "Building and testing $crate with $FEATURES" - - cargo build --locked --color=always --manifest-path $crate/Cargo.toml $FEATURES - G_DEBUG=fatal_warnings cargo test --color=always --manifest-path $crate/Cargo.toml $FEATURES - fi - done - - - | - if [ -n "$EXAMPLES_TUTORIALS" ]; then - cargo build --locked --color=always --manifest-path examples/Cargo.toml --bins --examples --all-features - cargo build --locked --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features - fi + - ./ci/run-cargo-test.sh .cargo test: stage: "test" @@ -364,53 +327,7 @@ test nightly all-features: .cargo test sys: stage: "test" script: - - rustc --version - - | - get_features() { - module=${1%%/sys} - case "$module" in - gstreamer-validate) - echo "" - ;; - *) - echo "--features=v1_22" - ;; - esac - - } - # First build and test all the crates with their relevant features - # Keep features in sync with below - for crate in gstreamer*/sys gstreamer-gl/*/sys; do - if [ -e $crate/Cargo.toml ]; then - echo "Building $crate with $(get_features $crate)" - cargo build --locked --color=always --manifest-path $crate/Cargo.toml $(get_features $crate) - fi - done - # Run tests for crates we can currently run. - # Other tests are broken currently. - for crate in gstreamer/sys \ - gstreamer-app/sys \ - gstreamer-audio/sys \ - gstreamer-base/sys \ - gstreamer-check/sys \ - gstreamer-controller/sys \ - gstreamer-gl/sys \ - gstreamer-gl/egl/sys \ - gstreamer-gl/wayland/sys \ - gstreamer-gl/x11/sys \ - gstreamer-mpegts/sys \ - gstreamer-net/sys \ - gstreamer-pbutils/sys \ - gstreamer-player/sys \ - gstreamer-rtsp-server/sys \ - gstreamer-rtsp/sys \ - gstreamer-sdp/sys \ - gstreamer-tag/sys \ - gstreamer-video/sys \ - gstreamer-webrtc/sys; do - echo "Testing $crate with $(get_features $crate)" - cargo test --locked --color=always --manifest-path $crate/Cargo.toml $(get_features $crate) - done + - ./ci/run-sys-cargo-test.sh test stable sys: extends: @@ -472,36 +389,7 @@ clippy: - job: 'build-stable' artifacts: false script: - - cargo clippy --version - # Keep features in sync with above - - | - get_features() { - crate=$1 - case "$crate" in - gstreamer-audio|gstreamer-editing-services|gstreamer-gl|gstreamer-pbutils|gstreamer-rtp|gstreamer-rtsp|gstreamer-video|gstreamer) - echo "--features=serde,v1_22" - ;; - gstreamer-validate) - echo "" - ;; - *) - echo "--features=v1_22" - ;; - esac - } - for crate in gstreamer* gstreamer-gl/{egl,wayland,x11}; do - if [ -e $crate/Cargo.toml ]; then - FEATURES=$(get_features $crate) - - echo "Running clippy on $crate with $FEATURES" - - cargo clippy --locked --color=always --manifest-path $crate/Cargo.toml $FEATURES --all-targets -- $CLIPPY_LINTS - fi - done - # And also run over all the examples/tutorials - - | - cargo clippy --locked --color=always --manifest-path examples/Cargo.toml --all-targets --all-features -- $CLIPPY_LINTS - cargo clippy --locked --color=always --manifest-path tutorials/Cargo.toml --all-targets --all-features -- $CLIPPY_LINTS + - ./ci/run-clippy.sh deny: extends: .img-stable diff --git a/ci/run-cargo-test.sh b/ci/run-cargo-test.sh new file mode 100755 index 000000000..c7e5f7d5d --- /dev/null +++ b/ci/run-cargo-test.sh @@ -0,0 +1,43 @@ +#! /bin/bash + +set -ex + +rustc --version +cargo --version + +# First build and test all the crates with their relevant features +# Keep features in sync with the list below below +get_features() { + crate=$1 + case "$crate" in + gstreamer-audio|gstreamer-editing-services|gstreamer-gl|gstreamer-pbutils|gstreamer-rtp|gstreamer-rtsp|gstreamer-video|gstreamer) + echo "--features=serde,v1_22" + ;; + gstreamer-validate) + echo "" + ;; + *) + echo "--features=v1_22" + ;; + esac +} + +for crate in gstreamer* gstreamer-gl/{egl,wayland,x11}; do + if [ -e "$crate/Cargo.toml" ]; then + if [ -n "$ALL_FEATURES" ]; then + FEATURES=$(get_features "$crate") + else + FEATURES="" + fi + + echo "Building and testing $crate with $FEATURES" + + cargo build --locked --color=always --manifest-path "$crate/Cargo.toml" $FEATURES + G_DEBUG=fatal_warnings cargo test --color=always --manifest-path "$crate/Cargo.toml" $FEATURES + fi +done + +if [ -n "$EXAMPLES_TUTORIALS" ]; then + cargo build --locked --color=always --manifest-path examples/Cargo.toml --bins --examples --all-features + cargo build --locked --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features +fi diff --git a/ci/run-clippy.sh b/ci/run-clippy.sh new file mode 100755 index 000000000..3d78e0b4b --- /dev/null +++ b/ci/run-clippy.sh @@ -0,0 +1,37 @@ +#! /bin/bash + +set -ex + +rustc --version +cargo --version +cargo clippy --version + +# Keep features in sync with run-cargo-test.sh +get_features() { + crate=$1 + case "$crate" in + gstreamer-audio|gstreamer-editing-services|gstreamer-gl|gstreamer-pbutils|gstreamer-rtp|gstreamer-rtsp|gstreamer-video|gstreamer) + echo "--features=serde,v1_22" + ;; + gstreamer-validate) + echo "" + ;; + *) + echo "--features=v1_22" + ;; + esac +} + +for crate in gstreamer* gstreamer-gl/{egl,wayland,x11}; do + if [ -e "$crate/Cargo.toml" ]; then + FEATURES=$(get_features "$crate") + + echo "Running clippy on $crate with $FEATURES" + + cargo clippy --locked --color=always --manifest-path "$crate/Cargo.toml" $FEATURES --all-targets -- $CLIPPY_LINTS + fi +done + +# And also run over all the examples/tutorials +cargo clippy --locked --color=always --manifest-path examples/Cargo.toml --all-targets --all-features -- $CLIPPY_LINTS +cargo clippy --locked --color=always --manifest-path tutorials/Cargo.toml --all-targets --all-features -- $CLIPPY_LINTS diff --git a/ci/run-sys-cargo-test.sh b/ci/run-sys-cargo-test.sh new file mode 100755 index 000000000..3534a036c --- /dev/null +++ b/ci/run-sys-cargo-test.sh @@ -0,0 +1,53 @@ +#! /bin/bash + +set -ex + +rustc --version +cargo --version + +get_features() { + module=${1%%/sys} + case "$module" in + gstreamer-validate) + echo "" + ;; + *) + echo "--features=v1_22" + ;; + esac +} + +# First build and test all the crates with their relevant features +# Keep features in sync with below +for crate in gstreamer*/sys gstreamer-gl/*/sys; do + if [ -e "$crate/Cargo.toml" ]; then + echo "Building $crate with $(get_features "$crate")" + cargo build --locked --color=always --manifest-path "$crate/Cargo.toml" $(get_features "$crate") + fi +done + +# Run tests for crates we can currently run. +# Other tests are broken currently. +for crate in gstreamer/sys \ + gstreamer-app/sys \ + gstreamer-audio/sys \ + gstreamer-base/sys \ + gstreamer-check/sys \ + gstreamer-controller/sys \ + gstreamer-gl/sys \ + gstreamer-gl/egl/sys \ + gstreamer-gl/wayland/sys \ + gstreamer-gl/x11/sys \ + gstreamer-mpegts/sys \ + gstreamer-net/sys \ + gstreamer-pbutils/sys \ + gstreamer-player/sys \ + gstreamer-rtsp-server/sys \ + gstreamer-rtsp/sys \ + gstreamer-sdp/sys \ + gstreamer-tag/sys \ + gstreamer-video/sys \ + gstreamer-webrtc/sys; do + echo "Testing $crate with $(get_features $crate)" + cargo test --locked --color=always --manifest-path $crate/Cargo.toml "$(get_features $crate)" +done