# TODO: Line 47, enable pytest --doctest-modules

name: Tests
on: [push, pull_request]
jobs:
  Tests:
    strategy:
      fail-fast: false		
      max-parallel: 15
      matrix:
        node: [10.x, 12.x, 14.x]
        python: [3.6, 3.8, 3.9]
        os: [macos-latest, ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - name: Use Python ${{ matrix.python }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}
        env:
          PYTHON_VERSION: ${{ matrix.python }}
      - name: Install Dependencies
        run: |
          npm install --no-progress
          pip install flake8 pytest
      - name: Set Windows environment
        if: matrix.os == 'windows-latest'
        run:
          echo '::set-env name=GYP_MSVS_VERSION::2015'
          echo '::set-env name=GYP_MSVS_OVERRIDE_PATH::C:\\Dummy'
      - name: Lint Python
        if: matrix.os == 'ubuntu-latest'
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
      - name: Run Python tests
        run: |
          python -m pytest
      # - name: Run doctests with pytest
      #   run: python -m pytest --doctest-modules
      - name: Run Node tests
        run: |
          npm test
