Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Codecov #35

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand All @@ -18,14 +18,51 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: "pip"
cache: 'pip'

- name: Install Poetry manager
- name: Install Poetry (Windows)
if: runner.os == 'Windows'
run: |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
echo "$HOME\AppData\Roaming\Python\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install Poetry (Unix)
if: runner.os != 'Windows'
run: pip install --upgrade poetry

- name: Install Dependencies
run: poetry install

- name: Test with pytest
- name: Test with coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
run: |
poetry run pytest --cov=transloadit tests
poetry run pytest --cov=transloadit \
--cov-report=xml \
--cov-report=json \
--cov-report=html \
--cov-report=term-missing \
--cov-fail-under=65 \
tests

- name: Test without coverage
if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12'
run: poetry run pytest tests

- name: Upload coverage reports
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: python-sdk
fail_ci_if_error: true

- name: Upload coverage artifacts
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: |
coverage.json
htmlcov/
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build status](https://github.com/transloadit/python-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/transloadit/python-sdk/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/transloadit/python-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/transloadit/python-sdk)

# Transloadit python-sdk

Expand Down Expand Up @@ -42,3 +43,31 @@ For fully working examples, take a look at [`examples/`](https://github.com/tran
## Documentation

See [readthedocs](https://transloadit.readthedocs.io) for full API documentation.

## Development
kvz marked this conversation as resolved.
Show resolved Hide resolved

### Testing
kvz marked this conversation as resolved.
Show resolved Hide resolved

Run tests with:

```bash
poetry run pytest
```

### Code Coverage

We maintain code coverage to ensure reliability. The current minimum coverage threshold is 65%.

Coverage reports are:

- Generated locally in the `htmlcov` directory
- Uploaded to Codecov for tracking
- Enforced in CI (builds will fail if coverage drops below threshold)

View the coverage report locally by opening `htmlcov/index.html` in your browser.

Generate a coverage report with:

```bash
poetry run pytest --cov=transloadit --cov-report=html tests
```
23 changes: 22 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "pytransloadit"
version = "1.0.0"
description = "A Python Integration for Transloadits file uploading and encoding service."
description = "A Python Integration for Transloadit's file uploading and encoding service."
authors = ["Ifedapo Olarewaju"]
maintainers = ["Florian Kuenzig", "Arnaud Limbourg"]
license = "MIT"
Expand Down Expand Up @@ -44,3 +44,24 @@ sphinx-autobuild = "^2021.3.14"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
addopts = "--cov=transloadit --cov-report=term-missing"
testpaths = ["tests"]

[tool.coverage.run]
source = ["transloadit"]
branch = true

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"pass",
"raise ImportError",
]
ignore_errors = true
fail_under = 65