Skip to content

Conversation

shenxianpeng
Copy link
Collaborator

@shenxianpeng shenxianpeng commented Oct 20, 2025

closes #123

Summary by CodeRabbit

  • Chores
    • Automated version detection for clang-format and clang-tidy is now scheduled weekly, running every Monday at 2:00 UTC via GitHub Actions.
    • Version updates from PyPI are automatically fetched and integrated, eliminating the need for manual version maintenance.

@shenxianpeng shenxianpeng marked this pull request as ready for review October 20, 2025 19:45
@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.44%. Comparing base (cb96c23) to head (75397a4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
+ Coverage   94.39%   94.44%   +0.05%     
==========================================
  Files           3        4       +1     
  Lines         107      108       +1     
==========================================
+ Hits          101      102       +1     
  Misses          6        6              

☔ 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.

@shenxianpeng shenxianpeng requested a review from Copilot October 20, 2025 19:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an automated system for updating clang-format and clang-tidy versions from PyPI. The implementation extracts version constants into a dedicated module and adds a Python script with GitHub Actions workflow to periodically fetch and update these versions.

Key changes:

  • Created a dedicated versions.py module containing version constants for clang-format and clang-tidy
  • Added an automation script that fetches latest versions from PyPI and updates the versions file
  • Configured a GitHub Actions workflow to run the update script weekly and create PRs with version updates

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cpp_linter_hooks/versions.py New module containing extracted version constants with automation-ready structure
scripts/update_versions.py Script that fetches versions from PyPI and updates the versions.py file programmatically
cpp_linter_hooks/util.py Refactored to import version constants from the new versions module instead of defining them inline
tests/test_util.py Updated imports to reference version constants from the new versions module
.github/workflows/update-versions.yml GitHub Actions workflow for automated weekly version updates via pull requests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 24 to 27
stable_versions = [
v
for v in versions
if not any(char in v for char in ["a", "b", "rc", "dev"])
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The pre-release filtering logic is flawed. Checking if single characters 'a' or 'b' exist in version strings will incorrectly filter out valid stable versions. For example, version '18.1.8' contains 'a' and would be excluded. Use regex pattern matching or check for specific pre-release patterns like 'alpha', 'beta', 'rc', 'dev' instead.

Suggested change
stable_versions = [
v
for v in versions
if not any(char in v for char in ["a", "b", "rc", "dev"])
# Exclude pre-releases: versions with 'aN', 'bN', 'rcN', or '.devN' suffixes
pre_release_pattern = re.compile(r"(a|b|rc|\.dev)\d+", re.IGNORECASE)
stable_versions = [
v
for v in versions
if not pre_release_pattern.search(v)

Copilot uses AI. Check for mistakes.

@shenxianpeng shenxianpeng changed the title feat: create script to update versions automaticlly feat: create script to update versions automatically Oct 20, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 20, 2025

CodSpeed Performance Report

Merging #132 will not alter performance

Comparing fix-123 (75397a4) with main (cb96c23)

Summary

✅ 60 untouched
⏩ 13 skipped1

Footnotes

  1. 13 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sonarqubecloud
Copy link

@shenxianpeng shenxianpeng added the enhancement New feature or request label Oct 20, 2025
@shenxianpeng shenxianpeng merged commit 805dfc4 into main Oct 20, 2025
17 of 18 checks passed
@shenxianpeng shenxianpeng deleted the fix-123 branch October 20, 2025 20:20
@coderabbitai
Copy link

coderabbitai bot commented Oct 20, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR implements automated version management for clang-format and clang-tidy tools. It creates a centralized versions module, a PyPI-based version fetcher script, and a GitHub Actions workflow that periodically updates version lists from PyPI. Existing imports are refactored to use the new centralized versions module.

Changes

Cohort / File(s) Summary
GitHub Actions Automation
.github/workflows/update-versions.yml
Introduces scheduled workflow (weekly on Mondays) that runs a Python script to update tool versions, checks for changes, and creates an automated pull request with updated version data.
Version Management Module
cpp_linter_hooks/versions.py
New module that centrally stores CLANG_FORMAT_VERSIONS and CLANG_TIDY_VERSIONS as hardcoded lists marked for automatic updates by GitHub Actions.
Version Update Script
scripts/update_versions.py
New script that fetches stable versions from PyPI API, filters out pre-releases, and updates cpp_linter_hooks/versions.py with new version lists. Includes fetch_versions_from_pypi() and update_versions_file() functions.
Import Refactoring
cpp_linter_hooks/util.py, tests/test_util.py
Updates to import version lists from cpp_linter_hooks.versions instead of defining them locally in util.py.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The changes span multiple components (CI workflow, new script with API/file I/O logic, module refactoring), but are cohesively scoped to version automation with clear separation of concerns. The PyPI API interaction and regex-based string replacement in the update script require careful review, while import refactoring is straightforward.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-123

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb96c23 and 75397a4.

📒 Files selected for processing (5)
  • .github/workflows/update-versions.yml (1 hunks)
  • cpp_linter_hooks/util.py (1 hunks)
  • cpp_linter_hooks/versions.py (1 hunks)
  • scripts/update_versions.py (1 hunks)
  • tests/test_util.py (1 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Update clang-tools version from PyPI

1 participant