Skip to content

test(docs): validate the Kubernetes manifest examples parse - #720

Open
veyron-kairo wants to merge 2 commits into
Project-HAMi:masterfrom
veyron-kairo:test/validate-doc-manifests
Open

test(docs): validate the Kubernetes manifest examples parse#720
veyron-kairo wants to merge 2 commits into
Project-HAMi:masterfrom
veyron-kairo:test/validate-doc-manifests

Conversation

@veyron-kairo

@veyron-kairo veyron-kairo commented Aug 4, 2026

Copy link
Copy Markdown

What this does

Adds a documentation test that validates the Kubernetes manifest examples in the docs actually parse, and fixes one that didn't.

Many pages show YAML the reader is expected to copy and kubectl apply. Nothing checked that those examples are valid, so a broken one could ship. This adds a node --test check (test/doc-manifests.test.mjs) that:

  • walks docs/, tutorials/, and the zh current/ docs;
  • takes the fenced yaml blocks that declare both apiVersion and kind — i.e. real manifests, not bare resources: snippets or the annotated example lists that deliberately repeat keys;
  • asserts each one parses.

Running it surfaced one broken example: the Chinese metax scheduling guide wrote the pod's annotations key and its value on a single line (annotations: hami.io/node-scheduler-policy: "spread"), which is invalid YAML. I fixed it to the nested form the English page already uses, in both current and the v2.9.0 snapshot (per the versioning workflow in AGENTS.md). Fixing the block also let Prettier format it, which added a space in a command: ["sleep", "infinity"] array on the same block.

Adds js-yaml as a devDependency for the check.

Checks

npm test, npm run lint, and npm run format:check pass. I confirmed the check fails (with a clear file (manifest #N): reason) when the manifest is left broken, so it guards against regressions rather than just passing today.

AI assistance disclosure

I used AI assistance (Claude Code) while locating the broken example. I reviewed and verified it, confirmed it catches the regression, ran the checks locally, and take responsibility for the change.

Summary by CodeRabbit

  • Documentation

    • Corrected MetaX GPU scheduling examples in the Chinese documentation.
    • Fixed YAML annotation nesting and formatting while preserving the existing spread scheduling behavior.
    • Updated both current and v2.9.0 documentation examples for consistency.
  • Tests

    • Added automated validation for YAML blocks in current documentation, helping detect malformed Kubernetes examples before publication.

Add a node --test check that walks the documentation, takes the fenced yaml
blocks that declare both apiVersion and kind (the manifests a reader would
apply), and asserts each one parses. Bare snippets and annotated example lists
are skipped, so it only holds real manifests to being valid.

This caught one broken example: the zh metax scheduling guide wrote the
annotations key and its value on a single line, which is invalid YAML. Fix it to
the nested form the en page already uses, in both current and the v2.9.0
snapshot. Add js-yaml as a devDependency for the check.

Signed-off-by: Shridhar Panigrahi <198173519+veyron-kairo@users.noreply.github.com>
@hami-robot

hami-robot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: veyron-kairo
Once this PR has been reviewed and has the lgtm label, please assign wawa0210 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for project-hami ready!

Name Link
🔨 Latest commit 6146d9f
🔍 Latest deploy log https://app.netlify.com/projects/project-hami/deploys/6a72319e29c0c90008f2f78e
😎 Deploy Preview https://deploy-preview-720--project-hami.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hami-robot hami-robot Bot added the size/L label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@veyron-kairo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 43244bb1-c7e1-4fa9-8b44-71dfe236893a

📥 Commits

Reviewing files that changed from the base of the PR and between e43487b and 6146d9f.

📒 Files selected for processing (1)
  • test/doc-manifests.test.mjs
📝 Walkthrough

Walkthrough

本次变更修正 MetaX GPU 文档示例的 YAML 注解结构,并新增测试扫描和解析当前文档中的 Kubernetes 风格 YAML 代码块。

Changes

文档 YAML 结构与校验

Layer / File(s) Summary
修正 MetaX GPU YAML 示例
i18n/zh/docusaurus-plugin-content-docs/current/userguide/metax-device/metax-gpu/enable-metax-gpu-schedule.md, i18n/zh/docusaurus-plugin-content-docs/version-v2.9.0/userguide/metax-device/metax-gpu/enable-metax-gpu-schedule.md
将调度策略注解放入 metadata.annotations,并保留 spread 策略。当前版本示例同时规范了 command 数组格式。
新增文档 YAML 解析测试
test/doc-manifests.test.mjs, package.json
新增测试扫描当前文档中的 Kubernetes 风格 YAML 代码块,并使用 js-yaml 报告带文件和代码块位置的解析错误。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: kind/bug

Suggested reviewers: rootsongjc, mesutoezdil

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a test that validates Kubernetes manifest examples in documentation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot added the kind/bug Something isn't working label Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/doc-manifests.test.mjs`:
- Line 16: Update the documentation traversal that builds markdownFiles to use
readdirSync with withFileTypes enabled, and recurse only when
entry.isDirectory() is true; avoid statSync so directory symlinks are not
followed and traversal cannot loop.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dcef705c-66be-4b33-b650-6f1372461407

📥 Commits

Reviewing files that changed from the base of the PR and between c0e0f77 and e43487b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • i18n/zh/docusaurus-plugin-content-docs/current/userguide/metax-device/metax-gpu/enable-metax-gpu-schedule.md
  • i18n/zh/docusaurus-plugin-content-docs/version-v2.9.0/userguide/metax-device/metax-gpu/enable-metax-gpu-schedule.md
  • package.json
  • test/doc-manifests.test.mjs

Comment thread test/doc-manifests.test.mjs Outdated
Use readdirSync withFileTypes and Dirent.isDirectory/isFile instead of statSync,
which follows symlinks and could recurse outside the docs tree. Addresses review
feedback.

Signed-off-by: Shridhar Panigrahi <198173519+veyron-kairo@users.noreply.github.com>
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.

1 participant