Feature/sharding paparazzi plugin - #134
Conversation
WalkthroughAdds a ChangesGenerated test sharding
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ComposablePreviewPaparazziPlugin
participant ComposablePreviewPaparazziExtension
participant TaskSetup
participant GenerateComposablePreviewPaparazziTestsTask
ComposablePreviewPaparazziPlugin->>ComposablePreviewPaparazziPlugin: afterEvaluate reads Test maxParallelForks
ComposablePreviewPaparazziPlugin->>ComposablePreviewPaparazziExtension: set generatedTestClassCount convention
TaskSetup->>GenerateComposablePreviewPaparazziTestsTask: set generatedTestClassCount
GenerateComposablePreviewPaparazziTestsTask->>GenerateComposablePreviewPaparazziTestsTask: generateTests() computes shard count
alt generatedTestClassCount == 1
GenerateComposablePreviewPaparazziTestsTask->>GenerateComposablePreviewPaparazziTestsTask: emit one test class
else generatedTestClassCount > 1
GenerateComposablePreviewPaparazziTestsTask->>GenerateComposablePreviewPaparazziTestsTask: emit Shard1 plus shard-specific sections
end
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 `@paparazzi-plugin-tests/build.gradle.kts`:
- Around line 35-39: The unit test fork count in testOptions/unitTests.all can
become zero on single-core runners because it uses
Runtime.getRuntime().availableProcessors() / 2. Update the maxParallelForks
assignment to clamp the computed value to at least 1 so the
Test.maxParallelForks setting always stays positive.
In
`@paparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.kt`:
- Around line 46-47: The shard-count validation in
GenerateComposablePreviewPaparazziTestsTask currently only logs when shards is
less than 1, which allows the task to continue without generating tests. Update
the task’s shard validation path so an invalid generatedTestClassCount or shard
count fails the Gradle task immediately, using the existing task logic around
GenerateComposablePreviewPaparazziTestsTask and its generation entry point to
stop execution rather than silently skipping generation.
🪄 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
Run ID: 381db5f7-6bba-4147-8dc3-a5ce78ffe428
📒 Files selected for processing (7)
README.mdpaparazzi-plugin-tests/build.gradle.ktspaparazzi-plugin/README.mdpaparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/ComposablePreviewPaparazziExtension.ktpaparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/ComposablePreviewPaparazziPlugin.ktpaparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.ktpaparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/TaskSetup.kt
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…sable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.kt Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
paparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.kt (1)
342-354: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winSort previews before sharding
cachedPreviewsfeedsindex % $numShardsdirectly, so any JVM-dependent scan order changes shard membership and can leave previews duplicated or skipped across shards. Sort by a stable preview key before partitioning.🤖 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 `@paparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.kt` around lines 342 - 354, The sharding logic in GenerateComposablePreviewPaparazziTestsTask uses cachedPreviews directly, so scan order can change shard assignment and cause duplicates or missing previews. Before computing shardedCachedPreviews, sort cachedPreviews by a stable preview identifier/key, then apply the index % numShards partitioning so shard membership is deterministic across JVM runs.
🤖 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.
Outside diff comments:
In
`@paparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.kt`:
- Around line 342-354: The sharding logic in
GenerateComposablePreviewPaparazziTestsTask uses cachedPreviews directly, so
scan order can change shard assignment and cause duplicates or missing previews.
Before computing shardedCachedPreviews, sort cachedPreviews by a stable preview
identifier/key, then apply the index % numShards partitioning so shard
membership is deterministic across JVM runs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4ea3f28b-db5b-4e30-8ae8-d8c706789786
📒 Files selected for processing (2)
paparazzi-plugin-tests/build.gradle.ktspaparazzi-plugin/src/main/kotlin/io/github/sergio/sastre/composable/preview/scanner/paparazzi/plugin/GenerateComposablePreviewPaparazziTestsTask.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- paparazzi-plugin-tests/build.gradle.kts
Showcases how to enable test sharding to run Paparazzi tests in parallel with ComposablePreviewScanner.
Summary by CodeRabbit
generatedTestClassCountconfiguration option to control the number of generated shards/classes.maxParallelForks(with a safe fallback).