From 429962bdd7ed15ad4b6c52f3d0d5d7152111f69d Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 14 Apr 2020 14:10:42 +0200 Subject: [PATCH] ci: use fdo ci template Build our own images instead of manually installing everything we need for each job. This should hopefully speed up our ci and make it more robust. --- .gitlab-ci.yml | 175 +++++++++++++++++++++++++++++---------------- ci/env.sh | 9 +++ ci/install-gst.sh | 2 + ci/install-rust.sh | 24 +++++++ 4 files changed, 150 insertions(+), 60 deletions(-) create mode 100644 ci/env.sh create mode 100755 ci/install-gst.sh create mode 100755 ci/install-rust.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d98fae119..1d5d9d71c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,49 +1,117 @@ +# We use https://gitlab.freedesktop.org/freedesktop/ci-templates +# to build the images used by the ci. +# +# Here is how to properly update thoses image: +# - new Rust stable version: update FDO_DISTRIBUTION_TAG +# - add dependencies: update FDO_DISTRIBUTION_PACKAGES and update FDO_DISTRIBUTION_TAG +# - update GStreamer version: update the tag in ci/install-gst.sh and update FDO_DISTRIBUTION_TAG +# +# Updating FDO_DISTRIBUTION_TAG is done by either: +# - setting it to the current date and the version suffix to 0 +# - incrementing the version suffix +# +# After each update commit your changes and push to your personnal repo. +# After review and ci approval merge the branch as usual. +# +# Updating the nightly image should be done by simply running a scheduled ci +# pipeline on the upstream repo with the $UPDATE_NIGHTLY variable defined. + +.templates_sha: &templates_sha acda94e139030dc2caa058118956225e55bbec5f + +include: + - project: 'freedesktop/ci-templates' + ref: *templates_sha + file: '/templates/debian.yml' + +variables: + FDO_UPSTREAM_REPO: gstreamer/gstreamer-rs + stages: + - "prep" - "lint" - "test" - "extras" -.tarball_setup: +.debian:10: variables: + FDO_DISTRIBUTION_VERSION: 10 + FDO_DISTRIBUTION_TAG: '$RUST_VERSION-2020-04-16.0' # Only stuff inside the repo directory can be cached # Override the CARGO_HOME variable to force its location CARGO_HOME: "${CI_PROJECT_DIR}/.cargo_home" - DEPENDENCIES: | - curl - liborc-0.4-dev - libglib2.0-dev - libxml2-dev - libgtk-3-dev - libegl1-mesa - libgles2-mesa - libgl1-mesa-dri - libgl1-mesa-glx - libwayland-egl1-mesa - xz-utils - libssl-dev - git before_script: - - apt-get update -yqq - - apt-get install -yqq --no-install-recommends $DEPENDENCIES + - source ./ci/env.sh - - mkdir -p precompiled-gst && cd precompiled-gst +.debian:10-stable: + extends: .debian:10 + variables: + RUST_VERSION: "stable" - - curl -L https://people.freedesktop.org/~slomo/gstreamer-1.16.1.tar.xz | tar xJ - - sed -i "s;prefix=/root/gstreamer;prefix=$PWD/gstreamer;g" $PWD/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc - - export PKG_CONFIG_PATH=$PWD/gstreamer/lib/x86_64-linux-gnu/pkgconfig - - export GST_PLUGIN_SYSTEM_PATH=$PWD/gstreamer/lib/x86_64-linux-gnu/gstreamer-1.0 - - export GST_PLUGIN_SCANNER=$PWD/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner - - export PATH=$PATH:$PWD/gstreamer/bin - - export LD_LIBRARY_PATH=$PWD/gstreamer/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH +.debian:10-1-40: + extends: .debian:10 + variables: + RUST_VERSION: "1.40.0" - - cd "${CI_PROJECT_DIR}" +.debian:10-nightly: + extends: .debian:10 + variables: + RUST_VERSION: "nightly" + +.build-debian-container: + extends: + - .fdo.container-build@debian + stage: prep + variables: + FDO_DISTRIBUTION_PACKAGES: "build-essential curl liborc-0.4-dev libglib2.0-dev libxml2-dev libgtk-3-dev libegl1-mesa libgles2-mesa libgl1-mesa-dri libgl1-mesa-glx libwayland-egl1-mesa xz-utils libssl-dev git wget ca-certificates" + FDO_DISTRIBUTION_EXEC: 'bash ci/install-gst.sh && bash ci/install-rust.sh $RUST_VERSION' + +build-stable: + extends: + - .build-debian-container + - .debian:10-stable + +build-1-40: + extends: + - .build-debian-container + - .debian:10-1-40 + +build-nightly: + extends: + - .build-debian-container + - .debian:10-nightly + +update-nightly: + extends: build-nightly + only: + variables: + - $UPDATE_NIGHTLY == "1" + variables: + FDO_FORCE_REBUILD: 1 + +.dist-debian-container: + extends: + - .fdo.distribution-image@debian cache: key: "gst" paths: - "${CARGO_HOME}" +.img-stable: + extends: + - .dist-debian-container + - .debian:10-stable + +.img-1-40: + extends: + - .dist-debian-container + - .debian:10-1-40 + +.img-nightly: + extends: + - .dist-debian-container + - .debian:10-nightly + .cargo test: - extends: '.tarball_setup' stage: "test" script: - rustc --version @@ -77,55 +145,47 @@ stages: fi test 1.40: - # 1.40 img - # https://hub.docker.com/_/rust/ - image: "rust:1.40-slim-buster" - extends: '.cargo test' + extends: + - '.cargo test' + - .img-1-40 test stable: - # Stable img - # https://hub.docker.com/_/rust/ - image: "rust:slim-buster" - extends: '.cargo test' + extends: + - '.cargo test' + - .img-stable test stable all-features: - # Stable img - # https://hub.docker.com/_/rust/ - image: "rust:slim-buster" variables: ALL_FEATURES: 'yes' - extends: '.cargo test' + extends: + - '.cargo test' + - .img-stable test nightly: - # Nightly - # https://hub.docker.com/r/rustlang/rust/ - image: "rustlang/rust:nightly-buster-slim" allow_failure: true - extends: '.cargo test' + extends: + - '.cargo test' + - .img-nightly test nightly all-features: - # Nightly - # https://hub.docker.com/r/rustlang/rust/ - image: "rustlang/rust:nightly-buster-slim" allow_failure: true variables: ALL_FEATURES: 'yes' - extends: '.cargo test' + extends: + - '.cargo test' + - .img-nightly rustfmt: - image: "rust:slim-buster" + extends: .img-stable stage: "lint" script: - - rustup component add rustfmt - cargo fmt --version - cargo fmt -- --color=always --check clippy: - extends: '.tarball_setup' - image: "rust:slim-buster" + extends: .img-stable stage: 'extras' script: - - rustup component add clippy-preview - cargo clippy --version # Keep features in sync with above - | @@ -146,18 +206,15 @@ clippy: cargo clippy --color=always --manifest-path tutorials/Cargo.toml --all-targets --all-features -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless -A clippy::missing_safety_doc audit: - extends: '.tarball_setup' - image: "rust:slim-buster" + extends: .img-stable stage: 'extras' only: - schedules script: - - cargo install --force cargo-audit - cargo audit --deny-warnings gir-checks: - extends: '.tarball_setup' - image: "rust:slim-buster" + extends: .img-stable stage: 'extras' script: - git clone https://github.com/gtk-rs/checker @@ -189,12 +246,10 @@ gir-checks: done outdated: - extends: '.tarball_setup' - image: "rust:slim-buster" + extends: .img-stable allow_failure: true stage: 'extras' only: - schedules script: - - cargo install --force --git https://github.com/kbknapp/cargo-outdated - cargo outdated --root-deps-only --exit-code 1 -v diff --git a/ci/env.sh b/ci/env.sh new file mode 100644 index 000000000..be75077c8 --- /dev/null +++ b/ci/env.sh @@ -0,0 +1,9 @@ +export RUSTUP_HOME='/usr/local/rustup' +export CARGO_HOME='/usr/local/cargo' +export PATH=$PATH:/usr/local/cargo/bin + +export PKG_CONFIG_PATH=/usr/local/gstreamer/lib/x86_64-linux-gnu/pkgconfig +export GST_PLUGIN_SYSTEM_PATH=/usr/local/gstreamer/lib/x86_64-linux-gnu/gstreamer-1.0 +export GST_PLUGIN_SCANNER=/usr/local/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner +export PATH=$PATH:/usr/local/gstreamer/bin +export LD_LIBRARY_PATH=/usr/local/gstreamer/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH diff --git a/ci/install-gst.sh b/ci/install-gst.sh new file mode 100755 index 000000000..6875e4e0f --- /dev/null +++ b/ci/install-gst.sh @@ -0,0 +1,2 @@ +curl -L https://people.freedesktop.org/~slomo/gstreamer-1.16.1.tar.xz | tar xJC /usr/local +sed -i "s;prefix=/root/gstreamer;prefix=/usr/local/gstreamer;g" /usr/local/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc diff --git a/ci/install-rust.sh b/ci/install-rust.sh new file mode 100755 index 000000000..939c5bba2 --- /dev/null +++ b/ci/install-rust.sh @@ -0,0 +1,24 @@ +source ./ci/env.sh + +RUSTUP_VERSION=1.21.1 +RUST_VERSION=$1 +RUST_ARCH="x86_64-unknown-linux-gnu" + +RUSTUP_URL=https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$RUST_ARCH/rustup-init +wget $RUSTUP_URL + +chmod +x rustup-init; +./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; +rm rustup-init; +chmod -R a+w $RUSTUP_HOME $CARGO_HOME + +rustup --version +cargo --version +rustc --version + +if [ "$RUST_VERSION" = "stable" ]; then + rustup component add clippy-preview + rustup component add rustfmt + cargo install --force cargo-audit + cargo install --force --git https://github.com/kbknapp/cargo-outdated +fi