name: CI

on:
  push:
    branches: [master, v0.*]
  pull_request:
    branches: master
  schedule:
    - cron:  '0 6 * * 1,4' # Each Monday and Thursday at 06:00 UTC
  workflow_dispatch:

env:
  NB_KERNEL: python
  MPLBACKEND: Agg
  WATEX_DATA: ${{ github.workspace }}/watex-data

jobs:
  run-tests:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python: ["3.8", "3.9", "3.10"]
        install: [full]
        deps: [latest]

        include:
          - python: "3.9"
            install: full
            deps: pinned
          - python: "3.10"
            install: light
            deps: pinned

    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ matrix.python }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}

      - name: Install dependencies 
        run: |
          python -m pip install --upgrade pip
          python -m pip install flake8 pytest pytest-cov
          if [[ ${{matrix.install}} == 'full' ]]; then pip install -r docs/requirements.txt; fi
          if [[ ${{matrix.deps }} == 'pinned' ]]; then pip install -r ci/deps_pinned.txt; fi

      - name: Run unit tests with pytest and code coverage with coverage.py
        run: |
          pytest tests -v --cov=tests/ --cov-config=.coveragerc --cov-report lcov:tests/lcov.info --cov-fail-under=60

      - name: Upload Coverage Results
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          path-to-lcov: tests/lcov.info

