Skip to content

Commit

Permalink
Measure test coverage with Codecov (#62)
Browse files Browse the repository at this point in the history
* feat: Measure test coverage with Codecov

* fix: Add Codecov configuration
  • Loading branch information
AdrianoKF committed Aug 28, 2024
1 parent 7efe6dc commit b33f9f9
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 6 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/backend-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
paths:
- backend/**
- .github/**
branches:
- main

Expand Down Expand Up @@ -47,4 +48,17 @@ jobs:
- name: Execute python tests
run: |
uv pip install . # need to install without --no-deps to work around non-portable dependency resolution in `uv pip compile`
pytest
uv run pytest -s --cov=src --cov-report=xml --junitxml=junit.xml
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./backend/coverage.xml
slug: aai-institute/infrastructure-product
flags: backend
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./backend/junit.xml
16 changes: 15 additions & 1 deletion .github/workflows/client-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
paths:
- client/**
- .github/**
branches:
- main

Expand Down Expand Up @@ -47,4 +48,17 @@ jobs:
- name: Execute python tests
run: |
uv pip install . # need to install without --no-deps to work around non-portable dependency resolution in `uv pip compile`
pytest
pytest --cov=src --cov-report=xml --junitxml=junit.xml
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./client/coverage.xml
slug: aai-institute/infrastructure-product
flags: client
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./client/junit.xml
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["build", "ruff", "pytest", "pytest-mock", "pre-commit", "testcontainers"]
dev = ["build", "ruff", "pytest", "pytest-mock", "pytest-cov", "pre-commit", "testcontainers"]

# Automatically determine version number from Git tags
[tool.setuptools_scm]
Expand Down
5 changes: 5 additions & 0 deletions backend/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ click==8.1.7
# uvicorn
colorful==0.5.6
# via ray
coverage==7.6.1
# via pytest-cov
distlib==0.3.8
# via virtualenv
dnspython==2.6.1
Expand Down Expand Up @@ -247,7 +249,10 @@ pyproject-hooks==1.1.0
pytest==8.3.2
# via
# jobs-server (pyproject.toml)
# pytest-cov
# pytest-mock
pytest-cov==5.0.0
# via jobs-server (pyproject.toml)
pytest-mock==3.14.0
# via jobs-server (pyproject.toml)
python-dateutil==2.9.0.post0
Expand Down
Empty file added backend/tests/__init__.py
Empty file.
Empty file.
Empty file added backend/tests/unit/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs_execute = "jobs.execute:execute"
jobby = "jobs.cli:main"

[project.optional-dependencies]
dev = ["build", "ruff", "pytest", "pre-commit"]
dev = ["build", "ruff", "pytest", "pytest-cov", "pre-commit"]
docs = [
"mkdocs",
"mkdocs-callouts",
Expand Down
6 changes: 6 additions & 0 deletions client/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ colorama==0.4.6
# mkdocs-material
colorful==0.5.6
# via ray
coverage==7.6.1
# via pytest-cov
distlib==0.3.8
# via virtualenv
docker==7.1.0
Expand Down Expand Up @@ -304,6 +306,10 @@ pyparsing==3.1.2
pyproject-hooks==1.1.0
# via build
pytest==8.2.2
# via
# job-queue (pyproject.toml)
# pytest-cov
pytest-cov==5.0.0
# via job-queue (pyproject.toml)
python-dateutil==2.9.0.post0
# via
Expand Down
2 changes: 0 additions & 2 deletions client/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ tensorboardx==2.6.2.2
# via ray
tensorflow==2.16.1
# via job-queue (pyproject.toml)
tensorflow-io-gcs-filesystem==0.36.0
# via tensorflow
termcolor==2.4.0
# via tensorflow
textual==0.72.0
Expand Down
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ignore:
- "test_*.py"
- "**/tests/**"
flag_management:
individual_flags:
- name: client
paths:
- "client/"
- name: backend
paths:
- "backend/"

0 comments on commit b33f9f9

Please sign in to comment.