name: Coverage
on:
  push:
    branches:
      - main
  pull_request:
  schedule:
    - cron: 0 0 * * *

jobs:
  Coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python environment
        uses: actions/setup-python@v4
        with:
          python-version: '3.9'
      - name: Setup virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
          python -m pip install --upgrade pip      
      - name: Install Requirements
        run: |
          pip install coverage pytest
          pip install -r test/requirements.txt
          python setup.py install
      - name: Generate Unit Test Coverage
        run: |
          coverage run --rcfile=.coveragerc -m pytest
          coverage xml
      - name: Publish Coverage
        uses: codecov/codecov-action@v3
        with:
          flags: unit
