Skip to content

Commit

Permalink
stability piplines
Browse files Browse the repository at this point in the history
  • Loading branch information
Andru Cherny committed Jun 7, 2021
1 parent 3b3bf46 commit e0b956a
Show file tree
Hide file tree
Showing 17 changed files with 666 additions and 74 deletions.
Empty file added .coveralls.yml
Empty file.
21 changes: 18 additions & 3 deletions .docker/app_test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ FROM php:7.2-cli

RUN apt-get update && apt-get install -y git unzip

RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& pecl install ast \
&& docker-php-ext-enable ast \
&& true

# -------------------- Installing PHP Extension: intl --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libicu-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) intl \
&& true

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_MEMORY_LIMIT -1

RUN mkdir /.composer_cache
ENV COMPOSER_CACHE_DIR /.composer_cache

RUN mkdir /packages
COPY . /packages/ValueObject
WORKDIR /packages/ValueObject
COPY . /packages/Base
WORKDIR /packages/Base

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
RUN composer -vvv install
Empty file added .docker/docker.mk
Empty file.
16 changes: 15 additions & 1 deletion .docker/php7.2-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ FROM php:7.2-cli

RUN apt-get update && apt-get install -y git unzip

RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& pecl install ast \
&& docker-php-ext-enable ast \
&& true

# -------------------- Installing PHP Extension: intl --------------------
RUN set -eux \
# Installation: Generic
# Type: Built-in extension
&& apt install -y libicu-dev \
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) intl \
&& true

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_MEMORY_LIMIT -1

Expand All @@ -10,7 +25,6 @@ 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
RUN composer -vvv global require ergebnis/composer-normalize
RUN composer -vvv global require pyrech/composer-changelogs

Expand Down
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# 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

ADGBASE_COMPOSE_PROJECT_NAME=mase

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=secret
###< symfony/framework-bundle ###

###> common variables ###
DOCKER_SERVER_HOST=docker.local
DOCKER_SERVER_PORT=5001
DOCKER_PROJECT_PATH=adgoal/common/base
DOCKER_PHP_VERSION=7.2
DOCKER_IMAGE_VERSION=master
Expand Down
49 changes: 49 additions & 0 deletions .make/static-analysis.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.PHONY: lint layer style coding-standards
static-analysis: lint layer style coding-standards ## Run phpstan, deprac, easycoding standarts code static analysis

.PHONY: phpstan psalm
style: phpstan psalm ## executes php analizers


.PHONY: lint
lint: ## checks syntax of PHP files
docker-compose run --rm --no-deps php sh -lc './vendor/bin/parallel-lint ./ --exclude vendor'

.PHONY: layer
layer: ## check issues with layers (deptrac tool)
docker-compose run --rm --no-deps php sh -lc './vendor/bin/deptrac analyze'

.PHONY: coding-standards
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'

.PHONY: coding-standards-fixer
coding-standards-fixer: ## run code standards fixer
docker-compose run --rm --no-deps php sh -lc './vendor/bin/ecs check src tests --fix'

tests-unit: ## Run unit-tests suite
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/phpunit --configuration /app/phpunit.xml.dist'

tests-integration: ## Run integration-tests suite
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/phpunit --configuration /app/phpunit.func.xml'

.PHONY: infection
infection: ## executes mutation framework infection
docker-compose run --rm --no-deps php-fpm sh -lc './vendor/bin/infection --min-msi=70 --min-covered-msi=80 --threads=$(JOBS) --coverage=var/report'

.PHONY: phpstan
phpstan: ## phpstan - PHP Static Analysis Tool
docker-compose run --rm --no-deps php sh -lc './vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests'

.PHONY: psalm
psalm: ## psalm is a static analysis tool for finding errors in PHP applications
docker-compose run --rm --no-deps php sh -lc './vendor/bin/psalm --config=psalm.xml'

.PHONY: psalm-fixer
psalm-fixer: ## psalm is a static analysis tool for finding errors in PHP applications
docker-compose run --rm --no-deps php sh -lc './vendor/bin/psalm --config=psalm.xml --alter --issues=MissingParamType --dry-run'

.PHONY: phan
phan: ## phan is a static analyzer for PHP that prefers to minimize false-positives.
docker-compose run --rm --no-deps php sh -lc 'PHAN_DISABLE_XDEBUG_WARN=1 PHAN_ALLOW_XDEBUG=1 php -d zend.enable_gc=0 ./vendor/bin/phan --config-file phan.php --require-config-exists'
20 changes: 8 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ cache:
env:
global:
- DOCKER_SERVER_HOST=docker.local
- DOCKER_SERVER_PORT=5001
- DOCKER_PROJECT_PATH=components/base
- TEST_CONFIG="phpunit.xml.dist"

