name: CodeCov

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.12"]
    services:
      mongodb:
        image: mongo:latest
        env:
          # MONGO_INITDB_ROOT_USERNAME: admin
          # MONGO_INITDB_ROOT_PASSWORD: admin
          MONGO_INITDB_DATABASE: testMongo
        ports:
          - 27017:27017
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install coverage[toml]
        python -m pip install -r requirements.txt

    - name: run tests and coverage
      run: |
        coverage run -m unittest tests
        coverage report -m
        coverage xml

    - name: Coverage Badge
      run: |
        pip install -U genbadge defusedxml
        genbadge coverage -i  coverage.xml -o coverage.svg