name: Test

on: [push, pull_request]

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: full

jobs:
  test-native:
    strategy:
      matrix:
        os: [windows-latest, macos-latest, ubuntu-latest]

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - uses: Swatinem/rust-cache@v2
      - run: rustup toolchain install stable --profile minimal
      - run: rustup component add rustfmt clippy
      - run: cargo fetch
      - run: cargo fmt -- --check --color always
      - run: cargo clippy --all-targets --all-features
      - run: cargo test --release

  # cli:
  #   strategy:
  #     matrix:
  #       os: [macos-latest]

  #   runs-on: ${{ matrix.os }}
  #   steps:
  #     - uses: actions/checkout@v3
  #     - uses: Swatinem/rust-cache@v2
  #     - run: rustup toolchain install stable --profile minimal
  #     - run: cargo fetch
  #     - run: cargo build -p rio --bin rio
  #     - run: RIO_LOG_LEVEL=info ./target/debug/rio -e touch ${HOME}/rio.test
  #     - run: |
  #         FILE=${HOME}/rio.test
  #         if [ -f "$FILE" ]; then
  #           echo "$FILE exists."
  #         else
  #           echo "$FILE does not exist."
  #           exit 1
  #         fi
  #       shell: bash

  # webassembly:
  #   runs-on: ubuntu-latest
  #   env:
  #     GECKODRIVER: chromedriver
  #   steps:
  #     - uses: actions/checkout@v3
  #     - uses: Swatinem/rust-cache@v2
  #       with:
  #         cache-all-crates: "true"
  #     - run: rustup toolchain install stable --profile minimal --target wasm32-unknown-unknown
  #     - run: cargo fetch
  #     - run: cargo build -p sugarloaf --target wasm32-unknown-unknown
  #     - run: cd ./sugarloaf && make install
  #     - uses: nanasess/setup-chromedriver@v2
  #     - run: |
  #         export DISPLAY=:99
  #         chromedriver --url-base=/wd/hub &
  #     - run: make test-renderer
