Skip to content

ci: add separate clang-format check workflow#15

Merged
aagra109 merged 2 commits into
mainfrom
chore/add-ci-workflow
Mar 1, 2026
Merged

ci: add separate clang-format check workflow#15
aagra109 merged 2 commits into
mainfrom
chore/add-ci-workflow

Conversation

@aagra109
Copy link
Copy Markdown
Owner

@aagra109 aagra109 commented Mar 1, 2026

Summary by CodeRabbit

  • Chores
    • Introduced automated code formatting validation in the continuous integration pipeline to ensure consistent formatting standards for C++ code across pull requests.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 1, 2026

Warning

Rate limit exceeded

@aagra109 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between a8c381f and b933dfa.

📒 Files selected for processing (8)
  • src/command_exec.cpp
  • src/exit_codes.h
  • src/free_command.cpp
  • src/list_command.cpp
  • src/port_inspection.cpp
  • src/usage.cpp
  • src/who_command.cpp
  • tests/unit_tests.cpp
📝 Walkthrough

Walkthrough

A 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

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/format.yml
New workflow triggered on pull requests that performs automated clang-format validation with --Werror to enforce code formatting standards across C++ files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A neat workflow hops into view,
Clang-format checking what's new,
C++ files in a line,
Now formatted so fine! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a separate clang-format check workflow to the CI configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/add-ci-workflow

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

Copy link
Copy Markdown

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

🧹 Nitpick comments (2)
.github/workflows/format.yml (2)

21-22: The added C++ extensions are not necessary for the current codebase, but adding -r to xargs is recommended as a defensive practice.

The repository currently tracks only *.cpp and *.h files (11 and 12 files respectively), so the current pattern covers all C++ files. However, adding the -r flag to xargs is still a good practice to prevent the command from executing clang-format if 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: Pin clang-format version to avoid CI drift.

Unpinned clang-format will use whatever version is available in the runner's apt repository, which can change with runner image updates. While installing clang-format-18 pins 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-action to install an exact LLVM/Clang version, or use a dedicated clang-format action like DoozyX/clang-format-lint-action that supports pinning specific patch versions. If using apt, at minimum pin the runner OS to ubuntu-24.04 alongside 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.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83be545 and a8c381f.

📒 Files selected for processing (1)
  • .github/workflows/format.yml

@aagra109 aagra109 merged commit 14d00aa into main Mar 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant