Skip to content

Codspeed - performance benchmarks #471

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
pull_request:
branches:
- '**'
# `workflow_dispatch` allows CodSpeed to trigger backtest performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
build:
Expand Down Expand Up @@ -51,6 +53,17 @@ jobs:
COV_CORE_SOURCE: .
COV_CORE_CONFIG: .coveragerc
COV_CORE_DATAFILE: .coverage.eager

- name: Test with CodSpeed
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: poetry run py.test --cov=./ --cov-append --cov-report=xml --codspeed
env:
COV_CORE_SOURCE: .
COV_CORE_CONFIG: .coveragerc
COV_CORE_DATAFILE: .coverage.eager

- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
150 changes: 149 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ linkify-it-py = "*"
### Testing ###
gp-libs = "*"
pytest = "*"
pytest-codspeed = "*"
pytest-rerunfailures = "*"
pytest-mock = "*"
pytest-watcher = "*"
Expand All @@ -112,6 +113,10 @@ files = [
"tests",
]

[[tool.mypy.overrides]]
module = "pytest_codspeed.plugin"
ignore_missing_imports = true

[tool.coverage.run]
branch = true
parallel = true
Expand Down
4 changes: 3 additions & 1 deletion tests/sync/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import typing as t

import pytest
from pytest_codspeed.plugin import BenchmarkFixture
from pytest_mock import MockerFixture

from libvcs import exc
Expand Down Expand Up @@ -56,6 +57,7 @@ def test_repo_git_obtain_initial_commit_repo(
tmp_path: pathlib.Path,
constructor: ProjectTestFactory,
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
benchmark: BenchmarkFixture,
) -> None:
"""Initial commit repos return 'initial'.

Expand All @@ -69,7 +71,7 @@ def test_repo_git_obtain_initial_commit_repo(
bare_dir = tmp_path / repo_name
git_repo: GitSync = constructor(**lazy_constructor_options(**locals()))

git_repo.obtain()
benchmark(lambda: git_repo.obtain())
assert git_repo.get_revision() == "initial"


Expand Down