Skip to content

Commit 4c09c13

Browse files
authored
feat: support codspeed (#81)
1 parent 70e1f52 commit 4c09c13

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

.github/workflows/codspeed.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CodSpeed
2+
3+
on:
4+
push:
5+
branches:
6+
- "main" # or "master"
7+
pull_request:
8+
# `workflow_dispatch` allows CodSpeed to trigger backtest
9+
# performance analysis in order to generate initial data.
10+
workflow_dispatch:
11+
12+
jobs:
13+
benchmarks:
14+
name: Run benchmarks
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.13"
21+
22+
- name: Install dependencies
23+
run: pip install -e .[dev]
24+
25+
- name: Run benchmarks
26+
uses: CodSpeedHQ/action@v3
27+
with:
28+
token: ${{ secrets.CODSPEED_TOKEN }}
29+
run: pytest tests/ --codspeed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ clang-tidy-1*
1818
clang-tidy-2*
1919
clang-format-1*
2020
clang-format-2*
21+
22+
# Ignore CodeSpeed folder
23+
.codspeed/

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dev = [
4949
"coverage",
5050
"pre-commit",
5151
"pytest",
52+
"pytest-codspeed",
5253
]
5354

5455
[tool.setuptools]

tests/test_clang_format.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from cpp_linter_hooks.clang_format import run_clang_format
55

66

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

2627

28+
@pytest.mark.benchmark
2729
@pytest.mark.parametrize(
2830
("args", "expected_retval"),
2931
(
@@ -48,6 +50,7 @@ def test_run_clang_format_invalid(args, expected_retval, tmp_path):
4850
assert ret == expected_retval
4951

5052

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

6871

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

8488

89+
@pytest.mark.benchmark
8590
def test_run_clang_format_verbose_error(tmp_path):
8691
"""Test that verbose option provides useful error information."""
8792
test_file = tmp_path / "main.c"

tests/test_clang_tidy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def generate_compilation_database():
1212
subprocess.run(["cmake", "-Bbuild", "testing/"])
1313

1414

15+
@pytest.mark.benchmark
1516
@pytest.mark.parametrize(
1617
("args", "expected_retval"),
1718
(
@@ -32,6 +33,7 @@ def test_run_clang_tidy_valid(args, expected_retval):
3233
print(output)
3334

3435

36+
@pytest.mark.benchmark
3537
@pytest.mark.parametrize(
3638
("args", "expected_retval"),
3739
(

tests/test_util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
TOOLS = ["clang-format", "clang-tidy"]
1111

1212

13+
@pytest.mark.benchmark
1314
@pytest.mark.parametrize(("tool", "version"), list(product(TOOLS, VERSIONS)))
1415
def test_ensure_installed(tool, version, tmp_path, monkeypatch, caplog):
1516
bin_path = tmp_path / "bin"

0 commit comments

Comments
 (0)