name: pytest linux 3.8

on:
  push:
    branches:
    - main
  pull_request:
    branches:
    - main

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        python-version: [ "3.8" ]
    defaults:
      run:
        shell: bash -l {0}

    name: Python ${{ matrix.python-version }} ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: |
            ~/conda_pkgs_dir
            ~/miniconda*/envs/
          key: ${{ runner.os }}-${{ matrix.python-version }}-env-${{ hashFiles('requirements/tests.txt') }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.python-version }}-env-
      - name: Setup conda
        uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: xonsh-test
          auto-update-conda: true
          python-version: ${{ matrix.python-version }}  # this itself makes sure that Python version is installed
          condarc-file: ci/condarc.yml
          use-only-tar-bz2: true
      - name: Get pip cache dir
        id: pip-cache
        run: |
          python -m pip install --upgrade pip wheel
          echo "::set-output name=dir::$(python -m pip cache dir)"
      - name: pip cache
        uses: actions/cache@v2
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: ${{ runner.os }}-pip-${{ hashFiles('requirements/tests.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Install dependencies
        run: |
          python -m pip --version
          python -m pip install -r requirements/tests.txt
          python -m pip install . --no-deps
      - name: Run tests
        run: python -m xonsh run-tests.xsh test -- --timeout=240
