name: Test with Conda

on:
  pull_request:

  push:
    branches:
      - main

jobs:
  test-conda:
    name: Test conda env

    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false

      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    defaults:
      run:
        shell: bash -l {0}

    env:
      # requests crashes on OSX without this
      no_proxy: "*"
      # issue with SciPy on Windows, see https://github.com/scipy/scipy/issues/14002
      CONDA_DLL_SEARCH_MODIFICATION_ENABLE: "1"

    steps:
      - uses: actions/checkout@v2

      - name: Cache conda
        uses: actions/cache@v2
        with:
          path: ~/conda_pkgs_dir
          key:
            ${{ runner.os }}-conda-${{hashFiles('conda-environment.yml') }}

      - uses: conda-incubator/setup-miniconda@v3
        with:
          activate-environment: veros
          environment-file: conda-environment.yml
          use-only-tar-bz2: true

      - name: Install test dependencies
        run: |
          pip install pytest

      - name: List
        run: |
          conda info
          conda list

      - name: Run tests
        run: pytest .
