-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add base components for microservices
- Loading branch information
Artem Onyshchenko
committed
Apr 24, 2020
0 parents
commit 4ef7afe
Showing
38 changed files
with
1,063 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
service_name: travis-ci | ||
coverage_clover: build/clover.xml | ||
json_path: build/coveralls-upload.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM php:7.3-cli | ||
|
||
RUN apt-get update && apt-get install -y git unzip | ||
|
||
ENV COMPOSER_ALLOW_SUPERUSER 1 | ||
ENV COMPOSER_MEMORY_LIMIT -1 | ||
|
||
RUN mkdir /.composer_cache | ||
ENV COMPOSER_CACHE_DIR /.composer_cache | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
RUN composer -vvv global require hirak/prestissimo | ||
|
||
# php extensions | ||
|
||
RUN pecl install xdebug | ||
RUN docker-php-ext-enable xdebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
|
||
# 4 space indentation | ||
[*.php] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Tab indentation (no size specified) | ||
[Makefile] | ||
indent_style = tab | ||
|
||
# Matches the exact files either package.json or .travis.yml | ||
[{*.yml, *.yaml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[composer.json] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This file is a "template" of which env vars need to be defined for your application | ||
# Copy this file to .env file for development, create environment variables when deploying to production | ||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
APP_ENV=dev | ||
APP_SECRET=secret | ||
###< symfony/framework-bundle ### | ||
|
||
###> common variables ### | ||
MICROBASE_COMPOSE_PROJECT_NAME=micro-base | ||
CI_COMMIT_REF_SLUG=master | ||
###< common variables ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
vendor/ | ||
|
||
###> PhpStorm project profile ### | ||
.idea/ | ||
###< PhpStorm project profile ### | ||
|
||
###> phpunit/phpunit ### | ||
phpunit.xml | ||
.phpunit.result.cache | ||
###< phpunit/phpunit ### | ||
|
||
###> friendsofphp/php-cs-fixer ### | ||
.php_cs.cache | ||
###< friendsofphp/php-cs-fixer ### | ||
|
||
###> squizlabs/php_codesniffer ### | ||
.phpcs-cache | ||
###< squizlabs/php_codesniffer ### | ||
|
||
###> sensiolabs-de/deptrac ### | ||
.deptrac.cache | ||
###< sensiolabs-de/deptrac ### | ||
|
||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
language: php | ||
|
||
matrix: | ||
include: | ||
- php: 7.3 | ||
fast_finish: true | ||
|
||
env: | ||
global: | ||
TEST_CONFIG="phpunit.xml.dist" | ||
|
||
before_install: | ||
- echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini || return 0 | ||
|
||
install: | ||
- travis_retry composer self-update | ||
- composer install | ||
|
||
script: | ||
- vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests | ||
- vendor/bin/psalm --config=psalm.xml | ||
- vendor/bin/ecs check src tests | ||
- vendor/bin/phpmd src/ text phpmd.xml | ||
- vendor/bin/phpunit --configuration $TEST_CONFIG | ||
- composer validate --no-check-publish | ||
- git log $(git describe --abbrev=0 --tags)...HEAD --no-merges --pretty=format:"* [%h](http://github.com/${TRAVIS_REPO_SLUG}/commit/%H) %s (%cN)" | ||
|
||
after_success: | ||
- travis_retry php ./vendor/bin/php-coveralls -v --config .coveralls.yml -v; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
version = $(shell git describe --tags --dirty --always) | ||
build_name = application-$(version) | ||
# use the rest as arguments for "run" | ||
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) | ||
# ...and turn them into do-nothing targets | ||
#$(eval $(RUN_ARGS):;@:) | ||
|
||
.PHONY: build | ||
build: ## build environment and initialize composer and project dependencies | ||
docker-compose build | ||
make composer-install | ||
|
||
.PHONY: stop | ||
stop: | ||
docker-compose stop | ||
|
||
.PHONY: composer-install | ||
composer-install: ## Install project dependencies | ||
docker-compose run --rm --no-deps php sh -lc 'composer install' | ||
|
||
.PHONY: composer-update | ||
composer-update: ## Update project dependencies | ||
docker-compose run --rm --no-deps php sh -lc 'composer update' | ||
|
||
.PHONY: composer-outdated | ||
composer-outdated: ## Show outdated project dependencies | ||
docker-compose run --rm --no-deps php sh -lc 'composer outdated' | ||
|
||
.PHONY: composer-validate | ||
composer-validate: ## Validate composer config | ||
docker-compose run --rm --no-deps php sh -lc 'composer validate --no-check-publish' | ||
|
||
.PHONY: composer | ||
composer: ## Execute composer command | ||
docker-compose run --rm --no-deps php sh -lc "composer $(RUN_ARGS)" | ||
|
||
.PHONY: phpunit | ||
phpunit: ## execute project unit tests | ||
docker-compose run --rm --no-deps php sh -lc "./vendor/bin/phpunit $(conf)" | ||
|
||
.PHONY: style | ||
style: ## executes php analizers | ||
docker-compose run --rm --no-deps php sh -lc './vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests' | ||
docker-compose run --rm --no-deps php sh -lc './vendor/bin/psalm --config=psalm.xml' | ||
|
||
.PHONY: lint | ||
lint: ## checks syntax of PHP files | ||
docker-compose run --rm --no-deps php sh -lc './vendor/bin/parallel-lint ./ --exclude vendor --exclude bin/.phpunit' | ||
|
||
.PHONY: layer | ||
layer: ## Check issues with layers (deptrac tool) | ||
docker-compose run --rm --no-deps php sh -lc './vendor/bin/deptrac analyze --formatter-graphviz=0' | ||
|
||
.PHONY: logs | ||
logs: ## look for service logs | ||
docker-compose logs -f $(RUN_ARGS) | ||
|
||
.PHONY: help | ||
help: ## Display this help message | ||
@cat $(MAKEFILE_LIST) | grep -e "^[a-zA-Z_\-]*: *.*## *" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: php-shell | ||
php-shell: ## PHP shell | ||
docker-compose run --rm php sh -lflay | ||
|
||
unit-tests: ## Run unit-tests suite | ||
docker-compose run --rm php sh -lc 'vendor/bin/phpunit --testsuite unit-tests' | ||
|
||
static-analysis: style layer coding-standards ## Run phpstan, easycoding standarts code static analysis | ||
|
||
coding-standards: ## Run check and validate code standards tests | ||
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/ecs check src tests' | ||
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/phpmd src/ text phpmd.xml' | ||
|
||
coding-standards-fixer: ## Run code standards fixer | ||
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/ecs check src tests --fix' | ||
|
||
security-tests: ## The SensioLabs Security Checker | ||
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/security-checker security:check --end-point=http://security.sensiolabs.org/check_lock' | ||
|
||
.PHONY: test lint static-analysis phpunit coding-standards composer-validate | ||
test: build lint static-analysis phpunit coding-standards composer-validate stop ## Run all test suites |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "micro-module/base", | ||
"type": "library", | ||
"description": "Micro module Base common library", | ||
"license": "proprietary", | ||
"require": { | ||
"php": "^7.3", | ||
"ext-json": "*", | ||
"beberlei/assert": "^3.2", | ||
"psr/log": "^1.1", | ||
"ramsey/uuid": "^3.8 || ^4.0", | ||
"monolog/monolog": "~1.22 || ~2.0" | ||
}, | ||
"require-dev": { | ||
"php-parallel-lint/php-console-highlighter": "^0.4", | ||
"php-parallel-lint/php-parallel-lint": "^1.0", | ||
"mockery/mockery": "^1.3", | ||
"phpmd/phpmd": "^2.8", | ||
"phpstan/phpstan": "^0.12", | ||
"phpstan/phpstan-mockery": "^0.12", | ||
"phpstan/phpstan-phpunit": "^0.12", | ||
"phpunit/phpunit": "^9.0", | ||
"roave/security-advisories": "dev-master", | ||
"symplify/easy-coding-standard": "^7.2", | ||
"vimeo/psalm": "3.5.0" | ||
}, | ||
"config": { | ||
"preferred-install": { | ||
"*": "dist" | ||
}, | ||
"sort-packages": true | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MicroModule\\Base\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"MicroModule\\Base\\Tests\\Unit\\": "tests/unit" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
paths: | ||
- ./src | ||
exclude_files: | ||
|
||
layers: | ||
- name: Domain | ||
collectors: | ||
- type: className | ||
regex: .*\\Domain\\.* | ||
- name: Application | ||
collectors: | ||
- type: className | ||
regex: .*\\Application\\.* | ||
- name: Infrastructure | ||
collectors: | ||
- type: className | ||
regex: .*\\Infrastructure\\.* | ||
|
||
ruleset: | ||
Domain: | ||
Application: | ||
- Domain | ||
Infrastructure: | ||
- Domain | ||
- Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: "3.7" | ||
|
||
services: | ||
php: | ||
container_name: ${MICROBASE_COMPOSE_PROJECT_NAME}_php | ||
user: 1000:1000 | ||
build: | ||
context: .docker/php7.3-dev | ||
volumes: | ||
- ~/.composer/cache/:/.composer_cache/:rw | ||
- .:/app:rw | ||
working_dir: /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
imports: | ||
- { resource: 'vendor/symplify/easy-coding-standard/config/clean-code.yml' } | ||
- { resource: 'vendor/symplify/easy-coding-standard/config/symfony.yml' } | ||
- { resource: 'vendor/symplify/easy-coding-standard/config/php71.yml' } | ||
|
||
parameters: | ||
skip: | ||
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff.MissingParameterTypeHint: | ||
- 'src/Infrastructure/Testing/RedisInMemory.php' | ||
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff.MissingReturnTypeHint: | ||
- 'src/Infrastructure/Testing/RedisInMemory.php' | ||
SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff.UnusedMethod: | ||
- 'src/Common/Alerting/AlertingProcessor.php' | ||
Symplify\CodingStandard\Fixer\Naming\PropertyNameMatchingTypeFixer: | ||
- 'src/Domain/Exception/ParentExceptionTrait.php' | ||
Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer: | ||
- 'src/Domain/Exception/ParentExceptionTrait.php' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="Ruleset" | ||
xmlns="http://pmd.sf.net/ruleset/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"> | ||
<description>Ruleset for PHP Mess Detector that enforces coding standards</description> | ||
|
||
<rule ref="rulesets/cleancode.xml"> | ||
<exclude name="StaticAccess"/> | ||
</rule> | ||
|
||
<rule ref="rulesets/codesize.xml"/> | ||
|
||
<rule ref="rulesets/controversial.xml"/> | ||
|
||
<rule ref="rulesets/design.xml"/> | ||
|
||
<rule ref="rulesets/naming.xml"> | ||
<exclude name="ShortVariable"/> | ||
<exclude name="LongVariable"/> | ||
<exclude name="ShortMethodName"/> | ||
</rule> | ||
|
||
<rule ref="rulesets/unusedcode.xml"> | ||
<!-- PHPMD cannot recognize parameters that are enforced by an interface --> | ||
<exclude name="UnusedFormalParameter"/> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-mockery/extension.neon | ||
|
||
parameters: | ||
excludes_analyse: | ||
- src/Infrastructure/Testing/RedisInMemory.php | ||
- src/Infrastructure/Testing/RedisFactory.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd" | ||
backupGlobals="false" | ||
colors="true" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<php> | ||
<ini name="error_reporting" value="-1" /> | ||
<env name="APP_ENV" value="test" /> | ||
<env name="APP_DEBUG" value="1" /> | ||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[indirect]=5" /> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="unit-tests"> | ||
<directory>tests/unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<logging> | ||
<log type="coverage-html" target="var/report/html" lowUpperBound="35" highLowerBound="70"/> | ||
</logging> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
Oops, something went wrong.