Skip to content

Commit

Permalink
feat(master): Add Task module
Browse files Browse the repository at this point in the history
- Add Task module
  • Loading branch information
Artem Onyshchenko committed Apr 24, 2020
0 parents commit 45d7c93
Show file tree
Hide file tree
Showing 23 changed files with 1,284 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service_name: travis-ci
coverage_clover: clover.xml
json_path: coveralls-upload.json
18 changes: 18 additions & 0 deletions .docker/php7.3-dev/Dockerfile
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
25 changes: 25 additions & 0 deletions .editorconfig
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
13 changes: 13 additions & 0 deletions .env
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 ###
MICROTSK_COMPOSE_PROJECT_NAME=micro-task
CI_COMMIT_REF_SLUG=master
###< common variables ###
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 ###

# Build data
build/

###> Phpunit ###
bin/.phpunit
###< Phpunit ###

composer.lock

30 changes: 30 additions & 0 deletions .travis.yml
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;
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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: fix-permission
fix-permission: ## fix permission for docker env
sudo chown -R $(shell whoami):$(shell whoami) *
sudo chown -R $(shell whoami):$(shell whoami) .docker/*

.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 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 -l

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, deprac, 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
50 changes: 50 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "micro-module/task",
"type": "library",
"description": "Micro module Task common library",
"license": "proprietary",
"require": {
"php": "^7.3",
"beberlei/assert": "^3.2",
"broadway/broadway": "^2.2",
"queue-interop/amqp-interop": "^0.8",
"queue-interop/queue-interop": "^0.7|^0.8",
"enqueue/enqueue": "^0.10",
"enqueue/fs": "^0.10",
"enqueue/job-queue": "^0.10",
"enqueue/null": "^0.10",
"league/tactician-bundle": "^1.1",
"league/tactician-command-events": "^0.6.0",
"psr/log": "^1.1"
},
"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",
"sensiolabs-de/deptrac-shim": "^0.4",
"symplify/easy-coding-standard": "^7.2",
"vimeo/psalm": "^3.11"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"MicroModule\\Task\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"MicroModule\\Task\\Tests\\Unit\\": "tests/unit"
}
}
}
25 changes: 25 additions & 0 deletions depfile.yml
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
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.7"

services:
php:
container_name: ${MICROTSK_COMPOSE_PROJECT_NAME}_php
user: 1000:1000
build:
context: .docker/php7.3-dev
volumes:
- ~/.composer/cache/:/.composer_cache/:rw
- ..:/packages:rw
working_dir: /packages/Task
4 changes: 4 additions & 0 deletions ecs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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' }
28 changes: 28 additions & 0 deletions phpmd.xml
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>
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- vendor/phpstan/phpstan-mockery/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
ignoreErrors:
- '#Parameter .* of .* expects .*, Mockery\\MockInterface given.#'
27 changes: 27 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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="MICRODTO_COMPOSE_PROJECT_NAME" value="micro-module-command-bus" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
</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>
</phpunit>
Loading

0 comments on commit 45d7c93

Please sign in to comment.