chore: add local service bootstrap#5913
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a Docker Compose project for local MySQL 8 and Redis 7, a Node.js CLI to start/stop/status/reset that project, npm script wrappers, and README documentation describing default localhost ports, fixture databases, and environment-variable overrides. ChangesLocal Development Services
Sequence DiagramsequenceDiagram
actor Developer
participant npm as "npm scripts"
participant CLI as "dev-services.js"
participant Docker as "Docker daemon"
participant MySQL as "MySQL container"
participant Redis as "Redis container"
Developer->>npm: run dev:services:start
npm->>CLI: node scripts/dev-services.js start
CLI->>Docker: docker compose -f dev-services.compose.yml version
CLI->>CLI: check port 3306 on 127.0.0.1
CLI->>CLI: check port 6379 on 127.0.0.1
CLI->>Docker: docker compose up -d
Docker->>MySQL: create/start container
Docker->>Redis: create/start container
CLI->>MySQL: mysqladmin ping (retry)
MySQL-->>CLI: ready
CLI->>MySQL: CREATE DATABASE IF NOT EXISTS ...
MySQL-->>CLI: databases created
CLI->>Redis: redis-cli ping (retry)
Redis-->>CLI: ready
CLI->>Developer: print endpoints 127.0.0.1:3306, 127.0.0.1:6379
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Deploying egg with
|
| Latest commit: |
5e4dd6d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4a72cb23.egg-cci.pages.dev |
| Branch Preview URL: | https://agent-egg-dev-fa7b6cfb.egg-cci.pages.dev |
There was a problem hiding this comment.
Code Review
This pull request introduces a local development environment for external services (MySQL and Redis) using Docker Compose. It includes a management script (scripts/dev-services.js) to handle service lifecycle, port availability checks, and database initialization, along with new npm scripts in package.json. Documentation has been added to the README.md to guide users. Feedback focuses on improving security by explicitly binding service ports to 127.0.0.1 and enhancing error handling in the script's main catch block.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #5913 +/- ##
==========================================
- Coverage 85.03% 85.03% -0.01%
==========================================
Files 665 667 +2
Lines 19108 19110 +2
Branches 3719 3719
==========================================
+ Hits 16249 16250 +1
- Misses 2466 2467 +1
Partials 393 393 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Deploying egg-v3 with
|
| Latest commit: |
5e4dd6d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e02b1c0b.egg-v3.pages.dev |
| Branch Preview URL: | https://agent-egg-dev-fa7b6cfb.egg-v3.pages.dev |
5cf9004 to
2cac01e
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a repository-level way to bootstrap local MySQL and Redis services for development and test flows that depend on external infrastructure. It fits into the monorepo by providing a shared local-services entrypoint plus documentation for DAL/ORM/Redis-related workflows.
Changes:
- Add a new
scripts/dev-services.jsCLI to start, stop, reset, and inspect a Docker Compose stack. - Add
dev:services:*root package scripts that wrap the new helper. - Add a root
dev-services.compose.ymland README guidance describing local service setup, ports, image overrides, and test assumptions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
scripts/dev-services.js |
Adds the Node.js helper that orchestrates Docker Compose, port checks, readiness checks, and MySQL DB initialization. |
package.json |
Adds root scripts for starting/stopping/checking/resetting the local services stack. |
dev-services.compose.yml |
Defines the local MySQL/Redis containers, ports, healthchecks, and persistent MySQL volume. |
README.md |
Documents how to use the new local services workflow and which tests/fixtures depend on it. |
2cac01e to
70d153e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
scripts/dev-services.js (1)
26-56: 💤 Low value
runDockeris a near-duplicate ofdockerComposeused only onceThe two helpers share identical bodies; the sole difference is that
runDockerskips-f composeFile.runDockeris called exactly once (line 154) to detect Docker Compose availability. Consider either inlining the availability check (e.g.spawnSync('docker', ['compose', 'version'], …)) or folding the two helpers together with an option flag to reduce the duplication surface.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/dev-services.js` around lines 26 - 56, dockerCompose and runDocker are near-duplicates; consolidate them by creating a single helper (e.g., dockerRun) that accepts an option to inject composeFile usage or takes the full args array so both cases are covered (use dockerRun in place of dockerCompose and runDocker). Update calls that currently call dockerCompose(...) to pass ['compose','-f', composeFile, ...] and replace the single runDocker call (the compose availability check) with dockerRun(['compose','version'], {cwd: rootDir, encoding:'utf8', stdio: ...}) or call dockerRun with an option like {useComposeFile:false}. Ensure the new helper preserves the same error handling and returns the spawnSync result, referencing spawnSync, composeFile, rootDir, dockerCompose, and runDocker for locating and replacing the implementations and call sites.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/dev-services.js`:
- Around line 108-109: Update the user-facing guidance string that currently
says "utoo run dev:services:reset" to the correct command "pnpm run
dev:services:reset" in the message assembled by the array ending with
].join('\n'); locate and edit the string literal in the message block (the
sentence starting "Re-run with the same EGG_DEV_SERVICES_* port override, or run
...") so it references "pnpm run" instead of "utoo run".
---
Nitpick comments:
In `@scripts/dev-services.js`:
- Around line 26-56: dockerCompose and runDocker are near-duplicates;
consolidate them by creating a single helper (e.g., dockerRun) that accepts an
option to inject composeFile usage or takes the full args array so both cases
are covered (use dockerRun in place of dockerCompose and runDocker). Update
calls that currently call dockerCompose(...) to pass ['compose','-f',
composeFile, ...] and replace the single runDocker call (the compose
availability check) with dockerRun(['compose','version'], {cwd: rootDir,
encoding:'utf8', stdio: ...}) or call dockerRun with an option like
{useComposeFile:false}. Ensure the new helper preserves the same error handling
and returns the spawnSync result, referencing spawnSync, composeFile, rootDir,
dockerCompose, and runDocker for locating and replacing the implementations and
call sites.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3c377324-c6f1-42aa-b04a-c978a57254cc
📒 Files selected for processing (2)
README.mdscripts/dev-services.js
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
Summary
utoo runcommandsVerification
Earlier service-stack verification on this PR also covered alternate-port startup, MySQL database initialization, Redis ping, running stack port mismatch protection, and reset cleanup.
Note: I did not rerun DAL/ORM tests against the default local ports after the
utoowording follow-up because 127.0.0.1:3306 was already occupied by an existing host service, and those tests mutate local MySQL databases.Summary by CodeRabbit
New Features
Documentation