From 0c9bb613427a457daf108d88ef3f7c04429121ec Mon Sep 17 00:00:00 2001 From: fedy95 Date: Thu, 28 Jan 2021 18:38:59 +0300 Subject: [PATCH 1/3] cleanup --- composer.json | 6 +++--- devops/scripts/init.sh | 2 +- devops/scripts/install.sh | 10 +++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 8546a8a..5e9a9aa 100644 --- a/composer.json +++ b/composer.json @@ -3,9 +3,9 @@ "license": "MIT", "require": { "php": "7.4.*", - "ext-apcu": "^5.1", - "ext-ctype": "*", - "ext-iconv": "*", + "ext-apcu": "5.1.*", + "ext-ctype": "7.4.*", + "ext-iconv": "7.4.*", "symfony/console": "5.2.*", "symfony/dotenv": "5.2.*", "symfony/flex": "^1.3.1", diff --git a/devops/scripts/init.sh b/devops/scripts/init.sh index 6f25a15..1cde9b1 100755 --- a/devops/scripts/init.sh +++ b/devops/scripts/init.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh # shellcheck disable=SC2046 -SCRIPTS_DIRECTORY=$(dirname $(realpath $0)) +SCRIPTS_DIRECTORY=$(dirname $(realpath "$0")) set -e diff --git a/devops/scripts/install.sh b/devops/scripts/install.sh index a41a6eb..d6cbab0 100755 --- a/devops/scripts/install.sh +++ b/devops/scripts/install.sh @@ -11,20 +11,16 @@ set -a [ -f devops/docker/.env ] && . devops/docker/.env set +a -color="\e[34m" -defaultColor="\e[0m" - # shellcheck disable=SC2028 -echo "$color\n### Building containers ... $defaultColor" +echo "### Building containers ..." docker-compose build \ --build-arg HOME=$HOME \ --build-arg USER=$USER \ --build-arg UID=$(id -u) \ - --build-arg GID=$(id -g) \ - --build-arg COMPOSER_VERSION=$COMPOSER_VERSION + --build-arg GID=$(id -g) # shellcheck disable=SC2028 -echo "$color\n### Creating .env ... $defaultColor" +echo "### Creating .env ..." ENV_FILE=.env if [ ! -f "$ENV_FILE" ]; then cp devops/dist/.env-dist "$ENV_FILE" -- 2.30.2 From a6b4365542110431af7d9e7812305a4cb010c8af Mon Sep 17 00:00:00 2001 From: fedy95 Date: Thu, 28 Jan 2021 18:39:26 +0300 Subject: [PATCH 2/3] add-linters --- composer.json | 65 ++++++++++++++++++++++++++++++++++++++++----------- composer.lock | 65 +++++++++++++++++++++++++++++++++++++++++++++++---- symfony.lock | 3 +++ 3 files changed, 115 insertions(+), 18 deletions(-) diff --git a/composer.json b/composer.json index 5e9a9aa..3fd251d 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,11 @@ "codeception/codeception": "^4.1", "codeception/module-asserts": "^1.3", "codeception/module-phpbrowser": "^1.0", + "codeception/module-rest": "^1.2", "ergebnis/composer-normalize": "^2.13", "friendsofphp/php-cs-fixer": "^2.18", - "roave/security-advisories": "dev-master", - "codeception/module-rest": "^1.2" + "php-parallel-lint/php-parallel-lint": "^1.2", + "roave/security-advisories": "dev-master" }, "config": { "apcu-autoloader": true, @@ -33,7 +34,8 @@ "optimize-autoloader": true, "preferred-install": { "*": "dist" - } + }, + "sort-packages": true }, "extra": { "composer-normalize": { @@ -71,33 +73,68 @@ "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "codecept": "codecept -c tests/codeception.yml", + "json-cs-fix": "composer normalize", + "lint:php": [ + "parallel-lint --no-progress --no-colors --blame ./bin/console", + "parallel-lint --no-progress --no-colors --blame ./config/bundles.php", + "parallel-lint --no-progress --no-colors --blame ./config/preload.php", + "parallel-lint --no-progress --no-colors --blame ./public/index.php", + "parallel-lint --no-progress --no-colors --blame ./src", + "parallel-lint --no-progress --no-colors --blame ./tests/_support/Helper", + "parallel-lint --no-progress --no-colors --blame ./tests/_support/AcceptanceTester.php", + "parallel-lint --no-progress --no-colors --blame ./tests/_support/ApiTester.php", + "parallel-lint --no-progress --no-colors --blame ./tests/_support/UnitTester.php", + "parallel-lint --no-progress --no-colors --blame ./tests/acceptance", + "parallel-lint --no-progress --no-colors --blame ./tests/api", + "parallel-lint --no-progress --no-colors --blame ./tests/unit", + "parallel-lint --no-progress --no-colors --blame ./.php_cs" + ], + "lint:yaml": [ + "bin/console --quiet --no-debug l:yaml ./config/packages", + "bin/console --quiet --no-debug l:yaml ./config/routes", + "bin/console --quiet --no-debug l:yaml ./config/routes.yaml", + "bin/console --quiet --no-debug l:yaml ./config/services.yaml", + "bin/console --quiet --no-debug l:yaml ./tests/acceptance.suite.yml", + "bin/console --quiet --no-debug l:yaml ./tests/api.suite.yml", + "bin/console --quiet --no-debug l:yaml ./tests/codeception.yml", + "bin/console --quiet --no-debug l:yaml ./tests/unit.suite.yml" + ], "php-cs-fix": [ "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache bin/console", "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache config/bundles.php", "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache config/preload.php", "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache public/index.php", "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache src", - "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/_support/Helper", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/_support/AcceptanceTester.php", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/_support/ApiTester.php", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/_support/UnitTester.php", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/acceptance", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/api", + "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache tests/unit", "php vendor/bin/php-cs-fixer fix --cache-file=var/php-cs-fixer/.php-cs.cache .php_cs" ], - "test:api": [ - "@codecept build -q", - "@codecept run api" + "prepare-request": [ + "@json-cs-fix", + "@lint:yaml", + "@lint:php", + "@lint:container", + "@php-cs-fix", + "@test:unit", + "@test:api", + "@test:acceptance" ], "test:acceptance": [ "@codecept build -q", "@codecept run acceptance" ], + "test:api": [ + "@codecept build -q", + "@codecept run api" + ], "test:unit": [ "@codecept build -q", "@codecept run unit --no-rebuild --coverage-html --coverage-text --no-colors" - ], - "prepare": [ - "@json-cs-fix", - "@php-cs-fix", - "@test:unit", - "@test:api", - "@test:acceptance" ] } } diff --git a/composer.lock b/composer.lock index 956aec8..940fed2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f0a8d27758152f19c0d1f1fbc37ba87e", + "content-hash": "6a8bd6e7067476da729289b79de15fc5", "packages": [ { "name": "psr/cache", @@ -4373,6 +4373,63 @@ }, "time": "2020-10-14T08:39:05+00:00" }, + { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/474f18bc6cc6aca61ca40bfab55139de614e51ca", + "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.4.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "~0.3", + "squizlabs/php_codesniffer": "~3.0" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/master" + }, + "time": "2020-04-04T12:18:32+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -7105,9 +7162,9 @@ "prefer-lowest": false, "platform": { "php": "7.4.*", - "ext-apcu": "^5.1", - "ext-ctype": "*", - "ext-iconv": "*" + "ext-apcu": "5.1.*", + "ext-ctype": "7.4.*", + "ext-iconv": "7.4.*" }, "platform-dev": [], "plugin-api-version": "2.0.0" diff --git a/symfony.lock b/symfony.lock index e2f1438..c464779 100644 --- a/symfony.lock +++ b/symfony.lock @@ -125,6 +125,9 @@ "php-cs-fixer/diff": { "version": "v1.3.1" }, + "php-parallel-lint/php-parallel-lint": { + "version": "v1.2.0" + }, "phpdocumentor/reflection-common": { "version": "2.2.0" }, -- 2.30.2 From a6446ea9955e42350033bd351383e407e2f5f362 Mon Sep 17 00:00:00 2001 From: fedy95 Date: Thu, 28 Jan 2021 18:40:56 +0300 Subject: [PATCH 3/3] add-description-for-readme --- Makefile | 5 +++-- README.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 79c3363..fd90e2a 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,9 @@ start: install stop: $(DOCKER_COMPOSE) down -# Entering into containers enter-php: $(DOCKER_COMPOSE) exec php bash +prepare-request: + $(DOCKER_COMPOSE) exec -T php bash -c "composer run prepare-request" -.DEFAULT_GOAL := install +.DEFAULT_GOAL := init diff --git a/README.md b/README.md index c1a5be3..b27b763 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # 5-cli-template +Template repo "pure-skeleton" with symfony 5.2. Includes: +- local devops via docker-compose and make +- codeception support with acceptance/api/unit-testing +- php/yaml linters +- php/composer code style fixers + + +### Requirements + - [docker 19+](https://docs.docker.com/engine/install/) + - [docker-compose 1.15+](https://docs.docker.com/compose/install/) + - [make 4.3+](https://www.gnu.org/software/make/) + +### Install +```shell script +make init +``` + +### Development +Enter inside docker container +```shell script +make enter-php +``` + +Run linters/tests and formatting the code +```shell script +make prepare-request +``` + +See other useful commands in **Makefile** and **composer.json** under *scripts* -- 2.30.2