feat: add config example validation script and workflow#2627
feat: add config example validation script and workflow#2627patrick-stephens wants to merge 25 commits into
Conversation
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
| Validates all Fluent Bit configuration examples in Markdown files by running them through `fluent-bit --dry-run`. | ||
|
|
||
| **Usage:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
| This approach ensures that extraction errors are always legitimate—never due to reaching the end of examples. Any extraction error indicates a genuine problem with the file structure. | ||
|
|
||
| **Features:** | ||
| - Supports multiple examples per Markdown file (processes all examples) |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Supports multiple examples p..."]
| - Only reports errors that are legitimate (malformed examples or configuration issues) | ||
|
|
||
| **Example - validate a single file:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
| ``` | ||
|
|
||
| **Example - validate all documentation files:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
| Extracts Fluent Bit configuration code blocks from Markdown files. This is used internally by `test-config.sh` but can also be called directly. | ||
|
|
||
| **Usage:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
| ``` | ||
|
|
||
| **Parameters:** | ||
| - `markdown-file`: Path to the Markdown file |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- markdown-file: Path to the..."]
| Validates all Fluent Bit configuration examples in Markdown files by running them through `fluent-bit --dry-run`. | ||
|
|
||
| **Usage:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| This approach ensures that extraction errors are always legitimate—never due to reaching the end of examples. Any extraction error indicates a genuine problem with the file structure. | ||
|
|
||
| **Features:** | ||
| - Supports multiple examples per Markdown file (processes all examples) |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| - Supports multiple examples per Markdown file (processes all examples) | |
| - Supports multiple examples per Markdown file (processes all examples) |
| - Only reports errors that are legitimate (malformed examples or configuration issues) | ||
|
|
||
| **Example - validate a single file:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| ``` | ||
|
|
||
| **Example - validate all documentation files:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| Extracts Fluent Bit configuration code blocks from Markdown files. This is used internally by `test-config.sh` but can also be called directly. | ||
|
|
||
| **Usage:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| ``` | ||
|
|
||
| **Parameters:** | ||
| - `markdown-file`: Path to the Markdown file |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| - `markdown-file`: Path to the Markdown file | |
| - `markdown-file`: Path to the Markdown file |
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
…in TOML format Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
| - `index|count` (Optional): Extract a specific example by index, or use `count` to get the total number of examples. Defaults to 1 (first example) | ||
|
|
||
| **Features:** | ||
| - Automatically removes common leading indentation from extracted examples |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Automatically removes common..."]
| - Preserves relative indentation within the configuration | ||
|
|
||
| **Examples:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
| **Count mode:** | ||
|
|
||
| The `count` parameter returns the total number of matching code fences for the specified language in the given tab. This is used by `test-config.sh` to: | ||
| 1. Determine how many examples to validate |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Determine how many examples..."]
| 3. Ensure all extraction errors are legitimate | ||
|
|
||
| Example output: | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
| ```yaml | ||
| service: | ||
| flush: 1 | ||
| ``` |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
| {% tab title="fluent-bit.yaml" %} | ||
| ```yaml | ||
| # First example YAML | ||
| ``` |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
|
|
||
| {% tabs %} | ||
| {% tab title="fluent-bit.yaml" %} | ||
| ```yaml |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```yaml"]
| {% tab title="fluent-bit.yaml" %} | ||
| ```yaml | ||
| # Second example YAML | ||
| ``` |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
| ``` | ||
| {% endtab %} | ||
| {% endtabs %} | ||
| ``` |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
| ``` | ||
| {% endtab %} | ||
| {% endtabs %} | ||
| ``` |
There was a problem hiding this comment.
[markdownlint] reported by reviewdog 🐶
error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
| - `index|count` (Optional): Extract a specific example by index, or use `count` to get the total number of examples. Defaults to 1 (first example) | ||
|
|
||
| **Features:** | ||
| - Automatically removes common leading indentation from extracted examples |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| - Automatically removes common leading indentation from extracted examples | |
| - Automatically removes common leading indentation from extracted examples |
| - Preserves relative indentation within the configuration | ||
|
|
||
| **Examples:** | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| **Count mode:** | ||
|
|
||
| The `count` parameter returns the total number of matching code fences for the specified language in the given tab. This is used by `test-config.sh` to: | ||
| 1. Determine how many examples to validate |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| 1. Determine how many examples to validate | |
| 1. Determine how many examples to validate |
| 3. Ensure all extraction errors are legitimate | ||
|
|
||
| Example output: | ||
| ```bash |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| service: | ||
| flush: 1 | ||
| ``` | ||
| {% endtab %} |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| {% endtab %} | |
| {% endtab %} |
| ``` | ||
| {% endtab %} | ||
| {% endtabs %} | ||
| ``` |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ``` | |
| ``` |
| ```yaml | ||
| # First example YAML | ||
| ``` | ||
| {% endtab %} |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| {% endtab %} | |
| {% endtab %} |
|
|
||
| {% tabs %} | ||
| {% tab title="fluent-bit.yaml" %} | ||
| ```yaml |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ```yaml | |
| ```yaml |
| ```yaml | ||
| # Second example YAML | ||
| ``` | ||
| {% endtab %} |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| {% endtab %} | |
| {% endtab %} |
| ``` | ||
| {% endtab %} | ||
| {% endtabs %} | ||
| ``` |
There was a problem hiding this comment.
[markdownlint-fix] reported by reviewdog 🐶
| ``` | |
| ``` |
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
ba1f42c to
56630f1
Compare
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Resolves #2459 by providing a simple AWK based approach to validating configuration examples:
--dry-runthe configuration and report success/failureA local script is provided that can be run for any file in the repo or all of them:
A workflow is provided to run this for any files changed in a PR so if an update is made to documentation it should check it is valid.
There is a basic suppression approach by file as there are some valid reasons for this:
execare not part of the container imageAs part of these changes we also found failures in existing files that were resolved.
Some tweaks were also required, e.g. parser definition must be in a separate file for legacy TOML config so it was updated to be a comment for the examples (which would be rejected anyway otherwise).
There are options to use something more complex like markdown-tree or similar to build an AST from the Markdown file to then pull out the bits we need but this may not work with the specific Gitbook format anyway and requires a whole load of extra dependencies.
Currently there is an upstream failure with certain plugins triggering a segmentation fault for
--dry-run: fluent/fluent-bit#12113This is resolved by plugins: fix dry-run segmentation faults fluent-bit#12114 so waiting on that to merge.