name: Tests

on: [push]

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        version: ["stable", "1.70.0"]
        os: ["ubuntu-latest", "windows-latest", "macos-latest"]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3

      - name: Install x11 dependencies for Kludgine
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update -y -qq

          # vulkan sdk
          wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
          sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list

          # install dependencies
          sudo apt-get update
          sudo apt-get install -y \
            libegl-mesa0 libgl1-mesa-dri libxcb-xfixes0-dev vulkan-sdk mesa-vulkan-drivers

      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.version }}

      - name: Run clippy
        if: matrix.version == 'stable'
        run: |
          cargo clippy --all-features --all-targets

      - name: Compile with all features
        run: |
          cargo build --all-features --all-targets

      - name: Run all features unit tests
        # for msrv, we only check build compatibility, as it's possible bugs are
        # fixed purely by updating the rust version.
        if: matrix.version == 'stable'
        run: |
          cargo test --all-features --all-targets
