name: Tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  check:
    name: Format and Doc
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install xcb libraries
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
          components: rustfmt
      - name: Rustfmt check
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
      - name: doc (kas)
        run: cargo doc --all-features --no-deps
      - name: doc (kas-theme)
        run: cargo doc --manifest-path kas-theme/Cargo.toml --features stack_dst,unsize --no-deps
      - name: doc (kas-wgpu)
        run: cargo doc --manifest-path kas-wgpu/Cargo.toml --features stack_dst,unsize --no-deps

  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
        # disabled because of shaderc dependencies: windows-latest

    steps:
      - uses: actions/checkout@v2
      - name: Install latest nightly
        uses: actions-rs/toolchain@v1
        with:
            toolchain: nightly
            override: true
      - name: Install xcb libraries
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get install -y libxcb-shape0-dev libxcb-xfixes0-dev

      - name: test (kas-macros)
        run: cargo test --manifest-path kas-macros/Cargo.toml --all-features
      - name: test (kas)
        run: cargo test --all-features
      - name: test (kas-theme)
        run: |
          # note: stack_dst + gat is broken
          cargo test --manifest-path kas-theme/Cargo.toml --features stack_dst,unsize
          cargo test --manifest-path kas-theme/Cargo.toml --no-default-features --features gat
      - name: test (kas-wgpu)
        run: |
          # note: gat is broken
          cargo test --manifest-path kas-wgpu/Cargo.toml --features stack_dst,unsize
