Improve auto-sync of documentation screenshots#340
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR refactors screenshot handling to reduce documentation churn by intelligently syncing only changed images. It moves screenshot output from 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. 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 @.github/scripts/sync-docs-screenshots.cjs:
- Around line 4-6: The script destructures process.argv into sourceDir,
targetDir and toolsDir and directly requires modules via path.join; add
validation to ensure the expected positional args exist (check
process.argv.length or that sourceDir/targetDir/toolsDir are non-empty), verify
that sourceDir and targetDir paths exist and are directories (use
fs.existsSync/fs.statSync), and ensure toolsDir exists before requiring PNG and
pixelmatch (wrap the require(path.join(toolsDir, ...)) calls in a try/catch or
pre-check so you can log a clear usage message and exit with non-zero status
when arguments or paths are missing/invalid); reference the process.argv
destructuring and the require(path.join(toolsDir, 'node_modules', 'pngjs')) /
require(path.join(toolsDir, 'node_modules', 'pixelmatch')) locations when
applying these checks.
- Around line 20-32: Wrap the PNG parsing and comparison logic that uses
PNG.sync.read(sourcePath) and PNG.sync.read(targetPath) plus the pixelmatch()
call in a try-catch block so a corrupted/malformed PNG doesn't crash the whole
script; catch any error, log a clear diagnostic message that includes the file
name (file), sourcePath/targetPath and the error, then continue to the next file
(i.e. skip comparison for this pair) so the loop proceeds; ensure you still only
compute numDiffPixels and compare against maxDiffRatio inside the try so those
operations are protected.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 3f45fce0-e4f0-44f9-bb5a-4b5f06a19c60
📒 Files selected for processing (7)
.github/scripts/sync-docs-screenshots.cjs.github/workflows/ci.yml.github/workflows/sync-docs-screenshots.yml.gitignoreeslint.config.mjsplaywright.config.tstest/helpers/screenshot.ts
Summary by CodeRabbit
New Features
Improvements
Chores