name: build

on:
  push:
    branches: [ "main" ]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: test-on-${{ matrix.os }}${{ matrix.features && '-' }}${{ matrix.features }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: windows-latest
          - os: ubuntu-latest
          - os: macos-latest
            features: "gpu"
          - os: ubuntu-latest
            features: "inplace"
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/setup-build
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - run: cargo make check --features "${{ matrix.features }}"
        shell: bash

  build-docs:
    name: build-docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/setup-build
        with:
          toolchain: nightly
      - run: cargo make doc
      - uses: dtolnay/install@cargo-docs-rs
      - run: | 
          cargo +nightly docs-rs
