-
Notifications
You must be signed in to change notification settings - Fork 1.9k
github: scripts: commit_prefix_check: add config format rules on linter #11346
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
Conversation
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
📝 WalkthroughWalkthroughThis change updates commit-prefix inference for Changes
Sequence Diagram(s)(omitted — changes are linting/control logic confined to a single script and tests) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8b6366650
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.github/scripts/commit_prefix_check.py (1)
183-193: Clarify error message or remove unused variables.Lines 188-189 compute
expected_listandexpected_strbut line 192 hardcodes"Expected one of: config_format:"in the error message. This creates two issues:
- The computed variables are unused (dead code).
- If other valid prefixes like
build:are also inferred, the error message doesn't mention them, which could confuse users.Consider either:
- Using
expected_strin the message to show all valid options, or- Removing lines 188-189 and adding a comment explaining why only
config_format:is shown (if the strict enforcement is intentional regardless of other prefixes).🔎 Option 1: Use expected_str to show all valid prefixes
if "config_format:" in expected_lower and subj_lower != "config_format:": expected_list = sorted(expected) expected_str = ", ".join(expected_list) return False, ( f"Subject prefix '{subject_prefix}' does not match files changed.\n" - f"Expected one of: config_format:" + f"Files under config_format/ require 'config_format:' prefix.\n" + f"All inferred prefixes: {expected_str}" )🔎 Option 2: Remove unused variables and clarify intent
if "config_format:" in expected_lower and subj_lower != "config_format:": - expected_list = sorted(expected) - expected_str = ", ".join(expected_list) return False, ( f"Subject prefix '{subject_prefix}' does not match files changed.\n" - f"Expected one of: config_format:" + f"Files under config_format/ require the umbrella prefix 'config_format:'" ).github/scripts/tests/test_commit_lint.py (1)
625-693: LGTM: Comprehensive test coverage for config_format strict rule.The four new test cases effectively validate the strict
config_format:prefix requirement:
- ✅ Valid usage with umbrella prefix
- ✅ Rejection of internal implementation prefix (
cf_yaml:)- ✅ Rejection of generic prefix (
yaml:)- ✅ Multiple config_format files requiring umbrella prefix
The tests are well-documented with clear docstrings explaining the intent and behavior.
Optional enhancement: Consider adding a test case for the mixed scenario where both config_format files and other component files are modified together, to explicitly document the expected behavior:
📝 Suggested test case for mixed component scenario
def test_config_format_mixed_with_other_components(): """ Test behavior when both config_format and non-config_format files are modified. This documents whether commits can use config_format: as an umbrella to cover changes in both config_format/ and other components, or if such changes must be split into separate commits. """ commit = make_commit( "config_format: update yaml parser and router\n\nSigned-off-by: User", [ "src/config_format/flb_cf_yaml.c", "src/flb_router.c" ] ) ok, msg = validate_commit(commit) # Update assertion based on intended behavior: # assert ok is False # if config_format should be isolated # assert ok is True # if umbrella can cover mixed changes
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/scripts/commit_prefix_check.py.github/scripts/tests/test_commit_lint.py
🧰 Additional context used
🧬 Code graph analysis (1)
.github/scripts/tests/test_commit_lint.py (1)
.github/scripts/commit_prefix_check.py (1)
validate_commit(136-238)
🔇 Additional comments (2)
.github/scripts/commit_prefix_check.py (2)
65-86: LGTM: Clear handling of src/ path patterns.The refactored src/ handling correctly distinguishes between:
src/fluent-bit.c→bin:src/flb_*.c→ extracted component namesrc/<dir>/...→ directory nameThe use of
continuestatements prevents cascading else logic and makes the flow easier to follow.
208-208: Add test case for mixed config_format + other component scenario.The umbrella prefix logic allows
config_format:to cover multiple config_format files, which is correct. However, there is no test coverage for commits that mix config_format files with other components (e.g.,["src/config_format/flb_cf_yaml.c", "src/flb_router.c"]with subjectconfig_format:).The current code would allow such mixed commits due to line 212's umbrella prefix check, creating an inconsistency with the strict rule's intent. Compare:
in_tail: + ["plugins/in_tail/tail.c", "src/flb_router.c"]→ rejected (in_tail not an umbrella)config_format: + ["src/config_format/...", "src/flb_router.c"]→ allowed (config_format is an umbrella)Either the design should be clarified as intentional (config_format can span multiple subsystems) or a stricter constraint should be added to prevent mixing. Add a test case to explicitly validate the expected behavior.
Signed-off-by: Hiroshi Hatake <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI Agents
In @.github/scripts/commit_prefix_check.py:
- Around line 188-192: Remove the unused variables or use them in the error
message: either delete the lines that create expected_list and expected_str, or
include expected_str in the returned error; update the message in the function
that returns (False, ...) so it reads something like "Subject prefix
'{subject_prefix}' does not match files changed. Expected prefix:
{expected_str}" (use the existing expected variable values or the computed
expected_str) and ensure the wording reflects a single valid prefix instead of
"Expected one of:"; adjust references in the function that builds this error
accordingly (function handling subject_prefix validation in
commit_prefix_check.py).
🧹 Nitpick comments (1)
.github/scripts/commit_prefix_check.py (1)
199-202: Consider removing the unused exclusion.The check for
"cmakelists.txt:"on line 201 excludes a prefix that is never added toexpected_lower. Only"build:"is added whenCMakeLists.txtfiles are encountered (lines 47-48). While harmless, this check is unnecessary.🔎 Optional cleanup
if "config_format:" in expected_lower: non_build = { p for p in expected_lower - if p not in ("build:", "cmakelists.txt:") + if p != "build:" }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/scripts/commit_prefix_check.py
🔇 Additional comments (2)
.github/scripts/commit_prefix_check.py (2)
65-86: Refactoring improves readability.The explicit handling of
src/paths with earlycontinuestatements makes the logic clearer and easier to follow. The three cases are well-separated:
src/fluent-bit.c→bin:src/flb_*.c→ component prefixsrc/<dir>/...→ directory prefix
224-224: Correctly addresses past review feedback.Removing
config_format:from the umbrella list is appropriate. With the updatedinfer_prefix_from_pathslogic (lines 82-84), paths undersrc/config_format/directly map toconfig_format:, so umbrella handling is no longer needed. The strict validation rules (lines 183-210) ensure proper enforcement of theconfig_format:prefix.This change resolves the concern raised in the past review comment.
Signed-off-by: Hiroshi Hatake <[email protected]>
I supported to handle
config_format:prefix for committing underconfig_formatdirectory.This PR resolves the following linting error on #11345:
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.