Skip to content

feat: support codspeed #81

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

Merged
merged 1 commit into from
Jul 4, 2025
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CodSpeed

on:
push:
branches:
- "main" # or "master"
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
benchmarks:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: pip install -e .[dev]

- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: pytest tests/ --codspeed
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ clang-tidy-1*
clang-tidy-2*
clang-format-1*
clang-format-2*

# Ignore CodeSpeed folder
.codspeed/
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dev = [
"coverage",
"pre-commit",
"pytest",
"pytest-codspeed",
]

[tool.setuptools]
Expand Down
5 changes: 5 additions & 0 deletions tests/test_clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from cpp_linter_hooks.clang_format import run_clang_format


@pytest.mark.benchmark
@pytest.mark.parametrize(
("args", "expected_retval"),
(
Expand All @@ -24,6 +25,7 @@ def test_run_clang_format_valid(args, expected_retval, tmp_path):
assert test_file.read_text() == Path("testing/good.c").read_text()


@pytest.mark.benchmark
@pytest.mark.parametrize(
("args", "expected_retval"),
(
Expand All @@ -48,6 +50,7 @@ def test_run_clang_format_invalid(args, expected_retval, tmp_path):
assert ret == expected_retval


@pytest.mark.benchmark
@pytest.mark.parametrize(
("args", "expected_retval"),
(
Expand All @@ -66,6 +69,7 @@ def test_run_clang_format_dry_run(args, expected_retval, tmp_path):
assert ret == -1 # Dry run should not fail


@pytest.mark.benchmark
def test_run_clang_format_verbose(tmp_path):
"""Test that verbose option works and provides detailed output."""
# copy test file to tmp_path to prevent modifying repo data
Expand All @@ -82,6 +86,7 @@ def test_run_clang_format_verbose(tmp_path):
assert test_file.read_text() == Path("testing/good.c").read_text()


@pytest.mark.benchmark
def test_run_clang_format_verbose_error(tmp_path):
"""Test that verbose option provides useful error information."""
test_file = tmp_path / "main.c"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def generate_compilation_database():
subprocess.run(["cmake", "-Bbuild", "testing/"])


@pytest.mark.benchmark
@pytest.mark.parametrize(
("args", "expected_retval"),
(
Expand All @@ -32,6 +33,7 @@ def test_run_clang_tidy_valid(args, expected_retval):
print(output)


@pytest.mark.benchmark
@pytest.mark.parametrize(
("args", "expected_retval"),
(
Expand Down
1 change: 1 addition & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
TOOLS = ["clang-format", "clang-tidy"]


@pytest.mark.benchmark
@pytest.mark.parametrize(("tool", "version"), list(product(TOOLS, VERSIONS)))
def test_ensure_installed(tool, version, tmp_path, monkeypatch, caplog):
bin_path = tmp_path / "bin"
Expand Down
Loading