CI: Fix MongoDB version + Makefile and PHPStan for local/CI dev experience#503
CI: Fix MongoDB version + Makefile and PHPStan for local/CI dev experience#503bartmcleod merged 10 commits intolexik:masterfrom
Conversation
- Upgraded MongoDB image from version 4.0 to 4.4 for improved features and security. - Enhanced health check options for the MongoDB service to ensure better reliability during CI runs.
- Introduced PHPStan as a development dependency for static code analysis. - Updated composer.json to include PHPStan version 2.0 in the require-dev section. - Created phpstan.neon.dist configuration file with specified analysis parameters and paths.
- Introduced a Makefile to streamline Docker commands for the LexikTranslationBundle. - Added commands for starting/stopping services, building images, running tests, and managing dependencies. - Enhanced developer experience by providing a centralized help command for available operations.
- Enhanced .gitignore to include additional directories for Composer dependencies, IDE configurations, and cache files. - Removed deprecated .php_cs configuration file and replaced it with .php-cs-fixer.dist.php for PHP-CS-Fixer setup. - Updated composer.json to include friendsofphp/php-cs-fixer as a development dependency and adjusted other dependencies. - Modified Makefile to use the new PHP-CS-Fixer configuration file. - Updated Dockerfile to use PHP 8.3 instead of 8.4 for compatibility. - Refactored LexikTranslationBundle.php to reorder use statements for better organization.
- Set PHP platform version to 8.2.0 in composer.json for compatibility. - Updated composer.lock to reflect changes in package versions, including downgrading doctrine/instantiator to 2.0.0 and symfony packages to 7.4.x versions. - Adjusted PHP requirements for several packages to ensure compatibility with the new PHP version.
- Added ext-mongodb version 2.1.4 to composer.json and platform-overrides in composer.lock for compatibility. - Downgraded mongodb/mongodb package version to 2.1.2 and updated related references in composer.lock. - Adjusted rector/rector version to 2.1.4 and updated vimeo/psalm version to 6.5.* in composer.lock.
bartmcleod
left a comment
There was a problem hiding this comment.
Please also remove the .php-cs-fixer.cache and add it to .gitignore
.gitignore
Outdated
| @@ -1,9 +1,20 @@ | |||
| # Dependencias de Composer (instaladas con composer install) | |||
There was a problem hiding this comment.
Please translate to English. There is no added value to having them in Spanish. Did AI do this for you?
There was a problem hiding this comment.
I use a prompt to generate and review a development environment that checks the code generated by the Makefile. By the way, I ran CS Fixer and Rector and they suggested some changes, but I haven’t wanted to add them yet. Take a look at them and validate them if you can.
There was a problem hiding this comment.
Not sure what you mean. I meant to translate the Spanish comments to English. Why would they need to be in Spanish?
| help: | ||
| @echo "LexikTranslationBundle - Available commands:" | ||
| @echo "" | ||
| @echo " make up Start services in the background" |
There was a problem hiding this comment.
Fix white space please
| return static function (RectorConfig $rectorConfig): void { | ||
| $rectorConfig->paths([ | ||
| return RectorConfig::configure() | ||
| ->withPaths([ |
There was a problem hiding this comment.
So we have path definitions in two places now?
|
@HecFranco Thank you for the extensive PR. I am not sure about the makefile, because it will require make to be installed. I had a few minor comments in my review, otherwise looking good! If you can remove the cache file and clarify how make would work cross-platform, we are good to go with this one. |
- Commented out the .php-cs-fixer.cache entry in .gitignore to prevent tracking of the cache file. - Deleted the .php-cs-fixer.cache file to clean up the project and avoid unnecessary cache tracking.
- Restored the .php-cs-fixer.cache entry in .gitignore to ensure the cache file is ignored during version control, preventing unnecessary tracking.
Thanks for the review and for the comments. Good point about the Makefile. I added it as a convenience layer for common development commands, not as a hard requirement. I’ve clarified in the PR that the underlying commands can still be run directly without make. I’ve also removed the cache file from the PR. For cross-platform support, I’ve added a note with the alternatives for environments where make is not available by default. Thanks again. |
- Translated comments in .gitignore to English for better understanding. - Ensured consistency in formatting and terminology across all entries.
- Updated README.md to include a new section on development setup, detailing the use of the Makefile for common tasks. - Created docs/development.md to provide comprehensive instructions for running development tooling, including cross-platform usage with Docker Compose. - Included commands for testing, static analysis, and code style management to enhance developer experience.
| parameters: | ||
| level: 5 | ||
| paths: | ||
| - Command |
There was a problem hiding this comment.
You did not reply to my comment about having the paths in two places. Can we use just one?
| @@ -1,4 +1,4 @@ | |||
| FROM php:8.4-cli-bullseye | |||
| FROM php:8.3-cli-bullseye | |||
There was a problem hiding this comment.
The one downside I see here is that we will not see deprecation errors when testing/running the code on local. Personally, I'm not affected by this, because I have a separate php 8.5 docker running for it, but still...
Summary
Changes
CI (
.github/workflows/php.yml)mongo:4.0tomongo:4.4so the server reports wire version ≥ 8, required by the currentext-mongodb/ libmongoc (avoids "wire version 7, but this version of libmongoc requires at least 8").optionswith health-cmd so the job waits for MongoDB to be ready before running tests.Makefile
up,down,build,test,rector,cs-fix,phpstan,ensure-up,cache-clear,install,update,help.help(runningmakeshows available commands).docker compose up -dandcomposer installso services and dependencies are ready; used as dependency fortest,rector,cs-fix,phpstan,install,update,cache-clear.lexik_translationcontainer viadocker compose run --rm lexik_translation.PHPStan
phpstan/phpstan: ^2.0inrequire-dev.level: 5, paths aligned with Rector (bundle code), excludingvendorandTests.make phpstanrunsvendor/bin/phpstan analyse --memory-limit=512Min the container.PHP-CS-Fixer
friendsofphp/php-cs-fixer: ^3.64inrequire-dev..php_cs(API 1.x).make cs-fixrunsvendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.phpin the container.Rector
rector/rectorfrom^0.14.8|^0.15to^2.0; removerector/jack.RectorConfig::configure()->withPaths()->withSets()); keepLevelSetList::UP_TO_PHP_81.make rectorrunsvendor/bin/rector processin the container.Docker
php:8.3-cli-bullseyeso Rector and PHPStan run without PHP 8.4 deprecations/fatal in vendor.Other
How to test
make ensure-upmake test,make phpstan,make cs-fix,make rector,make help.