Skip to content

Commit 2c91899

Browse files
authored
Merge pull request #35 from transloadit/coverage
Add Codecov
2 parents 7a5f0dc + f7d2d5b commit 2c91899

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,51 @@ jobs:
2626
architecture: x64
2727
cache: 'pip'
2828

29-
- name: Install Poetry manager
29+
- name: Install Poetry (Windows)
30+
if: runner.os == 'Windows'
31+
run: |
32+
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
33+
echo "$HOME\AppData\Roaming\Python\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
34+
35+
- name: Install Poetry (Unix)
36+
if: runner.os != 'Windows'
3037
run: pip install --upgrade poetry
3138

3239
- name: Install Dependencies
3340
run: poetry install
3441

35-
- name: Test with pytest
42+
- name: Test with coverage
43+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
3644
run: |
37-
poetry run pytest --cov=transloadit tests
45+
poetry run pytest --cov=transloadit \
46+
--cov-report=xml \
47+
--cov-report=json \
48+
--cov-report=html \
49+
--cov-report=term-missing \
50+
--cov-fail-under=65 \
51+
tests
3852
env:
3953
TEST_NODE_PARITY: 1
54+
55+
- name: Test without coverage
56+
if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12'
57+
run: poetry run pytest tests
58+
59+
- name: Upload coverage reports
60+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
61+
uses: codecov/codecov-action@v4
62+
with:
63+
token: ${{ secrets.CODECOV_TOKEN }}
64+
files: ./coverage.xml
65+
flags: unittests
66+
name: python-sdk
67+
fail_ci_if_error: true
68+
69+
- name: Upload coverage artifacts
70+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: coverage-reports
74+
path: |
75+
coverage.json
76+
htmlcov/

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Build status](https://github.com/transloadit/python-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/transloadit/python-sdk/actions/workflows/ci.yml)
2+
[![Coverage](https://codecov.io/gh/transloadit/python-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/transloadit/python-sdk)
23

34
# Transloadit python-sdk
45

@@ -64,3 +65,11 @@ Then to run the tests:
6465
```bash
6566
source .venv/bin/activate && poetry run pytest --cov=transloadit tests
6667
```
68+
69+
Generate a coverage report with:
70+
71+
```bash
72+
poetry run pytest --cov=transloadit --cov-report=html tests
73+
```
74+
75+
Then view the coverage report locally by opening `htmlcov/index.html` in your browser.

pyproject.toml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "pytransloadit"
33
version = "1.0.0"
4-
description = "A Python Integration for Transloadits file uploading and encoding service."
4+
description = "A Python Integration for Transloadit's file uploading and encoding service."
55
authors = ["Ifedapo Olarewaju"]
66
maintainers = ["Florian Kuenzig", "Arnaud Limbourg"]
77
license = "MIT"
@@ -44,3 +44,24 @@ sphinx-autobuild = "^2021.3.14"
4444
[build-system]
4545
requires = ["poetry-core"]
4646
build-backend = "poetry.core.masonry.api"
47+
48+
[tool.pytest.ini_options]
49+
addopts = "--cov=transloadit --cov-report=term-missing"
50+
testpaths = ["tests"]
51+
52+
[tool.coverage.run]
53+
source = ["transloadit"]
54+
branch = true
55+
56+
[tool.coverage.report]
57+
exclude_lines = [
58+
"pragma: no cover",
59+
"def __repr__",
60+
"if self.debug:",
61+
"raise NotImplementedError",
62+
"if __name__ == .__main__.:",
63+
"pass",
64+
"raise ImportError",
65+
]
66+
ignore_errors = true
67+
fail_under = 65

0 commit comments

Comments
 (0)