Skip to content

build: Detect version bump to permit "release: " prefix#11638

Merged
edsiper merged 1 commit intomasterfrom
cosmo0920-detect-bump-version-on-CMakeLists.txt
Mar 31, 2026
Merged

build: Detect version bump to permit "release: " prefix#11638
edsiper merged 1 commit intomasterfrom
cosmo0920-detect-bump-version-on-CMakeLists.txt

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

@cosmo0920 cosmo0920 commented Mar 31, 2026

Version bumping process that we always use needs to use release: prefix but this rule is not implemented in our linter. So, we need to handle this.


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:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

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

  • Chores
    • Enhanced commit validation for version bump releases. Version update commits now require the release: prefix in the commit message and cannot include unrelated changes.
    • Added automated tests to verify release commit validation behavior.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

The changes add validation logic to ensure commits modifying version information in CMakeLists.txt must use the release: prefix. A new internal is_version_bump() check inspects commit diffs and enforces this requirement within the existing commit validation pipeline.

Changes

Cohort / File(s) Summary
Version Bump Validation Logic
.github/scripts/commit_prefix_check.py
Added is_version_bump() function to detect version changes in CMakeLists.txt and integrated a release special rule into validate_commit() requiring release: prefix for version-bumping commits.
Release Validation Tests
.github/scripts/tests/test_commit_lint.py
Added fake git object helpers (FakeDiff, FakeStats, FakeCommit) and two new test cases validating acceptance of valid release commits and rejection of release commits with extraneous changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #11251: Modifies validate_commit() in the same file with different prefix inference/validation logic.
  • #11245: Updates validate_commit() logic with alternate special-case prefix handling.
  • #11346: Adds special-case prefix rules to validate_commit() for config_format umbrella handling.

Suggested labels

docs-required

Suggested reviewers

  • niedbalski
  • patrick-stephens
  • celalettin1286

Poem

🐰 Hops with glee at version guards,
Release commits now catch the cards!
A bumpy road? Check twice with care,
No sneaky changes hiding there! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding version bump detection to permit the 'release:' prefix in commit messages.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-detect-bump-version-on-CMakeLists.txt

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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: e29e2b3161

ℹ️ 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".

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 (3)
.github/scripts/tests/test_commit_lint.py (2)

926-936: Consider adding hexsha for robustness.

FakeCommit is missing the hexsha attribute which validate_commit uses in the GitCommandError handling (line 264 in the main file). While current tests won't trigger that path, adding it would make the fake more complete and prevent potential AttributeError if error handling paths are tested later.

♻️ Suggested addition
 class FakeCommit:
     def __init__(self, message, diffs):
         self.message = message
         self._diffs = diffs
         self.parents = [object()]
+        self.hexsha = "deadbeef1234"
 
         file_paths = [d.b_path for d in diffs]
         self.stats = FakeStats(file_paths)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/tests/test_commit_lint.py around lines 926 - 936, FakeCommit
used in tests lacks the hexsha attribute that validate_commit references when
handling GitCommandError; add a hexsha field to FakeCommit (e.g., self.hexsha =
some stable dummy value or derived from the message) so error-handling paths
that access commit.hexsha won’t raise AttributeError; update the FakeCommit
__init__ to set self.hexsha while keeping existing behavior of message, _diffs,
parents, and stats.

964-977: Consider asserting the error message for clarity.

The test passes, but the rejection reason differs from what one might expect. When CMakeLists.txt has non-version changes, is_version_bump() returns False, and normal validation fails because release: is not in the expected prefixes (only build: is inferred).

Adding an assertion on the error message would document the expected behavior and catch regressions:

♻️ Suggested improvement
-    ok, _ = validate_commit(commit)
+    ok, msg = validate_commit(commit)
     assert ok is False
+    assert "does not match files changed" in msg or "Expected one of: build:" in msg

Also, consider adding a test for a pure version bump with the wrong prefix (e.g., build: instead of release:):

