Skip to content

Commit

Permalink
Merge pull request #35 from transloadit/coverage
Browse files Browse the repository at this point in the history
Add Codecov
  • Loading branch information
kvz authored Nov 28, 2024
2 parents 7a5f0dc + f7d2d5b commit 2c91899
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
43 changes: 40 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,51 @@ jobs:
architecture: x64
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
env:
TEST_NODE_PARITY: 1

- 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/
9 changes: 9 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 @@ -64,3 +65,11 @@ Then to run the tests:
```bash
source .venv/bin/activate && poetry run pytest --cov=transloadit tests
```

Generate a coverage report with:

```bash
poetry run pytest --cov=transloadit --cov-report=html tests
```

Then view the coverage report locally by opening `htmlcov/index.html` in your browser.
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

0 comments on commit 2c91899

Please sign in to comment.