Skip to content

Added unit tests and actions yaml #13

Added unit tests and actions yaml

Added unit tests and actions yaml #13

Workflow file for this run

name: Unit Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
steps:
- name: 📥 Checkout code
uses: actions/checkout@v3
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: 📦 Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: 📦 Install dependencies with Poetry
run: |
poetry lock
poetry install --with dev
- name: 🧪 Run tests with coverage
run: |
poetry run pytest --cov=pytest_reporter_plus tests/unit/ --cov-fail-under=21 --cov-report=term --cov-report=xml
- name: 📊 Extract coverage percentage
if: github.event_name == 'pull_request'
run: |
COVERAGE=$(coverage report | grep TOTAL | awk '{print $4}')
echo "Coverage is $COVERAGE"
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
- name: 💬 Comment coverage on PR
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
🧪 **Test Coverage**
```
${{ env.COVERAGE }}
```