feat(link-resolver): update release links to point to stable URLs for… - #722
feat(link-resolver): update release links to point to stable URLs for…#722shhdgit wants to merge 4 commits into
Conversation
… tidb-in-kubernetes
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughTiDB-in-Kubernetes release notes from ChangesRelease URL Mappings
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TOC
participant linkResolver
participant PublishedURL
TOC->>linkResolver: resolve release-note link
linkResolver->>PublishedURL: map main or operator release to stable
PublishedURL-->>TOC: return resolved URL with preserved context
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@gatsby/URL_MAPPING_ARCHITECTURE.md`:
- Line 405: Update the wildcard mapping examples in the architecture
documentation, including both occurrences of the release mapping, to use an
unambiguous literal form such as release-* → v* or inline code. Preserve the
mapping’s meaning and the surrounding documentation.
In `@gatsby/url-resolver/config.ts`:
- Around line 142-148: Update the TOC-filtered node processing in createDocs to
deduplicate entries by their resolved path before cpMarkdown and createPage run,
retaining the main release-note source over the stable source when both resolve
to the same path. Preserve the existing URL resolver behavior and add
resolver/build integration coverage for both main and stable inputs.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 81e04eca-74ea-48ec-b22d-188a73ed8109
📒 Files selected for processing (5)
gatsby/URL_MAPPING_ARCHITECTURE.mdgatsby/link-resolver/__tests__/link-resolver.test.tsgatsby/link-resolver/config.tsgatsby/url-resolver/__tests__/url-resolver.test.tsgatsby/url-resolver/config.ts
| // tidb-in-kubernetes release notes from main | ||
| // Release notes from main override the copies from the stable release branch. | ||
| // /en/tidb-in-kubernetes/main/releases/{filename} -> /en/tidb-in-kubernetes/stable/{filename} | ||
| { | ||
| sourcePattern: "/{lang}/tidb-in-kubernetes/main/releases/{filename}", | ||
| targetPattern: "/{lang}/tidb-in-kubernetes/stable/{filename}", | ||
| }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 4 'createPage|calculateFileUrl|filterNodesByToc' \
gatsby/create-pages/create-docs.ts gatsby -g '*.ts'
rg -n -C 2 'tidb-in-kubernetes/(main|stable)/releases' \
docs/markdown-pages gatsbyRepository: pingcap/website-docs
Length of output: 50376
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- config rule ---\n'
sed -n '120,180p' gatsby/url-resolver/config.ts
printf '\n--- calculateFileUrl implementation ---\n'
sed -n '136,220p' gatsby/url-resolver/url-resolver.ts
sed -n '300,330p' gatsby/url-resolver/url-resolver.ts
printf '\n--- createDocs creation path ---\n'
sed -n '50,165p' gatsby/create-pages/create-docs.ts
printf '\n--- toc filter relevant implementation ---\n'
sed -n '130,225p' gatsby/toc-filter.ts
printf '\n--- existing tidb-in-kubernetes main/stable release resolver tests ---\n'
sed -n '360,405p' gatsby/url-resolver/__tests__/url-resolver.test.tsRepository: pingcap/website-docs
Length of output: 249
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- config rule ---'
sed -n '120,180p' gatsby/url-resolver/config.ts
echo
echo '--- calculateFileUrl implementation ---'
sed -n '136,220p' gatsby/url-resolver/url-resolver.ts
sed -n '300,330p' gatsby/url-resolver/url-resolver.ts
echo
echo '--- createDocs creation path ---'
sed -n '50,165p' gatsby/create-pages/create-docs.ts
echo
echo '--- toc filter relevant implementation ---'
sed -n '130,225p' gatsby/toc-filter.ts
echo
echo '--- existing tidb-in-kubernetes main/stable release resolver tests ---'
sed -n '360,405p' gatsby/url-resolver/__tests__/url-resolver.test.tsRepository: pingcap/website-docs
Length of output: 13819
Prevent both main and stable release notes from creating the same page.
main/releases/{filename} maps to /stable/{filename} using the first matching rule, but createDocs still iterates all TOC-filtered nodes before cpMarkdown and createPage. If a stable release note exists for the same file, publishing order can override the intended main-source override. Deduplicate by resolved path, keep a preferred source (main > stable), and cover both sources in a resolver/build integration test.
🤖 Prompt for 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.
In `@gatsby/url-resolver/config.ts` around lines 142 - 148, Update the
TOC-filtered node processing in createDocs to deduplicate entries by their
resolved path before cpMarkdown and createPage run, retaining the main
release-note source over the stable source when both resolve to the same path.
Preserve the existing URL resolver behavior and add resolver/build integration
coverage for both main and stable inputs.
There was a problem hiding this comment.
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 `@gatsby/__tests__/get-files-from-tocs.test.ts`:
- Around line 116-131: Update the mocked nodes created in the getFilesFromTocs
test with mdxAST link children representing toc-only and operator-releases-only,
rather than relying on makeNode’s empty children. Preserve the existing TOC
paths and ensure the links expose the filenames that the assertion expects.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b39e0ec3-3671-42a0-834e-933307082ee0
📒 Files selected for processing (6)
gatsby/URL_MAPPING_ARCHITECTURE.mdgatsby/__tests__/get-files-from-tocs.test.tsgatsby/__tests__/toc.test.tsgatsby/link-resolver/__tests__/link-resolver.test.tsgatsby/link-resolver/config.tsgatsby/url-resolver/__tests__/url-resolver.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- gatsby/link-resolver/config.ts
- gatsby/url-resolver/tests/url-resolver.test.ts
| const graphql = jest.fn().mockResolvedValue({ | ||
| data: { | ||
| allMdx: { | ||
| nodes: [ | ||
| makeNode( | ||
| "en/tidb-in-kubernetes/main/TOC", | ||
| "docs/markdown-pages/en/tidb-in-kubernetes/main/TOC.md" | ||
| ), | ||
| makeNode( | ||
| "en/tidb-in-kubernetes/main/TOC-tidb-operator-releases", | ||
| "docs/markdown-pages/en/tidb-in-kubernetes/main/TOC-tidb-operator-releases.md" | ||
| ), | ||
| ], | ||
| }, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Populate the mocked TOCs with link nodes.
At Lines [120-127], both nodes use makeNode, which supplies mdxAST: { children: [] } at Lines [28-34]. getFilesFromTocs therefore extracts no filenames, but the assertion expects toc-only and operator-releases-only; this test will fail before validating TOC selection.
🤖 Prompt for 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.
In `@gatsby/__tests__/get-files-from-tocs.test.ts` around lines 116 - 131, Update
the mocked nodes created in the getFilesFromTocs test with mdxAST link children
representing toc-only and operator-releases-only, rather than relying on
makeNode’s empty children. Preserve the existing TOC paths and ensure the links
expose the filenames that the assertion expects.
… tidb-in-kubernetes
Summary by CodeRabbit
/releases/*links now resolve to TiDB-in-Kubernetes stable release notes (not development).