Skip to content

Commit 2ee617d

Browse files
committed
github: scripts: tests: Add a test case for skipping validation on code blocks
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 24782f0 commit 2ee617d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/scripts/tests/test_commit_lint.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,31 @@ def test_valid_commit_bin_prefix_for_fluent_bit():
183183
assert ok is True
184184

185185

186+
def test_valid_commit_with_fenced_code_block_in_body():
187+
"""
188+
Commits containing fenced code blocks in the body should NOT fail validation.
189+
190+
Code blocks often include YAML, shell output, or logs that may look like
191+
subject prefixes or configuration directives. These must be ignored by
192+
the linter to avoid false positives.
193+
"""
194+
commit = make_commit(
195+
"out_s3: validate config earlier\n\n"
196+
"This commit improves validation.\n\n"
197+
"```yaml\n"
198+
"pipeline:\n"
199+
" inputs:\n"
200+
" - name: dummy\n"
201+
" tag: test\n"
202+
"```\n\n"
203+
"Signed-off-by: User",
204+
["plugins/out_s3/s3.c"]
205+
)
206+
207+
ok, msg = validate_commit(commit)
208+
assert ok is True
209+
210+
186211
# -----------------------------------------------------------
187212
# Tests: validate_commit ERROR CASES
188213
# -----------------------------------------------------------

0 commit comments

Comments
 (0)