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

feat: support codspeed #81

merged 1 commit into from
Jul 4, 2025

Conversation

shenxianpeng
Copy link
Collaborator

@shenxianpeng shenxianpeng commented Jul 4, 2025

Summary by CodeRabbit

  • Chores

    • Introduced a new GitHub Actions workflow to run performance benchmarks automatically.
    • Updated development dependencies to include benchmarking support.
    • Added .codspeed/ directory to .gitignore to prevent it from being tracked.
  • Tests

    • Enabled benchmarking for various test cases to collect performance metrics.

@shenxianpeng shenxianpeng added the enhancement New feature or request label Jul 4, 2025
Copy link

sonarqubecloud bot commented Jul 4, 2025

Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.12%. Comparing base (70e1f52) to head (f872a26).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #81   +/-   ##
=======================================
  Coverage   95.12%   95.12%           
=======================================
  Files           3        3           
  Lines          82       82           
=======================================
  Hits           78       78           
  Misses          4        4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

coderabbitai bot commented Jul 4, 2025

Walkthrough

A CodSpeed benchmarking workflow was added to GitHub Actions, integrating pytest-codspeed for performance measurement. The .gitignore was updated to exclude CodSpeed artifacts. The development dependencies in pyproject.toml now include pytest-codspeed. All relevant test functions were marked with @pytest.mark.benchmark to enable benchmarking during test runs.

Changes

File(s) Change Summary
.github/workflows/codspeed.yml Added a new GitHub Actions workflow for running CodSpeed benchmarks on pushes, PRs, and manual runs.
.gitignore Added .codspeed/ to ignore CodSpeed output directory.
pyproject.toml Added pytest-codspeed to the development dependencies.
tests/test_clang_format.py Added @pytest.mark.benchmark decorator to all test functions and parameterized cases.
tests/test_clang_tidy.py Added @pytest.mark.benchmark decorator to two test functions.
tests/test_util.py Added @pytest.mark.benchmark decorator to test_ensure_installed.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub
    participant Runner
    participant CodSpeed

    Developer->>GitHub: Push/PR/Manual Dispatch
    GitHub->>Runner: Trigger CodSpeed workflow
    Runner->>Runner: Checkout code
    Runner->>Runner: Setup Python 3.13
    Runner->>Runner: Install dev dependencies (incl. pytest-codspeed)
    Runner->>CodSpeed: Run CodSpeed Action (with secret token)
    Runner->>Runner: Run pytest on tests/ with CodSpeed integration
    Runner->>CodSpeed: Report benchmark results
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
tests/test_clang_format.py (1)

53-64: Parameter values are ignored – test never uses args / expected_retval
The current body hard-codes the CLI flags and asserts on -1, so the parametrisation brings no value and the test semantics are wrong.

-    ret, _ = run_clang_format(["--dry-run", str(test_file)])
-    assert ret == -1  # Dry run should not fail
+    ret, _ = run_clang_format(args + ["--dry-run", str(test_file)])
+    # Dry-run should succeed; use the parametrised expectation
+    assert ret == expected_retval
♻️ Duplicate comments (4)
tests/test_clang_tidy.py (1)

36-47: Same remark as above – can be removed once a module-level marker is used

tests/test_clang_format.py (3)

28-44: Same as previous comment – can be dropped after introducing a module-level marker.


72-87: Decorator duplication – see earlier suggestion about pytestmark.


89-104: Decorator duplication – see earlier suggestion about pytestmark.

🧹 Nitpick comments (7)
pyproject.toml (1)

52-53: Pin pytest-codspeed to a version range for deterministic CI
Leaving the dependency unpinned means the CI can suddenly break when a new major (or even minor) release introduces breaking changes. Consider constraining the version, e.g. pytest-codspeed>=0.4,<1.0.

-    "pytest-codspeed",
+    "pytest-codspeed>=0.4,<1.0",
tests/test_clang_tidy.py (1)

15-26: Prefer a module-level marker to avoid repetitive decorators
Instead of repeating @pytest.mark.benchmark on every test you can add once at the top of the module:

import pytest

pytestmark = pytest.mark.benchmark

This keeps the decorator stack small and the test body cleaner.

tests/test_util.py (1)

13-14: Use a module-level pytestmark to reduce noise
Repeated decorators make the file harder to scan; a single

