name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest]
        python-version: [3.6, 3.7, 3.8, 3.9, pypy-3.6, pypy-3.7]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      # https://github.com/actions/cache/blob/main/examples.md#using-a-script-to-get-cache-location
      - id: pip-cache
        run: python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
      - uses: actions/cache@v1
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - run: pip install --upgrade check-manifest flake8 isort setuptools
      - run: check-manifest
      - run: flake8 .
      - run: isort . --check-only
      - run: pip install .[test] coveralls
      - run: nosetests --with-coverage --cover-package=csvkit
      - env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: coveralls --service=github
