diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ef4466c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 4 + +[Makefile] +indent_style = tab +indent_size = 8 + +[{*.yml,*.yaml}] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..500a7cf --- /dev/null +++ b/.gitattributes @@ -0,0 +1,19 @@ +# Ignore all test and documentation for archive +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/.editorconfig export-ignore +/codecov.yml export-ignore +/.remarkrc export-ignore +/.remarkignore export-ignore +/behat.yml export-ignore +/phpunit.xml.dist export-ignore +/phpcs.xml.dist export-ignore +/CODE_OF_CONDUCT.md export-ignore +/CONTRIBUTING.md export-ignore +/Makefile export-ignore +/tests export-ignore +/features export-ignore +/docs export-ignore diff --git a/.github/.editorconfig b/.github/.editorconfig new file mode 100644 index 0000000..e3ed7d1 --- /dev/null +++ b/.github/.editorconfig @@ -0,0 +1,3 @@ +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..9f25583 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,220 @@ +name: 'CI' +on: # Build any PRs and main branch changes + workflow_dispatch: # Allows to run the workflow manually from the Actions tab + pull_request: + types: + - opened + - edited + - synchronize + push: + branches: [ master ] + schedule: + - cron: '0 0 1 * *' # Every month + +concurrency: + group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}" + cancel-in-progress: true + +env: + TEST_OUTPUT_STYLE: pretty + COMPOSER_OPTIONS: --optimize-autoloader + CODACY_CACHE_PATH: ~/.cache/codacy + CODACY_BIN: ~/.cache/codacy/codacy.sh + +jobs: + tests: + name: UTs & FTs - PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + env: + COVERAGE_TYPE: none + strategy: + fail-fast: true + max-parallel: 4 + matrix: + include: + # Bare minimum => Lowest versions allowed by composer config + - php-version: '8.0' + composer-flag: --prefer-lowest + # Up to date versions => Latest versions allowed by composer config + - php-version: '8.2' + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Enable coverage + if: ${{ matrix.php-version == '8.2' }} + run: | + echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV + echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-version }}' + tools: composer + coverage: ${{ env.COVERAGE_TYPE }} + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v3 + with: + path: | + ~/.composer + ./vendor + ${{ env.CODACY_CACHE_PATH }} + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }} + + - name: Download codacy binary + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p ${{ env.CODACY_CACHE_PATH }} \ + && curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \ + && chmod +x ${{ env.CODACY_BIN }} \ + && ${{ env.CODACY_BIN }} download + + - name: Build + run: | + composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \ + && make build + + - name: Tests + run: make test-unit && make test-functional + + # Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false + # And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context + - name: Upload coverages to Codacy + if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-http-server-openapi-doc-sdk') && env.COVERAGE_TYPE == 'xdebug' }} + run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial + + # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-http-server-openapi-doc-sdk + - name: Upload unit tests coverage to codecov + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} + uses: codecov/codecov-action@v3 + with: + file: "build/coverage-phpunit/unit.clover" + name: "unit-tests-${{ matrix.php-version }}" + flags: "unit-tests,php-${{ matrix.php-version }}" + fail_ci_if_error: true + move_coverage_to_trash: false + verbose: ${{ runner.debug == '1' }} + + - name: Upload functional tests coverage to codecov + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} + uses: codecov/codecov-action@v3 + with: + files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover" + name: "functional-tests-${{ matrix.php-version }}" + flags: "functional-tests,php-${{ matrix.php-version }}" + fail_ci_if_error: true + move_coverage_to_trash: false + verbose: ${{ runner.debug == '1' }} + + static-checks: + name: Static checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP 8.2 + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 # Latest supported + tools: composer + coverage: none + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v3 + with: + path: | + ~/.composer + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }} + + - name: Build + run: make build + + - name: ComposerRequireChecker + uses: docker://webfactory/composer-require-checker:4.5.0 + + - name: Dependencies check + if: ${{ github.event_name == 'pull_request' }} + uses: actions/dependency-review-action@v1 + + finalize-codacy-coverage-report: + runs-on: ubuntu-latest + name: Finalize Codacy coverage report + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-http-server-openapi-doc-sdk' }} + needs: [ tests ] + steps: + - name: Setup cache + id: cache + uses: actions/cache@v3 + with: + path: | + ${{ env.CODACY_CACHE_PATH }} + key: codacy-final + + - name: Download codacy binary + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p ${{ env.CODACY_CACHE_PATH }} \ + && curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \ + && chmod +x ${{ env.CODACY_BIN }} \ + && ${{ env.CODACY_BIN }} download + + - name: Finalize reporting + run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} + + nightly-tests: + name: Nightly - PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + env: + COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' + continue-on-error: true + needs: [ static-checks, tests ] + strategy: + fail-fast: false + max-parallel: 4 + matrix: + php-version: + - '8.3' # Current php dev version + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-version }}' + tools: composer + coverage: none + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v3 + with: + path: | + ~/.composer + ./vendor + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: | + composer update ${{ env.COMPOSER_OPTIONS }} \ + && make build + + - name: Test + run: make test-unit && make test-functional diff --git a/.remarkignore b/.remarkignore new file mode 100644 index 0000000..22d0d82 --- /dev/null +++ b/.remarkignore @@ -0,0 +1 @@ +vendor diff --git a/.remarkrc b/.remarkrc new file mode 100644 index 0000000..0527df5 --- /dev/null +++ b/.remarkrc @@ -0,0 +1,6 @@ +{ + "plugins": [ + "remark-preset-lint-consistent", + "remark-preset-lint-recommended" + ] +} diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 43423bf..b579dd2 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,86 +1,98 @@ 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 + - '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: - - - command: make coverage - idle_timeout: 1200 - coverage: - file: 'build/coverage/clover.xml' - format: 'php-clover' - - php-scrutinizer-run --enable-security-analysis - - make codestyle - cache: - directories: - - ~/.composer - - vendor + dependencies: + override: + - command: make build + title: Build deps + idle_timeout: 240 + tests: + stop_on_failure: true + override: + - command: make codestyle + title: Code style + - command: make scrutinizer-phpunit + idle_timeout: 1200 + coverage: + file: 'build/coverage-phpunit/scrutinizer.xml' + format: 'php-clover' + - command: make scrutinizer-behat + idle_timeout: 1200 + coverage: + file: 'build/coverage-behat/clover.xml' + format: 'php-clover' + - command: php-scrutinizer-run --enable-security-analysis + title: Scrutinizer checks - environment: - variables: - CI: 'true' - TEST_OUTPUT_STYLE: 'pretty' - COMPOSER_OPTIONS: '--optimize-autoloader' - COVERAGE_OUTPUT_STYLE: 'clover' - COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml' - php: - version: "7.1" - timezone: UTC - postgresql: false - redis: false + 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_DISABLE_WARNING: 'true' + php: + version: "8.2" + ini: + memory_limit: "-1" + timezone: UTC + postgresql: false + redis: false filter: - paths: - - src/* + 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 + 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 deleted file mode 100644 index 33bb217..0000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: php - -php: - - '7.1' - - '7.2' - - '7.3' - - '7.4' - -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 || true - -install: - - make build -script: - - make test-technical - - make test-functional - -cache: - directories: - - $HOME/.composer - - vendor - -branches: - except: - - /.*\-dev$/ - - /.*\-patch(\-\d+)?$/ diff --git a/Makefile b/Makefile index 24c8bd3..fdbc8a1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ 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 -BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/behat-coverage -COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml +REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports # Codestyle +BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-behat +PHPUNIT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-phpunit +PHPUNIT_UNIT_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/unit.clover +PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/functional.clover ## Commands options ### Composer @@ -39,14 +39,21 @@ else BEHAT_OUTPUT_STYLE_OPTION ?= --format progress endif -ifeq ("${COVERAGE_OUTPUT_STYLE}","clover") - PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH} -else +ifdef COVERAGE_OUTPUT_STYLE + export XDEBUG_MODE=coverage ifeq ("${COVERAGE_OUTPUT_STYLE}","html") - PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} - else - PHPUNIT_COVERAGE_OPTION ?= --coverage-text - endif + PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${PHPUNIT_COVERAGE_DIRECTORY} + PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-html ${PHPUNIT_COVERAGE_DIRECTORY} + BEHAT_COVERAGE_OPTION ?= --profile coverage-html + else ifeq ("${COVERAGE_OUTPUT_STYLE}","clover") + PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${PHPUNIT_UNIT_COVERAGE_FILE_PATH} + PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-clover ${PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH} + BEHAT_COVERAGE_OPTION ?= --profile coverage-clover + else + PHPUNIT_COVERAGE_OPTION ?= --coverage-text + PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-text + BEHAT_COVERAGE_OPTION ?= --profile coverage + endif endif ifneq ("${PHPCS_REPORT_FILE}","") @@ -71,39 +78,36 @@ install: configure: # Project tests -test: - make test-functional - make test-technical - make codestyle +test: test-functional test-unit codestyle -test-technical: - ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite technical +ifdef PHPUNIT_COVERAGE_OPTION +test-unit: create-build-directories +endif +test-unit: + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} --testsuite technical +ifdef BEHAT_COVERAGE_OPTION +test-functional: create-build-directories +else ifdef PHPUNIT_FUNCTIONAL_COVERAGE_OPTION +test-functional: create-build-directories +endif 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 + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_FUNCTIONAL_COVERAGE_OPTION} --testsuite functional + ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} ${BEHAT_COVERAGE_OPTION} --no-snippets -codestyle: create-reports-directory +codestyle: create-build-directories ./vendor/bin/phpcs ${PHPCS_DISABLE_WARNING_OPTION} --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} +scrutinizer-phpunit: + XDEBUG_MODE=coverage ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --coverage-clover build/coverage-phpunit/scrutinizer.xml -behat-coverage: create-behat-coverage-directory - composer required leanphp/behat-code-coverage - ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets --profile coverage +scrutinizer-behat: + XDEBUG_MODE=coverage ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --profile coverage-clover --no-snippets # Internal commands -create-coverage-directory: - mkdir -p ${COVERAGE_DIRECTORY} - -create-behat-coverage-directory: - mkdir -p ${BEHAT_COVERAGE_DIRECTORY} - -create-reports-directory: - mkdir -p ${REPORTS_DIRECTORY} - +create-build-directories: + mkdir -p ${PHPUNIT_COVERAGE_DIRECTORY} ${BEHAT_COVERAGE_DIRECTORY} ${REPORTS_DIRECTORY} -.PHONY: build install configure test test-technical test-functional codestyle coverage behat-coverage create-coverage-directory create-behat-coverage-directory create-reports-directory +.PHONY: build install configure test test-unit test-functional codestyle create-build-directories scrutinizer-behat scrutinizer-phpunit .DEFAULT: build diff --git a/README.md b/README.md index 532f2da..4fce99f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,18 @@ # JSON-RPC Http server OpenAPI documentation -[![License](https://img.shields.io/github/license/yoanm/php-jsonrpc-http-server-openapi-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/php-jsonrpc-http-server-openapi-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=yoanm/php-jsonrpc-http-server-openapi-doc-sdk)](https://dependabot.com) -[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/build-status/master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/?branch=master) +[![License](https://img.shields.io/github/license/yoanm/php-jsonrpc-http-server-openapi-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) +[![Code size](https://img.shields.io/github/languages/code-size/yoanm/php-jsonrpc-http-server-openapi-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) +[![Dependabot Status](https://api.dependabot.com/badges/status?host=github\&repo=yoanm/php-jsonrpc-http-server-openapi-doc-sdk)](https://dependabot.com) -[![Travis Build Status](https://img.shields.io/travis/com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/master.svg?label=Travis&logo=travis)](https://travis-ci.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) +[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk.svg?label=Scrutinizer\&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/build-status/master) +[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/?branch=master) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/8f39424add044b43a70bdb238e2f48db)](https://www.codacy.com/gh/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/dashboard?utm_source=github.com\&utm_medium=referral\&utm_content=yoanm/php-jsonrpc-http-server-openapi-doc-sdk\&utm_campaign=Badge_Grade) -[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/jsonrpc-http-server-openapi-doc-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-http-server-openapi-doc-sdk) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/jsonrpc-http-server-openapi-doc-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-http-server-openapi-doc-sdk) +[![CI](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/actions/workflows/CI.yml) +[![codecov](https://codecov.io/gh/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/branch/master/graph/badge.svg?token=NHdwEBUFK5)](https://codecov.io/gh/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) + +[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/jsonrpc-http-server-openapi-doc-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-http-server-openapi-doc-sdk) +[![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/jsonrpc-http-server-openapi-doc-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-http-server-openapi-doc-sdk) SDK to generate Http JSON-RPC server documentation for OpenAPI v3.0.0 @@ -13,7 +20,8 @@ See [`yoanm/symfony-jsonrpc-http-server-openapi-doc`](https://github.com/yoanm/s ## How to use -Create the normalizer : +Create the normalizer : + ```php use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ErrorDocNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ExternalSchemaListDocNormalizer; @@ -55,7 +63,8 @@ $normalizer = new DocNormalizer( ); ``` -Then you can convert `ServerDoc` or `HttpServerDoc` by doing : +Then you can convert `ServerDoc` or `HttpServerDoc` by doing : + ```php use Yoanm\JsonRpcServerDoc\Domain\Model\ServerDoc; @@ -69,7 +78,6 @@ $serverDoc = new ServerDoc(); $openAPIDoc = $normalizer->normalize($serverDoc); ``` - - ## Contributing + See [contributing note](./CONTRIBUTING.md) diff --git a/behat.yml b/behat.yml index 4349eaa..0af1455 100644 --- a/behat.yml +++ b/behat.yml @@ -1,19 +1,30 @@ default: + extensions: + DVDoug\Behat\CodeCoverage\Extension: + filter: + include: + directories: + 'src': ~ + reports: [] # No reports suites: default: contexts: - Tests\Functional\BehatContext\DocNormalizerContext: ~ coverage: extensions: - LeanPHP\Behat\CodeCoverage\Extension: - drivers: - - local - filter: - whitelist: - include: - directories: - 'src': ~ - report: - format: html - options: - target: build/behat-coverage + DVDoug\Behat\CodeCoverage\Extension: + reports: + text: + showColors: true +coverage-html: + extensions: + DVDoug\Behat\CodeCoverage\Extension: + reports: + html: + target: build/coverage-behat +coverage-clover: + extensions: + DVDoug\Behat\CodeCoverage\Extension: + reports: + clover: + target: build/coverage-behat/clover.xml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..ad6143e --- /dev/null +++ b/codecov.yml @@ -0,0 +1,12 @@ +coverage: + range: "80...100" + +flags: + nightly: + joined: false + +comment: + show_carryforward_flags: true + +github_checks: + annotations: true diff --git a/composer.json b/composer.json index 94e332a..b0a8e16 100644 --- a/composer.json +++ b/composer.json @@ -25,19 +25,30 @@ } }, "suggest": { + "yoanm/jsonrpc-params-symfony-constraint-doc-sdk": "SDK to generate JSON-RPC documentation from symfony constraint", + "yoanm/jsonrpc-server-sdk": "Server SDK to convert a json-rpc request string into json-rpc response string", "yoanm/symfony-jsonrpc-http-server-openapi-doc": "Symfony bundle for easy JSON-RPC server OpenAPI 3.0.0 documentation", "yoanm/symfony-jsonrpc-http-server-doc": "Symfony bundle for easy JSON-RPC server documentation", "yoanm/symfony-jsonrpc-http-server": "Symfony Bundle to convert an HTTP json-rpc request into HTTP json-rpc response" }, "require": { - "php": ">=7.1", - "yoanm/jsonrpc-server-doc-sdk": "^0.2" + "php": "^8.0", + "yoanm/jsonrpc-server-doc-sdk": "^1.0" }, "require-dev": { "ext-json": "*", - "behat/behat": "~3.0", - "squizlabs/php_codesniffer": "3.*", - "phpunit/phpunit": "^7.0 || ^8.0", - "yoanm/php-unit-extended": "~1.0" + "behat/behat": "^3.9.0", + "dvdoug/behat-code-coverage": "^5.0", + "phpspec/prophecy": "^1.15", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.5", + "yoanm/php-unit-extended": "^2.0" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/tests/Functional/App/Helper/ArrayAppendHelperTraitTest.php b/tests/Functional/App/Helper/ArrayAppendHelperTraitTest.php index 7cd080b..ed9f441 100644 --- a/tests/Functional/App/Helper/ArrayAppendHelperTraitTest.php +++ b/tests/Functional/App/Helper/ArrayAppendHelperTraitTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Helper; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Tests\Common\Helper\ConcreteArrayAppendHelper; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Helper\ArrayAppendHelperTrait; use Yoanm\JsonRpcServerDoc\Domain\Model\ErrorDoc; @@ -13,6 +14,8 @@ */ class ArrayAppendHelperTraitTest extends TestCase { + use ProphecyTrait; + /** @var ArrayAppendHelperTrait|ConcreteArrayAppendHelper */ private $helper; diff --git a/tests/Functional/App/Normalizer/Component/ErrorDocNormalizerTest.php b/tests/Functional/App/Normalizer/Component/ErrorDocNormalizerTest.php index 72bc9d8..4a88ed1 100644 --- a/tests/Functional/App/Normalizer/Component/ErrorDocNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/ErrorDocNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ErrorDocNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ShapeNormalizer; @@ -16,6 +17,8 @@ */ class ErrorDocNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var TypeDocNormalizer|ObjectProphecy */ private $typeDocNormalizer; /** @var ShapeNormalizer|ObjectProphecy */ diff --git a/tests/Functional/App/Normalizer/Component/ExternalSchemaListDocNormalizerTest.php b/tests/Functional/App/Normalizer/Component/ExternalSchemaListDocNormalizerTest.php index de8a0b5..a697b2f 100644 --- a/tests/Functional/App/Normalizer/Component/ExternalSchemaListDocNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/ExternalSchemaListDocNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ErrorDocNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ExternalSchemaListDocNormalizer; @@ -19,6 +20,8 @@ */ class ExternalSchemaListDocNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var TypeDocNormalizer|ObjectProphecy */ private $typeDocNormalizer; /** @var ErrorDocNormalizer|ObjectProphecy */ diff --git a/tests/Functional/App/Normalizer/Component/OperationDocNormalizerTest.php b/tests/Functional/App/Normalizer/Component/OperationDocNormalizerTest.php index 131765b..7d1b89a 100644 --- a/tests/Functional/App/Normalizer/Component/OperationDocNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/OperationDocNormalizerTest.php @@ -3,6 +3,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\OperationDocNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\RequestDocNormalizer; @@ -19,6 +20,8 @@ */ class OperationDocNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var RequestDocNormalizer|ObjectProphecy */ private $requestDocTransformer; /** @var ResponseDocNormalizer|ObjectProphecy */ diff --git a/tests/Functional/App/Normalizer/Component/RequestDocNormalizerTest.php b/tests/Functional/App/Normalizer/Component/RequestDocNormalizerTest.php index 6cc6510..ba1d489 100644 --- a/tests/Functional/App/Normalizer/Component/RequestDocNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/RequestDocNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\RequestDocNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ShapeNormalizer; @@ -16,6 +17,8 @@ */ class RequestDocNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var DefinitionRefResolver|ObjectProphecy */ private $definitionRefResolver; /** @var ShapeNormalizer|ObjectProphecy */ diff --git a/tests/Functional/App/Normalizer/Component/ResponseDocNormalizerTest.php b/tests/Functional/App/Normalizer/Component/ResponseDocNormalizerTest.php index b77e7b3..53457e0 100644 --- a/tests/Functional/App/Normalizer/Component/ResponseDocNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/ResponseDocNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ResponseDocNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ShapeNormalizer; @@ -17,6 +18,8 @@ */ class ResponseDocNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var ShapeNormalizer|ObjectProphecy */ private $shapeNormalizer; /** @var ResponseDocNormalizer */ diff --git a/tests/Functional/App/Normalizer/Component/SchemaTypeNormalizerTest.php b/tests/Functional/App/Normalizer/Component/SchemaTypeNormalizerTest.php index 46ec5cf..f5f1247 100644 --- a/tests/Functional/App/Normalizer/Component/SchemaTypeNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/SchemaTypeNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Tests\Common\TypeDoc\NotManagedTypeDoc; use Tests\Common\TypeDoc\NullDoc; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\SchemaTypeNormalizer; @@ -14,6 +15,8 @@ */ class SchemaTypeNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var SchemaTypeNormalizer */ private $normalizer; diff --git a/tests/Functional/App/Normalizer/Component/ShapeNormalizerTest.php b/tests/Functional/App/Normalizer/Component/ShapeNormalizerTest.php index 3555abe..8e553e8 100644 --- a/tests/Functional/App/Normalizer/Component/ShapeNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/ShapeNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ShapeNormalizer; /** @@ -11,6 +12,8 @@ */ class ShapeNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var ShapeNormalizer */ private $normalizer; diff --git a/tests/Functional/App/Normalizer/Component/TypeDocNormalizerTest.php b/tests/Functional/App/Normalizer/Component/TypeDocNormalizerTest.php index a804097..1752f07 100644 --- a/tests/Functional/App/Normalizer/Component/TypeDocNormalizerTest.php +++ b/tests/Functional/App/Normalizer/Component/TypeDocNormalizerTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Normalizer\Component; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\SchemaTypeNormalizer; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\TypeDocNormalizer; use Yoanm\JsonRpcServerDoc\Domain\Model\Type as TypeDocNs; @@ -13,6 +14,8 @@ */ class TypeDocNormalizerTest extends TestCase { + use ProphecyTrait; + /** @var TypeDocNormalizer */ private $normalizer; diff --git a/tests/Functional/App/Resolver/DefinitionRefResolverTest.php b/tests/Functional/App/Resolver/DefinitionRefResolverTest.php index aeedeb9..48c272e 100644 --- a/tests/Functional/App/Resolver/DefinitionRefResolverTest.php +++ b/tests/Functional/App/Resolver/DefinitionRefResolverTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\App\Resolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Resolver\DefinitionRefResolver; use Yoanm\JsonRpcServerDoc\Domain\Model\ErrorDoc; @@ -14,6 +15,8 @@ */ class DefinitionRefResolverTest extends TestCase { + use ProphecyTrait; + /** @var DefinitionRefResolver */ private $resolver; diff --git a/tests/Functional/Infra/Normalizer/DocNormalizerTest.php b/tests/Functional/Infra/Normalizer/DocNormalizerTest.php index 06b5b45..3a34a5e 100644 --- a/tests/Functional/Infra/Normalizer/DocNormalizerTest.php +++ b/tests/Functional/Infra/Normalizer/DocNormalizerTest.php @@ -1,7 +1,8 @@