add-linters #4

Merged
fedy95 merged 3 commits from add-linters into master 5 years ago
  1. 5
      Makefile
  2. 29
      README.md
  3. 71
      composer.json
  4. 65
      composer.lock
  5. 2
      devops/scripts/init.sh
  6. 10
      devops/scripts/install.sh
  7. 3
      symfony.lock

5
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

29
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*

71
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",
@ -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"
]
}
}

65
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"

2
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

10
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"

3
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"
},