def test_version_bump_requires_release_prefix():
    """Version bumps must use the release: prefix, not other prefixes."""
    commit = make_fake_commit(
        "build: bump version to 5.0.2\n\nSigned-off-by: User",
        [("CMakeLists.txt", "-set(FLB_VERSION_PATCH  0)\n+set(FLB_VERSION_PATCH  2)\n")]
    )
    ok, msg = validate_commit(commit)
    assert ok is False
    assert "Version bump must use release: prefix" in msg
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/tests/test_commit_lint.py around lines 964 - 977, Update the
test to assert the expected rejection message so behavior is explicit: in
test_release_rejected_when_cmakelists_has_non_version_change, after calling
validate_commit(commit) assert ok is False and also assert the returned message
contains the expected text (use the actual rejection string returned by
validate_commit/is_version_bump logic). Additionally add the suggested new test
(test_version_bump_requires_release_prefix) that constructs a pure version
change but with the wrong prefix and asserts validate_commit returns False and
the message contains the "Version bump must use release: prefix" text; reference
validate_commit and is_version_bump to locate the validation paths to confirm
the exact message to assert against.
.github/scripts/commit_prefix_check.py (1)

193-220: Consider limiting version detection to root CMakeLists.txt only.

The check path.endswith("CMakeLists.txt") matches any CMakeLists.txt in the repository (root, plugins/*/CMakeLists.txt, lib/*/CMakeLists.txt, etc.). If a release commit updates the version in root CMakeLists.txt but also touches a subdirectory CMakeLists.txt for a legitimate reason (e.g., updating a dependency version), is_version_bump() would return False and the commit would fail normal validation because release: is not an inferred prefix.

If this is intentional (release commits should only touch root version numbers), consider adding a comment explaining this constraint. Otherwise, restrict to the root file:

♻️ Proposed fix to restrict to root CMakeLists.txt
-            if not path.endswith("CMakeLists.txt"):
+            if path != "CMakeLists.txt":
                 continue
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/commit_prefix_check.py around lines 193 - 220, The current
check treats any CMakeLists.txt as the root version file (uses
path.endswith("CMakeLists.txt")), which causes is_version_bump() to fail when
submodule or plugin CMake files are changed; update the condition to only
consider the repository root file (e.g., require path == "CMakeLists.txt" or
normalize and compare to the exact root path) in the loop that processes diffs,
and add a short comment in the is_version_bump() function explaining that only
the root CMakeLists.txt is checked (or keep the existing behavior but document
it) so future readers understand the constraint.
🤖 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/scripts/commit_prefix_check.py:
- Around line 193-220: The current check treats any CMakeLists.txt as the root
version file (uses path.endswith("CMakeLists.txt")), which causes
is_version_bump() to fail when submodule or plugin CMake files are changed;
update the condition to only consider the repository root file (e.g., require
path == "CMakeLists.txt" or normalize and compare to the exact root path) in the
loop that processes diffs, and add a short comment in the is_version_bump()
function explaining that only the root CMakeLists.txt is checked (or keep the
existing behavior but document it) so future readers understand the constraint.

In @.github/scripts/tests/test_commit_lint.py:
- Around line 926-936: FakeCommit used in tests lacks the hexsha attribute that
validate_commit references when handling GitCommandError; add a hexsha field to
FakeCommit (e.g., self.hexsha = some stable dummy value or derived from the
message) so error-handling paths that access commit.hexsha won’t raise
AttributeError; update the FakeCommit __init__ to set self.hexsha while keeping
existing behavior of message, _diffs, parents, and stats.
- Around line 964-977: Update the test to assert the expected rejection message
so behavior is explicit: in
test_release_rejected_when_cmakelists_has_non_version_change, after calling
validate_commit(commit) assert ok is False and also assert the returned message
contains the expected text (use the actual rejection string returned by
validate_commit/is_version_bump logic). Additionally add the suggested new test
(test_version_bump_requires_release_prefix) that constructs a pure version
change but with the wrong prefix and asserts validate_commit returns False and
the message contains the "Version bump must use release: prefix" text; reference
validate_commit and is_version_bump to locate the validation paths to confirm
the exact message to assert against.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4abadb67-1009-448a-b0fc-23bac808fe25

📥 Commits

Reviewing files that changed from the base of the PR and between 680f14c and e29e2b3.

📒 Files selected for processing (2)
  • .github/scripts/commit_prefix_check.py
  • .github/scripts/tests/test_commit_lint.py

@edsiper edsiper merged commit 3152192 into master Mar 31, 2026
11 checks passed
@edsiper edsiper deleted the cosmo0920-detect-bump-version-on-CMakeLists.txt branch March 31, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants