Documentation
name: Tests

on:
  push:
    branches: [ master, '[0-9]+.[0-9]+' ]
  pull_request:
    branches: [ master, '[0-9]+.[0-9]+' ]

jobs:
  nightly:
    name: Nightly, format and Doc
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
          components: rustfmt
      - name: Install dependencies
        run: sudo apt-get install -y libxkbcommon-dev libxcb-shape0-dev libxcb-xfixes0-dev

      - name: Rustfmt check
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
      - name: Build docs
        run: cargo doc --all-features --all --no-deps
      - name: Test kas-macros
        run: cargo test --manifest-path crates/kas-macros/Cargo.toml --all-features
      - name: Test kas-core
        run: cargo test --manifest-path crates/kas-core/Cargo.toml --all-features
      - name: Test kas-widgets
        run: cargo test --manifest-path crates/kas-widgets/Cargo.toml --all-features
      - name: Test kas-resvg
        run: cargo test --manifest-path crates/kas-resvg/Cargo.toml --all-features
      - name: Test kas-theme
        run: cargo test --manifest-path crates/kas-theme/Cargo.toml --all-features
      - name: Test kas-wgpu
        run: |
          cargo test --manifest-path crates/kas-wgpu/Cargo.toml --no-default-features --features raster
          cargo test --manifest-path crates/kas-wgpu/Cargo.toml --all-features
      - name: Test kas-dylib
        run: cargo test --manifest-path crates/kas-dylib/Cargo.toml --all-features
      - name: Test kas
        run: cargo test --all-features
      - name: Test examples/mandlebrot
        run: cargo test --manifest-path examples/mandlebrot/Cargo.toml --all-features

  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        toolchain: [stable]
        include:
          - os: ubuntu-latest
            toolchain: "1.53.0"

    steps:
      - uses: actions/checkout@v2
      - name: Install toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }}
          override: true
      - name: Install dependencies
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get install -y libxkbcommon-dev libxcb-shape0-dev libxcb-xfixes0-dev

      - name: Test kas-macros
        run: cargo test --manifest-path crates/kas-macros/Cargo.toml --all-features
      - name: Test kas-core
        run: cargo test --manifest-path crates/kas-core/Cargo.toml
      - name: Test kas-widgets
        run: cargo test --manifest-path crates/kas-widgets/Cargo.toml
      - name: Test kas-resvg
        run: cargo test --manifest-path crates/kas-resvg/Cargo.toml --all-features
      - name: Test kas-theme
        run: cargo test --manifest-path crates/kas-theme/Cargo.toml
      - name: Test kas-wgpu
        run: cargo test --manifest-path crates/kas-wgpu/Cargo.toml
      - name: Test kas-dylib
        run: cargo test --manifest-path crates/kas-dylib/Cargo.toml
      - name: Test kas
        run: cargo test
      - name: Test examples/mandlebrot
        run: cargo test --manifest-path examples/mandlebrot/Cargo.toml