<NME> ci.yml
<BEF> name: Continuous Integration

on:
  push:
    branches:
    - master
  pull_request:

jobs:
  format:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2
      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        - ''
        - backend_winit
        - backend_drm
        - backend_drm_legacy
        - backend_drm_gbm
        - backend_drm_eglstream
        - backend_drm_egl
        - backend_libinput
        - backend_udev
        - backend_session
        - backend_session_logind
        - renderer_gl
        - renderer_glium
        - wayland_frontend
        - xwayland
        - default
      - name: Format
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
  
  clippy-check:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2
      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.59.0
          override: true
          profile: minimal
          components: clippy
          default: true
      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-
      - name: Get cargo-cache latest version
        id: cargocacheversion
        run: echo "::set-output name=version::$(cargo search 'cargo-cache' --limit 1 | head -n 1 | cut -d ' ' -f 3 | cut -d '"' -f 2)"
      - name: Cargo binaries cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/bin/cargo-cache
            ~/.cargo/.crates.toml
            ~/.cargo/.crates2.json
          key: ${{ runner.os }}-cargo-binaries-${{ steps.cargocacheversion.outputs.version }}
      - name: Install cargo-cache
        uses: actions-rs/cargo@v1
        with:
          command: install
          args: cargo-cache --version ${{ steps.cargocacheversion.outputs.version }}
      - name: Clean cargo cache of old items
        uses: actions-rs/cargo@v1
        with:
          command: cache
          args: clean-unref
      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libsystemd-dev libdbus-1-dev
      - name: Downgrade log
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -p log --precise 0.4.14
      - name: Clippy Smithay
        if: ${{ !env.ACT }} # act has no token
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --features "test_all_features" -- -D warnings
      - name: Clippy Smithay (ACT)
        if: ${{ env.ACT }} # on act lets just run clippy normally
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --features "test_all_features" -- -D warnings
      - name: Clippy Anvil
        if: ${{ !env.ACT }} # act has no token
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --manifest-path "./anvil/Cargo.toml" --features "test_all_features" --no-deps -- -D warnings
      - name: Clippy Anvil (ACT)
        if: ${{ env.ACT }} # on act lets just run clippy normally
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --manifest-path "./anvil/Cargo.toml" --features "test_all_features" --no-deps -- -D warnings
      - name: Clippy Smallvil
        if: ${{ !env.ACT }} # act has no token
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --manifest-path "./smallvil/Cargo.toml" --no-deps -- -D warnings
      - name: Clippy Smallvil (ACT)
        if: ${{ env.ACT }} # on act lets just run clippy normally
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --manifest-path "./smallvil/Cargo.toml" --no-deps -- -D warnings
  
  check-minimal:
    env:
      RUSTFLAGS: "-D warnings"

    runs-on: ubuntu-22.04
    needs:
      - clippy-check
      - format

    steps:
      - name: Checkout sources
        uses: actions/checkout@v2
      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          override: true
          profile: minimal
          default: true
      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-
      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libsystemd-dev libdbus-1-dev
      - name: Downgrade to minimal dependencies
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -Z minimal-versions
      - name: Check
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: --features "test_all_features"

  smithay-tests:
    needs:
      - format
      - clippy-check
    strategy:
      fail-fast: false
      matrix:
        features:
        - ''
        - backend_winit
        - backend_drm
        - backend_gbm
        - backend_egl
        - backend_libinput
        - backend_udev
        - backend_session
        - backend_session_logind
        - backend_session_libseat
        - backend_vulkan
        - backend_x11
        - desktop
        - renderer_gl
        - renderer_glow
        - renderer_multi
        - wayland_frontend
        - xwayland
        - default
        - test_all_features

    env:
      RUSTFLAGS: "-D warnings"

    runs-on: ubuntu-22.04

    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-

      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          default: true
          profile: minimal
      
      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libsystemd-dev libdbus-1-dev libseat-dev

      - name: Downgrade log
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -p log --precise 0.4.14
      
      - name: Test features
        uses: actions-rs/cargo@v1
        env:
          RUST_BACKTRACE: full
        with:
          command: test
          args: --no-default-features --features "${{ matrix.features }}"

  smallvil:
    needs:
      - format
      - clippy-check
      - smithay-tests
    strategy:
      fail-fast: false

    env:
      RUSTFLAGS: "-D warnings"

    runs-on: ubuntu-22.04

    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-

      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          default: true
          profile: minimal

      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y libxkbcommon-dev libegl1-mesa-dev libwayland-dev
      
      - name: Downgrade log
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -p log --precise 0.4.14
      
      - name: Test smallvil
        uses: actions-rs/cargo@v1
        env:
          RUST_BACKTRACE: full
        with:
          command: test
          args: --manifest-path "./smallvil/Cargo.toml""

  anvil-tests:
    needs:
      - format
      - clippy-check
      - smithay-tests
    strategy:
      fail-fast: false
      matrix:
        features:
        - ''
        - egl
        - winit
        - udev
        - logind
        - x11
        - default
        - test_all_features

    env:
      RUSTFLAGS: "-D warnings"

    runs-on: ubuntu-22.04

    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-

      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          default: true
          profile: minimal

      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libsystemd-dev libdbus-1-dev
      
      - name: Downgrade log
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -p log --precise 0.4.14
      
      - name: Test features
        uses: actions-rs/cargo@v1
        env:
          RUST_BACKTRACE: full
        with:
          command: test
          args: --manifest-path "./anvil/Cargo.toml" --no-default-features --features "${{ matrix.features }}"

  anvil-wlcs:
    needs:
      - format
      - clippy-check
      - smithay-tests
      - anvil-tests

    strategy:
      fail-fast: false
      matrix:
        include:
          - job_name: "Core tests"
            gtest_filter: "SelfTest*:FrameSubmission*"
            flag: core
          - job_name: "Output tests"
            gtest_filter: "XdgOutputV1Test*"
            flag: output
          - job_name: "Pointer input tests"
            gtest_filter: "*/SurfacePointerMotionTest*"
            flag: pointer-input

    name: "WLCS: ${{ matrix.job_name }}"

    env:
      RUSTFLAGS: "-D warnings"
      GRCOV_VERSION: "0.8.10"

    runs-on: ubuntu-22.04

    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-

      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          override: true
          default: true
          profile: minimal
          components: llvm-tools-preview

      - name: grcov cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/bin/grcov
            ~/.cargo/.crates.toml
            ~/.cargo/.crates2.json
          key: ${{ runner.os }}-grcov-${{ env.GRCOV_VERSION }}

      - name: Install grcov
        uses: actions-rs/cargo@v1
        with:
          command: install
          args: grcov --version ${{ env.GRCOV_VERSION }}

      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y cmake libgtest-dev google-mock libboost-dev libxkbcommon-dev libwayland-dev

      - name: WLCS build cache
        uses: actions/cache@v2
        with:
          path: wlcs
          key: ${{ runner.os }}-build-wlcs-${{ hashFiles('./compile_wlcs.sh') }}

      - name: Build WLCS
        run: ./compile_wlcs.sh

      - name: Downgrade log
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -p log --precise 0.4.14

      - name: Build anvil WLCS plugin
        uses: actions-rs/cargo@v1
        env:
          RUST_BACKTRACE: full
          RUSTFLAGS: "-Cinstrument-coverage --cfg coverage"
        with:
          command: build
          args: --manifest-path "./wlcs_anvil/Cargo.toml"

      - name: Run test suite
        run: ./wlcs/wlcs ./target/debug/libwlcs_anvil.so --gtest_filter="${{ matrix.gtest_filter }}"
        env:
          LLVM_PROFILE_FILE: "anvil-wlcs-%p-%m.profraw"

      - name: Coverage
        run: grcov . --binary-path ./target/debug -s . -t lcov --branch --llvm --ignore-not-existing --ignore '*/examples/*' --ignore '*/tests/*' --ignore '*/.cargo/registry/*' --excl-br-start "mod tests \{" --excl-start "mod tests \{" --excl-br-line "#\[derive\(" --excl-line "#\[derive\(" -o lcov.info

      - name: Upload to codecov.io
        uses: codecov/codecov-action@v1
        with:
          flags: wlcs-${{ matrix.flag }}

  doc:
    name: Documentation on Github Pages
    runs-on: ubuntu-22.04
    needs:
      - smithay-tests

    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Get date for registry cache
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Cargo registry cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
          restore-keys: ${{ runner.os }}-cargo-registry-

      - name: Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly # We need nightly to enable doc_auto_cfg
          override: true

      - name: System dependencies
        run: sudo apt-get update; sudo apt-get install -y libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libsystemd-dev libdbus-1-dev
      
      - name: Downgrade log
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: -p log --precise 0.4.14
      
      - name: Build Documentation
        uses: actions-rs/cargo@v1
        with:
          command: doc
          # TODO: Update nix when drm-rs is updated
          args: --no-deps --features "test_all_features" -p smithay -p calloop:0.10.1 -p dbus -p drm -p gbm -p input -p nix:0.24.2 -p udev -p slog -p wayland-server:0.30.0-beta.12 -p wayland-backend -p wayland-protocols:0.30.0-beta.12 -p winit -p x11rb
          env: RUSTDOCFLAGS=--cfg="docsrs"

      - name: Setup index
        run: cp ./doc_index.html ./target/doc/index.html

      - name: Deploy
        if: ${{ github.event_name == 'push' }}
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./target/doc
          force_orphan: true

<MSG> ci: Adjust to new feature set

<DFF> @@ -17,16 +17,13 @@ jobs:
         - ''
         - backend_winit
         - backend_drm
-        - backend_drm_legacy
-        - backend_drm_gbm
-        - backend_drm_eglstream
-        - backend_drm_egl
+        - backend_gbm
+        - backend_egl
         - backend_libinput
         - backend_udev
         - backend_session
         - backend_session_logind
         - renderer_gl
-        - renderer_glium
         - wayland_frontend
         - xwayland
         - default

ci: Adjust to new feature set