Skip to content

Commit 6f5b9e7

Browse files
authored
CI: Fix MongoDB version + Makefile and PHPStan for local/CI dev experience (#503)
* chore: Update MongoDB service configuration in GitHub Actions workflow - 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. * chore: Add PHPStan for static analysis and update composer dependencies - 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. * feat: Add Makefile for Docker command management - 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. * chore: Update project configuration and dependencies - 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. * chore: Update PHP version and adjust dependencies in composer files - 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. * chore: Update MongoDB extension version in composer files - 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. * chore: Update .gitignore and remove .php-cs-fixer.cache - 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. * chore: Uncomment .php-cs-fixer.cache entry in .gitignore - Restored the .php-cs-fixer.cache entry in .gitignore to ensure the cache file is ignored during version control, preventing unnecessary tracking. * chore: Update .gitignore for improved clarity and consistency - Translated comments in .gitignore to English for better understanding. - Ensured consistency in formatting and terminology across all entries. * docs: Add development setup instructions and Makefile details - 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.
1 parent f454256 commit 6f5b9e7

File tree

12 files changed

+9211
-20
lines changed

12 files changed

+9211
-20
lines changed

.github/workflows/php.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ jobs:
2323
- 3306:3306
2424
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
2525
mongo:
26-
image: library/mongo:4.0
26+
image: mongo:4.4
2727
ports:
2828
- 27017:27017
2929
env:
3030
MONGO_INITDB_ROOT_USERNAME: admin
3131
MONGO_INITDB_ROOT_PASSWORD: secret
32+
options: >-
33+
--health-cmd "mongo mongodb://admin:secret@localhost:27017/admin --eval 'db.adminCommand(\"ping\")'"
34+
--health-interval 10s
35+
--health-timeout 5s
36+
--health-retries 5
3237
3338
strategy:
3439
matrix:

.gitignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
# Composer dependencies (installed with composer install)
12
vendor
2-
composer.lock
3+
4+
# PhpStorm IDE configuration and cache
35
.idea
46

7+
# Test application temporary directory
58
Tests/app/tmp/
9+
10+
# PHPUnit result cache
611
.phpunit.result.cache
712

13+
# PHP-CS-Fixer cache
14+
.php-cs-fixer.cache
15+
16+
# Generated documentation
817
.docs
9-
.demo
18+
19+
# Demo or demonstration environment
20+
.demo

.php-cs-fixer.dist.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('bin')
5+
->exclude('vendor')
6+
->in(__DIR__);
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@PSR12' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'binary_operator_spaces' => true,
13+
'blank_line_after_opening_tag' => true,
14+
'concat_space' => ['spacing' => 'one'],
15+
'no_extra_blank_lines' => true,
16+
'no_leading_import_slash' => true,
17+
'no_trailing_comma_in_singleline' => true,
18+
'no_unused_imports' => true,
19+
'ordered_imports' => true,
20+
])
21+
->setFinder($finder);

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.4-cli-bullseye
1+
FROM php:8.3-cli-bullseye
22

33
ENV COMPOSER_ALLOW_SUPERUSER=1
44

LexikTranslationBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Lexik\Bundle\TranslationBundle;
44

5-
use Symfony\Component\HttpKernel\Bundle\Bundle;
6-
use Symfony\Component\DependencyInjection\ContainerBuilder;
75
use Lexik\Bundle\TranslationBundle\DependencyInjection\Compiler\RegisterMappingPass;
86
use Lexik\Bundle\TranslationBundle\DependencyInjection\Compiler\TranslatorPass;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
use Symfony\Component\HttpKernel\Bundle\Bundle;
99

1010
/**
1111
* Bundle main class.

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.PHONY: up down build test rector cs-fix phpstan ensure-up help cache-clear install update
2+
3+
DOCKER_RUN = docker compose run --rm lexik_translation
4+
5+
.DEFAULT_GOAL := help
6+
7+
help:
8+
@echo "LexikTranslationBundle - Available commands:"
9+
@echo ""
10+
@echo " make up Start services in the background"
11+
@echo " make ensure-up Start services and install dependencies (composer)"
12+
@echo " make down Stop and remove containers"
13+
@echo " make build Build Docker images"
14+
@echo " make test Run test suite (PHPUnit)"
15+
@echo " make rector Run Rector (refactoring)"
16+
@echo " make cs-fix Apply PHP-CS-Fixer (code style)"
17+
@echo " make phpstan Run PHPStan (static analysis)"
18+
@echo " make cache-clear Clear Composer cache"
19+
@echo " make install Install dependencies (composer install)"
20+
@echo " make update Update dependencies (composer update)"
21+
@echo " make help Show this help"
22+
23+
up:
24+
docker compose up -d
25+
26+
ensure-up:
27+
docker compose up -d
28+
$(DOCKER_RUN) composer install --prefer-dist --no-progress
29+
30+
down:
31+
docker compose down
32+
33+
build:
34+
docker compose build
35+
36+
test: ensure-up
37+
$(DOCKER_RUN) composer test
38+
39+
rector: ensure-up
40+
$(DOCKER_RUN) vendor/bin/rector process
41+
42+
cs-fix: ensure-up
43+
$(DOCKER_RUN) vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php
44+
45+
phpstan: ensure-up
46+
$(DOCKER_RUN) vendor/bin/phpstan analyse --memory-limit=512M
47+
48+
cache-clear: ensure-up
49+
$(DOCKER_RUN) composer clear-cache
50+
51+
install: ensure-up
52+
$(DOCKER_RUN) composer install --prefer-dist --no-progress
53+
54+
update: ensure-up
55+
$(DOCKER_RUN) composer update --no-progress

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ Here is a little screen shot of the edition page :)
3333

3434
![edition page screen](https://github.com/lexik/LexikTranslationBundle/raw/master/Resources/doc/screen/grid.jpg)
3535

36+
Development
37+
===========
38+
39+
The project provides a **Makefile** for common tasks (tests, static analysis, code style). See **[docs/development.md](docs/development.md)** for:
40+
41+
* How to use the Makefile (requires [GNU Make](https://www.gnu.org/software/make/), usually pre-installed on Linux and macOS).
42+
* **Cross-platform**: running the same commands on Windows (without Make) using Docker Compose.
43+
* Cache files (e.g. `.php-cs-fixer.cache`) are listed in `.gitignore` and are not committed; you can remove them locally if needed.
44+
3645
TESTING
3746
=======
3847

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@
4343
"doctrine/doctrine-bundle": "^2.2",
4444
"doctrine/mongodb-odm": "^2.7",
4545
"doctrine/mongodb-odm-bundle": "^5.0",
46+
"friendsofphp/php-cs-fixer": "^3.64",
4647
"mikey179/vfsstream": "^1.6",
4748
"mongodb/mongodb": "^1.21.0 || ^2.0.0",
49+
"phpstan/phpstan": "^2.0",
4850
"phpunit/phpunit": "^9.5|^10.0",
49-
"rector/jack": "^0.2.3",
50-
"rector/rector": "^0.14.8|^0.15",
51+
"rector/rector": "^2.0",
5152
"symfony/var-exporter": "^6.4|^7.0"
5253
},
5354
"autoload": {
@@ -70,6 +71,10 @@
7071
"test": "vendor/bin/phpunit"
7172
},
7273
"config": {
74+
"platform": {
75+
"php": "8.2.0",
76+
"ext-mongodb": "2.1.4"
77+
},
7378
"sort-packages": true
7479
}
7580
}

0 commit comments

Comments
 (0)