pytestmark = pytest.mark.benchmark

at top level marks every test in the module.

tests/test_clang_format.py (1)

7-17: Consider one global benchmark mark instead of per-test decorators
A single pytestmark = pytest.mark.benchmark at the top of the file achieves the same effect with less duplication.

.github/workflows/codspeed.yml (3)

17-24: Enable pip caching to speed up installs

actions/setup-python@v5 supports cache: pip; enabling it cuts install time on subsequent runs.

       - uses: actions/setup-python@v5
         with:
-          python-version: "3.13"
+          python-version: "3.12"
+          cache: "pip"

23-23: Quote extras spec to avoid YAML flow-sequence quirks

Quoting makes it unambiguously a string.

-        run: pip install -e .[dev]
+        run: "pip install -e .[dev]"

4-8: Consider pull_request_target for benchmark reporting

pull_request_target runs on the base ref, giving the workflow access to secrets while still checking out the PR’s code, which often simplifies benchmark publishing.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70e1f52 and f872a26.

📒 Files selected for processing (6)
  • .github/workflows/codspeed.yml (1 hunks)
  • .gitignore (1 hunks)
  • pyproject.toml (1 hunks)
  • tests/test_clang_format.py (5 hunks)
  • tests/test_clang_tidy.py (2 hunks)
  • tests/test_util.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Run benchmarks
🔇 Additional comments (1)
.gitignore (1)

21-23: Good call on ignoring CodSpeed artefacts
The new .codspeed/ entry keeps benchmark results out of VCS – LGTM.

Copy link

codspeed-hq bot commented Jul 4, 2025

CodSpeed Performance Report

Congrats! CodSpeed is installed 🎉

🆕 31 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks

  • test_run_clang_format_dry_run[args0-1] (1.1 ms)
  • test_run_clang_format_invalid[args0-1] (1.1 ms)
  • test_run_clang_format_invalid[args1-1] (1.1 ms)
  • test_run_clang_format_invalid[args2-1] (1.1 ms)
  • test_run_clang_format_invalid[args3-1] (1.1 ms)
  • test_run_clang_format_invalid[args4-1] (551.9 µs)
  • test_run_clang_format_invalid[args5-1] (552.5 µs)
  • test_run_clang_format_valid[args0-expected_retval0] (1.3 ms)
  • test_run_clang_format_valid[args1-expected_retval1] (1.2 ms)
  • test_run_clang_format_valid[args2-expected_retval2] (1.2 ms)
  • test_run_clang_format_valid[args3-expected_retval3] (1.2 ms)
  • test_run_clang_format_valid[args4-expected_retval4] (689.5 µs)
  • test_run_clang_format_valid[args5-expected_retval5] (690.3 µs)
  • test_run_clang_format_verbose (1.3 ms)
  • test_run_clang_format_verbose_error (1.2 ms)
  • test_run_clang_tidy_invalid[args0-1] (1 ms)
  • test_run_clang_tidy_invalid[args1-1] (1 ms)
  • test_run_clang_tidy_invalid[args2-1] (1 ms)
  • test_run_clang_tidy_invalid[args3-1] (1 ms)
  • test_run_clang_tidy_invalid[args4-1] (463.2 µs)
  • test_run_clang_tidy_invalid[args5-1] (458.4 µs)
  • test_run_clang_tidy_valid[args0-1] (1.1 ms)
  • test_run_clang_tidy_valid[args1-1] (1.1 ms)
  • test_run_clang_tidy_valid[args2-1] (1.1 ms)
  • test_run_clang_tidy_valid[args3-1] (1.1 ms)
  • test_run_clang_tidy_valid[args4-1] (525.1 µs)
  • test_run_clang_tidy_valid[args5-1] (526.6 µs)
  • test_ensure_installed[clang-format-18] (1.8 ms)
  • test_ensure_installed[clang-format-None] (1.8 ms)
  • test_ensure_installed[clang-tidy-18] (1.8 ms)
  • test_ensure_installed[clang-tidy-None] (1.8 ms)

@shenxianpeng shenxianpeng merged commit 4c09c13 into main Jul 4, 2025
17 checks passed
@shenxianpeng shenxianpeng deleted the support-codespeed branch July 4, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant