ci: add separate clang-format check workflow#15
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughA new GitHub Actions workflow is added that automatically checks C++ code formatting on pull requests. The workflow installs clang-format and runs a dry-run validation with error reporting enabled on all tracked .cpp and .h files. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/format.yml (2)
21-22: The added C++ extensions are not necessary for the current codebase, but adding-rtoxargsis recommended as a defensive practice.The repository currently tracks only
*.cppand*.hfiles (11 and 12 files respectively), so the current pattern covers all C++ files. However, adding the-rflag toxargsis still a good practice to prevent the command from executingclang-formatif no files match the pattern.🔧 Suggested change
- name: Check formatting run: | - git ls-files -z '*.cpp' '*.h' | xargs -0 clang-format --dry-run --Werror + git ls-files -z '*.cpp' '*.h' | xargs -0 -r clang-format --dry-run --Werror🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/format.yml around lines 21 - 22, Update the workflow run step that pipes git ls-files -z to xargs so xargs is invoked with the -r (or --no-run-if-empty) option to avoid calling clang-format when no files match; specifically modify the command that uses git ls-files -z '*.cpp' '*.h' | xargs -0 clang-format --dry-run --Werror to add -r to the xargs invocation while keeping the existing patterns and clang-format flags unchanged.
17-18: Pinclang-formatversion to avoid CI drift.Unpinned
clang-formatwill use whatever version is available in the runner's apt repository, which can change with runner image updates. While installingclang-format-18pins the major version, the patch version (currently 18.1.3 on ubuntu-latest) may still drift.For more reliable version control, consider using
KyleMayes/install-llvm-actionto install an exact LLVM/Clang version, or use a dedicated clang-format action likeDoozyX/clang-format-lint-actionthat supports pinning specific patch versions. If using apt, at minimum pin the runner OS toubuntu-24.04alongside the major version to reduce unexpected changes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/format.yml around lines 17 - 18, The "Install clang-format" CI step currently installs an unpinned clang-format via apt; change it to a deterministic installer: replace the apt install step with a pinned installer action (e.g., use KyleMayes/install-llvm-action with the exact LLVM/Clang version or DoozyX/clang-format-lint-action that supports specific patch pins) or, if you must use apt, pin both the package (e.g., clang-format-18) and the runner OS (ubuntu-24.04) to reduce drift; update the workflow step named "Install clang-format" to call the chosen action and specify the exact version string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/format.yml:
- Around line 21-22: Update the workflow run step that pipes git ls-files -z to
xargs so xargs is invoked with the -r (or --no-run-if-empty) option to avoid
calling clang-format when no files match; specifically modify the command that
uses git ls-files -z '*.cpp' '*.h' | xargs -0 clang-format --dry-run --Werror to
add -r to the xargs invocation while keeping the existing patterns and
clang-format flags unchanged.
- Around line 17-18: The "Install clang-format" CI step currently installs an
unpinned clang-format via apt; change it to a deterministic installer: replace
the apt install step with a pinned installer action (e.g., use
KyleMayes/install-llvm-action with the exact LLVM/Clang version or
DoozyX/clang-format-lint-action that supports specific patch pins) or, if you
must use apt, pin both the package (e.g., clang-format-18) and the runner OS
(ubuntu-24.04) to reduce drift; update the workflow step named "Install
clang-format" to call the chosen action and specify the exact version string.
Summary by CodeRabbit