Harden no-cache output cleanup#62
Conversation
|
Warning Review limit reached
More reviews will be available in 58 minutes and 17 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 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.
Pull request overview
This PR hardens build --no-cache output cleanup by switching away from shell-based deletion, adding a YiiPress build marker file, and preventing destructive cleanup unless the output directory is empty or explicitly marked as YiiPress-generated. It also delays cleanup until after content configuration parsing succeeds, and updates tests/docs accordingly.
Changes:
- Replace
rm -rfoutput cleanup withYiisoft\Files\FileHelper::removeDirectory()and add safety checks before clearing. - Write a
.yiipress-buildmarker after successful builds; refuse--no-cachecleanup for non-empty, unmarked output dirs. - Update unit tests and CLI documentation to cover/describe the new marker behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Console/BuildCommand.php |
Implements safe output cleanup, adds build marker logic, and delays destructive actions until after parsing succeeds. |
tests/Unit/Console/BuildCommandTest.php |
Adds assertions/tests for marker creation and for refusing to clear unmarked non-empty output directories. |
docs/commands.md |
Updates --no-cache documentation to reflect the marker-based cleanup behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private const int MAX_AUTO_WORKERS = 4; | ||
| private const string BUILD_MARKER = '.yiipress-build'; | ||
|
|
| if (!$noWrite) { | ||
| $this->writeBuildMarker($outputDir); | ||
| } |
| private function isDirectoryEmpty(string $directory): bool | ||
| { | ||
| $iterator = new FilesystemIterator($directory, FilesystemIterator::SKIP_DOTS); | ||
|
|
||
| return !$iterator->valid(); | ||
| } |
| - `--output-dir`, `-o` — path to the output directory (default: `output`). Absolute or relative to project root. | ||
| - `--workers`, `-w` — number of parallel workers or `auto` (default: `auto`). Auto mode detects available CPU capacity inside the container, caps it at `4`, and still falls back to sequential work for small task sets. | ||
| - `--no-cache` — disable build cache and incremental builds. Forces a full rebuild, clearing the output directory. By default, rendered HTML is cached and a build manifest tracks source file hashes for incremental builds. | ||
| - `--no-cache` — disable build cache and incremental builds. Forces a full rebuild, clearing the output directory only when it is empty or contains YiiPress' build marker. By default, rendered HTML is cached and a build manifest tracks source file hashes for incremental builds. |
Summary
Tests