codecov / feedback

A place to discuss feedback about the pull request and web product experience.
37 stars 7 forks source link

Bug Report: covering lines of tests not the lines of package #522

Closed Qazalbash closed 1 month ago

Qazalbash commented 2 months ago

My project structure is something like this,

.
├── LICENSE
├── pyproject.toml
├── README.md
├── ruff.toml
├── src
│   └── myproject
│       ├── module0
│       │   ├── file0.py
│       │   ├── file1.py
│       │   └── __init__.py
│       └── __init__.py
└── tests
    ├── __init__.py
    ├── test0.py
    └── test1.py
.codecov.yml

```yaml codecov: require_ci_to_pass: true branch: main coverage: precision: 2 range: 50..100 round: nearest status: project: default: target: auto threshold: 1 patch: default: target: 90 ```

ci.yaml

```yaml # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: CI on: push: branches: ['main', 'dev'] paths: - "**/*.py" - ".github/workflows/ci.yml" pull_request: branches: ['main', 'dev'] paths: - "**/*.py" - ".github/workflows/ci.yml" jobs: lint: name: Lint with ruff (py ${{ matrix.python-version }} on ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: - ubuntu-latest python-version: - "3.10" - "3.11" - "3.12" - "3.x" steps: - uses: actions/checkout@v4.1.7 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5.2.0 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install ruff - name: Lint with ruff run: | ruff format . --check test: name: "build (py ${{ matrix.python-version }} on ${{ matrix.os }})" runs-on: ${{ matrix.os }} needs: - lint strategy: fail-fast: false matrix: os: - ubuntu-latest python-version: - "3.10" - "3.11" - "3.12" - "3.x" steps: - uses: actions/checkout@v4.1.7 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5.2.0 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install pytest pytest-cov python -m pip install . - name: Test with pytest env: PY_COLORS: 1 run: | pytest --cov src -ra --color yes - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: verbose: true env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} ```

Either codecov is not covering lines from my code or it is covering from tests.