DNM: Test component index ordering check workflow#6305
DNM: Test component index ordering check workflow#6305jesserockz wants to merge 2 commits intocurrentfrom
Conversation
✅ Deploy Preview for esphome ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Closing — the workflow uses |
There was a problem hiding this comment.
Pull request overview
This PR adds an automated check for ImgTable ordering in components/index.mdx (via a Node script + GitHub Actions workflow) and intentionally introduces a misordering in the Network Protocols table to exercise the workflow behavior.
Changes:
- Intentionally moves WireGuard out of alphabetical order in the Network Protocols
ImgTableto trigger a CI review. - Adds
script/check_component_index.mjsto detect/fix ordering and emit JSON suggestions for CI. - Adds
.github/workflows/check-component-index.ymlto run the script on PRs and post aREQUEST_CHANGESreview with inline suggestions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/content/docs/components/index.mdx |
Reorders multiple ImgTable blocks; intentionally breaks ordering in Network Protocols to test the checker. |
script/check_component_index.mjs |
Implements the ordering rule enforcement and suggestion generation for CI. |
.github/workflows/check-component-index.yml |
Runs the checker on PRs touching the index and posts/dismisses reviews accordingly. |
You can also share your feedback on Copilot code review. Take the survey.
| <ImgTable items={[ | ||
| ["Network Core", "/components/network/", "server-network.svg", "dark-invert"], | ||
| ["Native API", "/components/api/", "server-network.svg", "dark-invert"], | ||
| ["MQTT", "/components/mqtt/", "mqtt.png"], | ||
| ["WireGuard", "/components/wireguard/", "wireguard_custom_logo.svg", "dark-invert"], | ||
| ["ESP-NOW", "/components/espnow/", "esp-now.svg"], | ||
| ["HTTP Request", "/components/http_request/", "connection.svg", "dark-invert"], | ||
| ["mDNS", "/components/mdns/", "radio-tower.svg", "dark-invert"], | ||
| ["WireGuard", "/components/wireguard/", "wireguard_custom_logo.svg", "dark-invert"], | ||
| ["MQTT", "/components/mqtt/", "mqtt.png"], | ||
| ["Native API", "/components/api/", "server-network.svg", "dark-invert"], | ||
| ["Packet Transport", "/components/packet_transport/", "packet_transport.svg", "dark-invert"], | ||
| ["StatsD", "/components/statsd/", "connection.svg", "dark-invert"], | ||
| ["UDP", "/components/udp/", "udp.svg"], | ||
| ["Packet Transport", "/components/packet_transport/", "packet_transport.svg", "dark-invert"], | ||
| ["Zigbee End Device", "/components/zigbee/", "zigbee.svg"], |
| on: | ||
| pull_request_target: | ||
| types: [opened, reopened, synchronize] | ||
| paths: | ||
| - 'src/content/docs/components/index.mdx' |
| - name: Checkout PR head | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
|
| await github.rest.pulls.createReview({ | ||
| owner, | ||
| repo, | ||
| pull_number: pr_number, | ||
| commit_id: process.env.HEAD_SHA, |
| const sorted = [...restLines].sort((a, b) => | ||
| getName(a).toLowerCase().localeCompare(getName(b).toLowerCase()), | ||
| ); |
|
Caution Review failedPull request was closed or merged during review WalkthroughThis PR introduces automated validation of component index ordering via a new GitHub Actions workflow and Node.js script. The workflow runs on changes to the component index file, executes a sorting verification script, and posts review suggestions for any unsorted entries. The actual component index documentation is also updated with reordered and new entries. Changes
Sequence DiagramsequenceDiagram
actor PR as Pull Request Event
participant GHA as GitHub Actions
participant Script as check_component_index.mjs
participant FS as File System
participant API as GitHub API
PR->>GHA: Trigger on component index changes
GHA->>GHA: Checkout code
GHA->>GHA: Setup Node.js
GHA->>Script: Execute with --suggestions flag
Script->>FS: Read component index file
Script->>Script: Parse ImgTable blocks & validate ordering
Script->>Script: Generate suggestions if unsorted
Script->>FS: Write suggestions.json
Script-->>GHA: Exit with code (0=sorted, 1=unsorted)
alt Sorted
GHA->>API: Dismiss prior bot review
API-->>GHA: Success
else Unsorted
GHA->>GHA: Parse suggestions.json
GHA->>API: Post CHANGES_REQUESTED review
API->>API: Add inline suggestions per block
API-->>GHA: Review posted
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
Description
Do not merge — this PR intentionally moves WireGuard out of alphabetical order in the Network Protocols table to test the
check-component-indexworkflow from #6304.Expecting the workflow to post a
REQUEST_CHANGESreview with an inline suggestion showing the correct order.Related issue (if applicable): N/A
Pull request in esphome with YAML changes (if applicable):
Checklist
I am merging into
nextbecause this is new documentation that has a matching pull-request in esphome as linked above.or
I am merging into
currentbecause this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.Link added in
/src/content/docs/components/index.mdxwhen creating new documents for new components or cookbook.