install:
- export DOCKER_IMAGE_VERSION=`echo $TRAVIS_BRANCH | tr "[:upper:]" "[:lower:]" | sed "s/[^a-zA-Z0-9-]/-/g" | sed "s/-$//g" | tr -d '\n' | tr -d '\r'`
- export DOCKER_IMAGE_TAG=$DOCKER_SERVER_HOST:$DOCKER_SERVER_PORT/$DOCKER_PROJECT_PATH/app_test:$DOCKER_IMAGE_VERSION
- docker build . -f .docker/app_test/Dockerfile -t $DOCKER_IMAGE_TAG
#install:
# - export DOCKER_IMAGE_VERSION=`echo $TRAVIS_BRANCH | tr "[:upper:]" "[:lower:]" | sed "s/[^a-zA-Z0-9-]/-/g" | sed "s/-$//g" | tr -d '\n' | tr -d '\r'`
# - export DOCKER_IMAGE_TAG=$DOCKER_SERVER_HOST/$DOCKER_PROJECT_PATH/app_test:$DOCKER_IMAGE_VERSION
# - docker build . -f .docker/app_test/Dockerfile -t $DOCKER_IMAGE_TAG

script:
- docker run $DOCKER_IMAGE_TAG vendor/bin/parallel-lint ./ --exclude vendor
- docker run $DOCKER_IMAGE_TAG vendor/bin/deptrac analyze --formatter-graphviz=0
- docker run $DOCKER_IMAGE_TAG vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests
- docker run $DOCKER_IMAGE_TAG vendor/bin/psalm --config=psalm.xml
- docker run $DOCKER_IMAGE_TAG vendor/bin/ecs check src tests
- docker run $DOCKER_IMAGE_TAG vendor/bin/phpmd src/ text phpmd.xml
- docker run -v $(pwd)/build:/packages/Base/build $DOCKER_IMAGE_TAG vendor/bin/phpunit --configuration $TEST_CONFIG
- make lint
- make static-analysis
- make coding-standards
- make tests-unit
- 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:
Expand Down
38 changes: 8 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
include .env
export

include .make/static-analysis.mk
include .docker/docker.mk

sources = bin/console config src
version = $(shell git describe --tags --dirty --always)
build_name = application-$(version)
Expand All @@ -16,9 +19,8 @@ fix-permission: ## fix permission for docker env

.PHONY: build
build: ## build environment and initialize composer and project dependencies
docker build .docker/php$(DOCKER_PHP_VERSION)-dev/ -t $(DOCKER_SERVER_HOST):$(DOCKER_SERVER_PORT)/$(DOCKER_PROJECT_PATH)/php$(DOCKER_PHP_VERSION)-dev:$(DOCKER_IMAGE_VERSION) \
docker build .docker/php$(DOCKER_PHP_VERSION)-dev/ -t $(DOCKER_SERVER_HOST)/$(DOCKER_PROJECT_PATH)/php$(DOCKER_PHP_VERSION)-dev:$(DOCKER_IMAGE_VERSION) \
--build-arg DOCKER_SERVER_HOST=$(DOCKER_SERVER_HOST) \
--build-arg DOCKER_SERVER_PORT=$(DOCKER_SERVER_PORT) \
--build-arg DOCKER_PROJECT_PATH=$(DOCKER_PROJECT_PATH) \
--build-arg DOCKER_PHP_VERSION=$(DOCKER_PHP_VERSION) \
--build-arg DOCKER_IMAGE_VERSION=$(DOCKER_IMAGE_VERSION)
Expand All @@ -39,11 +41,7 @@ composer-update: ## Update project dependencies

.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'
docker-compose run --rm --no-deps php sh -lc 'composer outdated's

.PHONY: composer
composer: ## Execute composer command
Expand All @@ -53,14 +51,6 @@ composer: ## Execute composer command
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: logs
logs: ## look for service logs
Expand All @@ -74,20 +64,8 @@ help: ## Display this help message
php-shell: ## PHP shell
docker-compose run --rm php sh -l

unit-tests: ## Run unit-tests suite
tests-unit: ## Run unit-tests suite
docker-compose run --rm php sh -lc 'vendor/bin/phpunit --testsuite unit-tests'

static-analysis: style 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 coding-standards composer-validate stop ## Run all test suites
.PHONY: test lint static-analysis phpunit coding-standards tests-unit
test: build lint static-analysis coding-standards tests-unit stop ## Run all test suites
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"jakub-onderka/php-parallel-lint": "^1.0",
"mockery/mockery": "^1.2",
"phpmd/phpmd": "^2.6",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-mockery": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.0",
"roave/security-advisories": "dev-master",
"sensiolabs-de/deptrac-shim": "^0.4",
"symfony/phpunit-bridge": "*",
"symplify/easy-coding-standard": "^5.4",
"vimeo/psalm": "^3.0"
"sensiolabs-de/deptrac-shim": "^0.12.0",
"symplify/easy-coding-standard": "8.3.*",
"vimeo/psalm": "^4.7",
"phan/phan": "4.0.*"
},
"config": {
"preferred-install": {
Expand Down
39 changes: 39 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;


return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]]);

// run and fix, one by one
$containerConfigurator->import(SetList::CLEAN_CODE);
$containerConfigurator->import(SetList::SYMFONY);
$containerConfigurator->import(SetList::PHP_71);
$containerConfigurator->import(SetList::PHP_73_MIGRATION);
$containerConfigurator->import(SetList::PSR_12);

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SKIP, [
\PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer::class => null,
\PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer::class => null,
\PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer::class => null,
\SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff::class => null,
\PhpCsFixer\Fixer\Operator\ConcatSpaceFixer::class => null
]);
};
17 changes: 0 additions & 17 deletions ecs.yml

This file was deleted.

Loading

0 comments on commit e0b956a

Please sign in to comment.