From 630a7682072a3c5ef6723c01c97aba117440d108 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Mon, 14 May 2018 14:33:00 +0200 Subject: [PATCH] Init --- .gitignore | 4 ++ .scrutinizer.yml | 92 ++++++++++++++++++++++++++ .travis.yml | 33 ++++++++++ CONTRIBUTING.md | 33 ++++++++++ Makefile | 95 +++++++++++++++++++++++++++ README.md | 17 +++++ behat.yml | 5 ++ composer.json | 46 +++++++++++++ features/bootstrap/FeatureContext.php | 21 ++++++ phpcs.xml.dist | 12 ++++ phpunit.xml.dist | 49 ++++++++++++++ src/.gitkeep | 0 tests/Functional/.gitkeep | 0 tests/Technical/.gitkeep | 0 14 files changed, 407 insertions(+) create mode 100644 .gitignore create mode 100644 .scrutinizer.yml create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md create mode 100644 Makefile create mode 100644 README.md create mode 100644 behat.yml create mode 100644 composer.json create mode 100644 features/bootstrap/FeatureContext.php create mode 100644 phpcs.xml.dist create mode 100644 phpunit.xml.dist create mode 100644 src/.gitkeep create mode 100644 tests/Functional/.gitkeep create mode 100644 tests/Technical/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6ac9a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +vendor +build +#A library must not provide a composer.lock file +composer.lock diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..5a1a311 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,92 @@ +build_failure_conditions: + - 'project.metric_change("scrutinizer.quality", < -0.30)' + - 'elements.rating(<= D).exists' # No classes/methods with a rating of D or worse + - 'issues.severity(>= MAJOR).exists' # New major or higher severity issues + - 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9 + - 'project.metric("scrutinizer.test_coverage", < 1)' # Code Coverage must alway be 100% + - 'patches.label("Doc Comments").exists' # No doc comments patches allowed + - 'patches.label("Spacing").exists' # No spacing patches allowed + - 'patches.label("Bug").exists' # No bug patches allowed + - 'issues.label("coding-style").exists' # No coding style issues allowed +build: + dependencies: + override: + - make build + tests: + stop_on_failure: true + override: + - php-scrutinizer-run --enable-security-analysis + - + command: make codestyle + analysis: + file: 'build/reports/cs-data' + format: 'php-cs-checkstyle' + - + command: make coverage + idle_timeout: 1200 + coverage: + file: 'build/coverage/clover.xml' + format: 'php-clover' + cache: + directories: + - ~/.composer + - vendor + + environment: + variables: + CI: 'true' + TEST_OUTPUT_STYLE: 'pretty' + COMPOSER_OPTIONS: '--optimize-autoloader' + COVERAGE_OUTPUT_STYLE: 'clover' + COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml' + PHPCS_REPORT_STYLE: 'checkstyle' + PHPCS_REPORT_FILE: 'build/reports/cs-data' + php: + version: "7.1" + timezone: UTC + postgresql: false + redis: false +filter: + paths: + - src/* +checks: + php: + code_rating: true + duplication: true + no_debug_code: true + check_method_contracts: + verify_interface_like_constraints: true + verify_documented_constraints: true + verify_parent_constraints: true + simplify_boolean_return: true + return_doc_comments: true + return_doc_comment_if_not_inferrable: true + remove_extra_empty_lines: true + properties_in_camelcaps: true + phpunit_assertions: true + parameters_in_camelcaps: true + parameter_doc_comments: true + param_doc_comment_if_not_inferrable: true + overriding_parameter: true + no_trailing_whitespace: true + no_short_variable_names: + minimum: '3' + no_short_method_names: + minimum: '3' + no_long_variable_names: + maximum: '20' + no_goto: true + naming_conventions: + local_variable: '^[a-z][a-zA-Z0-9]*$' + abstract_class_name: ^Abstract|Factory$ + utility_class_name: 'Utils?$' + constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$' + property_name: '^[a-z][a-zA-Z0-9]*$' + method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$' + parameter_name: '^[a-z][a-zA-Z0-9]*$' + interface_name: '^[A-Z][a-zA-Z0-9]*Interface$' + type_name: '^[A-Z][a-zA-Z0-9]*$' + exception_name: '^[A-Z][a-zA-Z0-9]*Exception$' + isser_method_name: '^(?:is|has|should|may|supports)' + more_specific_types_in_doc_comments: true + fix_doc_comments: false diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b9cd43f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: php + +php: + - '7.0' + - '7.1' + - '7.2' + +env: + global: + CI: 'true' + TEST_OUTPUT_STYLE: 'pretty' + PHPCS_REPORT_STYLE: 'full' + COMPOSER_OPTIONS: '--optimize-autoloader' + +sudo: false + +matrix: + fast_finish: true + +before_install: + # remove xdebug to speed up build + - phpenv config-rm xdebug.ini + +install: + - make build +script: + - make test-technical + - make test-functional + +cache: + directories: + - $HOME/.composer + - vendor diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5741f51 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contributing + +## Getting Started + * Fork, then clone the repo: +```bash +git clone git@github.com:your-username/symfony-jsonrpc-http-server-openapi-doc.git +```` + + * Make sure everything goes well: +```bash +make build +make test +``` + + * Make your changes (Add/Update tests according to your changes). + * Make sure tests are still green: +```bash +make test +``` + + * To check code coverage, launch +```bash +make coverage +``` + + * Push to your fork and [submit a pull request](https://github.com/yoanm/symfony-jsonrpc-http-server-openapi-doc/compare/). + * Wait for feedback or merge. + + Some stuff that will increase your pull request's acceptance: + * Write tests. + * Follow PSR-2 coding style. + * Write good commit messages. + * Do not rebase or squash your commits when a review has been made. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61a3638 --- /dev/null +++ b/Makefile @@ -0,0 +1,95 @@ +COLOR_ENABLED ?= true +TEST_OUTPUT_STYLE ?= dot +COVERAGE_OUTPUT_STYLE ?= html + +## DIRECTORY AND FILE +BUILD_DIRECTORY ?= build +REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports +COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage +COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml + +## Commands options +### Composer +#COMPOSER_OPTIONS= +### Phpcs +PHPCS_REPORT_STYLE ?= full +#PHPCS_REPORT_FILE= +#PHPCS_REPORT_FILE_OPTION= + +# Enable/Disable color ouput +ifeq ("${COLOR_ENABLED}","true") + PHPUNIT_COLOR_OPTION ?= --colors=always + BEHAT_COLOR_OPTION ?= --colors + PHPCS_COLOR_OPTION ?= --colors + COMPOSER_COLOR_OPTION ?= --ansi +else + PHPUNIT_COLOR_OPTION ?= --colors=never + PHPCS_COLOR_OPTION ?= --no-colors + BEHAT_COLOR_OPTION ?= --no-colors + COMPOSER_COLOR_OPTION ?= --no-ansi +endif + +ifeq ("${TEST_OUTPUT_STYLE}","pretty") + PHPUNIT_OUTPUT_STYLE_OPTION ?= --testdox + BEHAT_OUTPUT_STYLE_OPTION ?= --format pretty +else + PHPUNIT_OUTPUT_STYLE_OPTION ?= + BEHAT_OUTPUT_STYLE_OPTION ?= --format progress +endif + +ifeq ("${COVERAGE_OUTPUT_STYLE}","clover") + PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH} +else + ifeq ("${COVERAGE_OUTPUT_STYLE}","html") + PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} + else + PHPUNIT_COVERAGE_OPTION ?= --coverage-text + endif +endif + +ifneq ("${PHPCS_REPORT_FILE}","") + PHPCS_REPORT_FILE_OPTION ?= --report-file=${PHPCS_REPORT_FILE} +endif + + +## Project build (install and configure) +build: install configure + +## Project installation +install: + composer install ${COMPOSER_COLOR_OPTION} ${COMPOSER_OPTIONS} --prefer-dist --no-suggest --no-interaction + +## project Configuration +configure: + +# Project tests +test: + make test-functional + make test-technical + make codestyle + +test-technical: + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite technical + +test-functional: + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite functional + ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets + +codestyle: create-reports-directory + ./vendor/bin/phpcs --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE} + +coverage: create-coverage-directory + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} + + + +# Internal commands +create-coverage-directory: + mkdir -p ${COVERAGE_DIRECTORY} + +create-reports-directory: + mkdir -p ${REPORTS_DIRECTORY} + + +.PHONY: build install configure test test-technical test-functional codestyle coverage create-coverage-directory create-reports-directory +.DEFAULT: build diff --git a/README.md b/README.md new file mode 100644 index 0000000..482af6d --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Symfony JSON-RPC Http server OpenAPI documentation + +[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server-openapi-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server-openapi-doc) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server-openapi-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server-openapi-doc) [![PHP Versions](https://img.shields.io/badge/php-7.0%20%2F%207.1%20%2F%207.2-8892BF.svg)](https://php.net/) + +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-openapi-doc/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-openapi-doc/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-openapi-doc/badges/build.png?b=master)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-openapi-doc/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-openapi-doc/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-openapi-doc/?branch=master) + +[![Travis Build Status](https://img.shields.io/travis/yoanm/symfony-jsonrpc-http-server-openapi-doc/master.svg?label=travis)](https://travis-ci.org/yoanm/symfony-jsonrpc-http-server-openapi-doc) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-http-server-openapi-doc.svg)](https://travis-ci.org/yoanm/symfony-jsonrpc-http-server-openapi-doc) + +[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server-openapi-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server-openapi-doc) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server-openapi-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server-openapi-doc) + +Symfony bundle for easy JSON-RPC server OpenAPI 3.0.0 documentation + +## How to use +   + +## Contributing +See [contributing note](./CONTRIBUTING.md) diff --git a/behat.yml b/behat.yml new file mode 100644 index 0000000..a5ce152 --- /dev/null +++ b/behat.yml @@ -0,0 +1,5 @@ +default: + suites: + default: + contexts: + - Tests\Functional\BehatContext\FeatureContext: ~ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..69beefd --- /dev/null +++ b/composer.json @@ -0,0 +1,46 @@ +{ + "name": "yoanm/symfony-jsonrpc-http-server-openapi-doc", + "description": "Symfony bundle for easy JSON-RPC server OpenAPI 3.0.0 documentation", + "license": "MIT", + "type": "library", + "support": { + "issues": "https://github.com/yoanm/symfony-jsonrpc-http-server-openapi-doc/issues" + }, + "authors": [ + { + "name": "Yoanm", + "email": "yoanm@users.noreply.github.com", + "role": "Developer" + } + ], + "autoload": { + "psr-4": { + "Yoanm\\SymfonyJsonRpcHttpServerOpenAPIDoc\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests", + "Tests\\Functional\\BehatContext\\": "features/bootstrap" + } + }, + "require": { + "php": ">=5.5", + "yoanm/jsonrpc-server-doc-sdk": "dev-feature/improve", + "yoanm/jsonrpc-http-server-openapi-doc-sdk": "dev-feature/improve", + "yoanm/symfony-jsonrpc-http-server-doc": "dev-feature/improve", + "symfony/http-foundation": "^3.0 || ^4.0", + "symfony/http-kernel": "^3.0 || ^4.0", + "symfony/config": "^3.0 || ^4.0", + "symfony/dependency-injection": "^3.0 || ^4.0" + }, + "require-dev": { + "behat/behat": "~3.0", + "squizlabs/php_codesniffer": "3.*", + "phpunit/phpunit": "^6.0 || ^7.0", + "matthiasnoback/symfony-dependency-injection-test": "^2.0 || ^3.0", + "matthiasnoback/symfony-config-test": "^3.0 || ^4.0", + "symfony/framework-bundle": "^3.4", + "yoanm/php-unit-extended": "~1.0" + } +} diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php new file mode 100644 index 0000000..f562608 --- /dev/null +++ b/features/bootstrap/FeatureContext.php @@ -0,0 +1,21 @@ + + + src + tests + features/bootstrap + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..cb7c344 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,49 @@ + + + + + + + + + + + tests/Functional + + + tests/Technical + + + + + + src + + + diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Functional/.gitkeep b/tests/Functional/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Technical/.gitkeep b/tests/Technical/.gitkeep new file mode 100644 index 0000000..e69de29