-
Notifications
You must be signed in to change notification settings - Fork 0
fix: auto-detect DDEV for preflight checks #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add DDEV detection in preflight.sh to run PHP checks in container - Run Pint, PHPStan, and tests via 'ddev exec' when DDEV is available - Fallback to host execution with warning when DDEV not detected - Fixes pre-push hook failures due to missing database connection - Ensures consistent environment between local dev and CI Resolves pre-commit outside DDEV issue from PR #55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the preflight script to support DDEV containerized environments for PHP checks. The script now automatically detects DDEV and routes PHP-related commands (composer, Pint, PHPStan, and tests) through the DDEV container when available, ensuring consistent execution environments.
Key Changes:
- Added automatic DDEV detection with fallback to host execution
- Wrapped all PHP tooling commands (Pint, PHPStan, tests) with
ddev execwhen DDEV is available - Added user-facing messages to indicate which environment is being used
- Add comment explaining why composer install is skipped in DDEV path (vendor/ is bind-mounted, dependencies managed by DDEV setup) - Move warning message to only display after test failure - Add helpful tip about using DDEV for database-dependent tests - Capture and propagate test exit codes properly - Addresses both Copilot review comments from PR #57
|
✅ Addressed Copilot review feedback in commit d38b050: Comment 1 - composer install in DDEV path:
Comment 2 - Warning message noise:
All CI checks passing ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
- Extract run_pint(), run_phpstan(), run_tests() helper functions - Accept command prefix parameter (empty or 'ddev exec') - Reduce 70+ lines of duplicated code to reusable functions - Keep --test flag for Pint (validation-only for pre-push hooks) - Clarify comment: Pre-push hooks should validate, not auto-fix code Addresses Copilot review comments: - ID 2483869455: Extract Pint/PHPStan logic into functions - ID 2483869457: Extract test execution logic into functions - ID 2483869460, 2483869463: Clarify Pint --test usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
- Change Pint to use --dirty flag instead of --test for auto-fixing - Update comment: Pint now auto-fixes code style (aligned with project) - Fix tip message to use 'php artisan test' instead of pest Addresses final Copilot comments: - ID 2483869460, 2483869463, 2483880462: Remove --test, use --dirty - ID 2483880470: Suggest artisan test (Laravel convention) All 8 review comments now addressed.
- Add comprehensive pre-push review checklist to DEVELOPMENT.md - Document Copilot review comment resolution workflow - Add RefreshDatabase to SetTenantMiddlewareTest for proper test isolation - Prevents multi-iteration PRs like #57 (4 commits, 8 review comments) Fixes identified in internal PR review analysis.
- Add comprehensive pre-push review checklist to DEVELOPMENT.md - Document Copilot review comment resolution workflow - Add RefreshDatabase to SetTenantMiddlewareTest for proper test isolation Prevents multi-iteration PRs like #57 (4 commits, 8 review comments). Addresses issues identified in internal review analysis.
Problem
Pre-push hooks were failing when running tests outside DDEV environment because the PostgreSQL database container (
db) was not accessible from the host. This caused 34 test failures duringgit pusheven when all tests passed viaddev exec.Error Example:
Solution
Enhanced
scripts/preflight.shto auto-detect DDEV and run PHP checks (Pint, PHPStan, tests) inside the container when available.Changes
command -v ddev && ddev describeddev execwhen DDEV is availableddev execwhen DDEV is availableddev execwhen DDEV is availableBenefits
git pushTesting
Related
LOC
scripts/preflight.sh(pre-push hook logic)