.gitlab-ci.yml 4.73 KB
Newer Older
1
stages:
Jordan Petridis's avatar
Jordan Petridis committed
2
  - "lint"
3
  - "test"
Jordan Petridis's avatar
Jordan Petridis committed
4
  - "extras"
5

6
.tarball_setup:
7
  variables:
8 9 10
    # 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"
11 12
    DEPENDENCIES: |
      curl
13
      liborc-0.4-dev
14 15 16 17 18 19 20 21
      libglib2.0-dev
      libxml2-dev
      libgtk-3-dev
      libegl1-mesa
      libgles2-mesa
      libgl1-mesa-dri
      libgl1-mesa-glx
      libwayland-egl1-mesa
22
      xz-utils
Guillaume Desmottes's avatar
Guillaume Desmottes committed
23
      libssl-dev
24 25 26
  before_script:
    - apt-get update -yqq
    - apt-get install -yqq --no-install-recommends $DEPENDENCIES
Jordan Petridis's avatar
Jordan Petridis committed
27

28 29
    - mkdir -p precompiled-gst && cd precompiled-gst

30
    - curl -L https://people.freedesktop.org/~slomo/gstreamer-1.16.1.tar.xz | tar xJ
31 32 33 34 35 36
    - 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
37 38 39 40 41 42 43

    - cd "${CI_PROJECT_DIR}"
  cache:
    key: "gst"
    paths:
      - "${CARGO_HOME}"

44 45
.cargo test:
  extends: '.tarball_setup'
46
  stage: "test"
47 48
  script:
    - rustc --version
49 50 51 52 53 54
      # First build and test all the crates with their relevant features
      # Keep features in sync with below
    - |
      for crate in gstreamer*; do
        if [ -n "$ALL_FEATURES" ]; then
          if [ $crate = "gstreamer" ]; then
55
            FEATURES=ser_de,v1_16
56 57 58 59 60 61 62 63 64 65 66 67 68
          elif [ $crate = "gstreamer-gl" ]; then
            FEATURES=egl,x11,wayland,v1_16
          else
            FEATURES=v1_16
          fi

          cargo build --color=always --manifest-path $crate/Cargo.toml --features=$FEATURES
          G_DEBUG=fatal_warnings cargo test --color=always --manifest-path $crate/Cargo.toml --features=$FEATURES
        else
          cargo build --color=always --manifest-path $crate/Cargo.toml
          G_DEBUG=fatal_warnings cargo test --color=always --manifest-path $crate/Cargo.toml
        fi
      done
69

70 71
      # If we do a build with all features then also build the
      # tutorials/examples with all features
72
    - |
73
      if [ -n "$ALL_FEATURES" ]; then
74 75
        cargo build --color=always --manifest-path examples/Cargo.toml --bins --examples --all-features
        cargo build --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features
76
      fi
77

78 79
test 1.39:
  # 1.39 img
80
  # https://hub.docker.com/_/rust/
81
  image: "rust:1.39-slim-buster"
82
  extends: '.cargo test'
83 84

test stable:
85 86
  # Stable img
  # https://hub.docker.com/_/rust/
87
  image: "rust:slim-buster"
88 89 90
  extends: '.cargo test'

test stable all-features:
91 92
  # Stable img
  # https://hub.docker.com/_/rust/
93
  image: "rust:slim-buster"
94 95
  variables:
    ALL_FEATURES: 'yes'
96
  extends: '.cargo test'
97 98

test nightly:
99 100
  # Nightly
  # https://hub.docker.com/r/rustlang/rust/
101
  image: "rustlang/rust:nightly-buster-slim"
102 103 104 105
  allow_failure: true
  extends: '.cargo test'

test nightly all-features:
106 107
  # Nightly
  # https://hub.docker.com/r/rustlang/rust/
108
  image: "rustlang/rust:nightly-buster-slim"
109
  allow_failure: true
110
  variables:
111
    ALL_FEATURES: 'yes'
112
  extends: '.cargo test'
Jordan Petridis's avatar
Jordan Petridis committed
113 114

rustfmt:
115
  image: "rust:slim-buster"
Jordan Petridis's avatar
Jordan Petridis committed
116 117
  stage: "lint"
  script:
118
    - rustup component add rustfmt
Jordan Petridis's avatar
Jordan Petridis committed
119 120
    - cargo fmt --version
    - cargo fmt -- --color=always --check
Jordan Petridis's avatar
Jordan Petridis committed
121 122

clippy:
123
  extends: '.tarball_setup'
124
  image: "rust:slim-buster"
Jordan Petridis's avatar
Jordan Petridis committed
125 126 127 128
  stage: 'extras'
  script:
    - rustup component add clippy-preview
    - cargo clippy --version
129 130 131 132
      # Keep features in sync with above
    - |
      for crate in gstreamer*; do
        if [ $crate = "gstreamer" ]; then
133
          FEATURES=ser_de,v1_16
134 135 136 137 138 139
        elif [ $crate = "gstreamer-gl" ]; then
          FEATURES=egl,x11,wayland,v1_16
        else
          FEATURES=v1_16
        fi

140
        cargo clippy --color=always --manifest-path $crate/Cargo.toml --features=$FEATURES -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless
141
      done
142 143 144 145
    # And also run over all the examples/tutorials
    - |
      cargo clippy --color=always --manifest-path examples/Cargo.toml --bins --examples --all-features -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless
      cargo clippy --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless
Guillaume Desmottes's avatar
Guillaume Desmottes committed
146 147 148 149 150 151 152 153

audit:
  extends: '.tarball_setup'
  image: "rust:slim-buster"
  stage: 'extras'
  only:
    - schedules
  script:
154
    - cargo install --force cargo-audit
Guillaume Desmottes's avatar
Guillaume Desmottes committed
155
    - cargo audit --deny-warnings