From bd80b063b882fa930af5d66262e67cd64f6d0ce9 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 19:27:01 +0200 Subject: [PATCH 01/38] Refactor before fixing CI --- features/bootstrap/AbstractContext.php | 10 +++++ features/demo_app/src/AbstractKernel.php | 40 +++++++++++++++++-- features/demo_app/src/DefaultKernel.php | 36 +++-------------- .../KernelWithMappingCollectorListener.php | 36 +++-------------- 4 files changed, 57 insertions(+), 65 deletions(-) diff --git a/features/bootstrap/AbstractContext.php b/features/bootstrap/AbstractContext.php index ec3a27f..acb2a47 100644 --- a/features/bootstrap/AbstractContext.php +++ b/features/bootstrap/AbstractContext.php @@ -6,6 +6,7 @@ use DemoApp\DefaultKernel; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class AbstractContext implements Context { @@ -23,6 +24,15 @@ public function jsonDecode($encodedData) return $decoded; } + /** + * {@inheritdoc} + */ + protected function configureRoutes(RoutingConfigurator $routes) + { + $confDir = $this->getConfigDir(); + $routes->import($confDir.'/routes'.self::CONFIG_EXTS, 'glob'); + } + /** * @param string $uri * @param string $httpMethod diff --git a/features/demo_app/src/AbstractKernel.php b/features/demo_app/src/AbstractKernel.php index 5848183..1179200 100644 --- a/features/demo_app/src/AbstractKernel.php +++ b/features/demo_app/src/AbstractKernel.php @@ -2,8 +2,11 @@ namespace DemoApp; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseHttpKernel; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; abstract class AbstractKernel extends BaseHttpKernel { @@ -13,6 +16,17 @@ abstract class AbstractKernel extends BaseHttpKernel /** @var string|null */ private $customCacheDir = null; + public function registerBundles(): iterable + { + /** @noinspection PhpIncludeInspection */ + $contents = require $this->getConfigDir().'/bundles.php'; + foreach ($contents as $class => $envs) { + if (isset($envs['all']) || isset($envs[$this->environment])) { + yield new $class(); + } + } + } + /** * {@inheritdoc} */ @@ -20,7 +34,7 @@ public function getCacheDir() { // Use a specific cache for each kernels if (null === $this->customCacheDir) { - $this->customCacheDir = $this->getProjectDir().'/var/cache/'.$this->environment.'/'.$this->getConfigDirectory(); + $this->customCacheDir = $this->getProjectDir().'/var/cache/'.$this->environment.'/'.$this->getConfigDirectoryName(); } return $this->customCacheDir; @@ -41,6 +55,25 @@ public function getProjectDir() { return realpath(__DIR__.'/../'); } + /** + * {@inheritdoc} + */ + protected function configureRoutes($routes) + { + $confDir = $this->getConfigDir(); + $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); + } + + /** + * {@inheritdoc} + */ + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) + { + $container->setParameter('container.dumper.inline_class_loader', true); + $confDir = $this->getConfigDir(); + $loader->load($confDir.'/config'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob'); + } /** * Gets the container class. @@ -50,8 +83,9 @@ public function getProjectDir() protected function getContainerClass() { // In order to avoid collisions between kernels use a dedicated name - return parent::getContainerClass().Container::camelize($this->getConfigDirectory()); + return parent::getContainerClass().Container::camelize($this->getConfigDirectoryName()); } - abstract public function getConfigDirectory() : string; + abstract public function getConfigDirectoryName() : string; + abstract public function getConfigDir(): string; } diff --git a/features/demo_app/src/DefaultKernel.php b/features/demo_app/src/DefaultKernel.php index 8d505a1..ae536f5 100644 --- a/features/demo_app/src/DefaultKernel.php +++ b/features/demo_app/src/DefaultKernel.php @@ -3,46 +3,20 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class DefaultKernel extends AbstractKernel { - public function registerBundles(): iterable - { - /** @noinspection PhpIncludeInspection */ - $contents = require $this->getProjectDir().'/'.$this->getConfigDirectory().'/bundles.php'; - foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { - yield new $class(); - } - } - } - - /** - * {@inheritdoc} - */ - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) - { - $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir().'/'.$this->getConfigDirectory(); - $loader->load($confDir.'/config'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob'); - } - /** * {@inheritdoc} */ - protected function configureRoutes(RouteCollectionBuilder $routes) + public function getConfigDirectoryName() : string { - $confDir = $this->getProjectDir().'/'.$this->getConfigDirectory(); - $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); + return 'default_config'; } - /** - * {@inheritdoc} - */ - public function getConfigDirectory() : string + public function getConfigDir(): string { - return 'default_config'; + return $this->getProjectDir().'/'.$this->getConfigDirectoryName(); } } diff --git a/features/demo_app/src/KernelWithMappingCollectorListener.php b/features/demo_app/src/KernelWithMappingCollectorListener.php index 17914ab..0da3e3c 100644 --- a/features/demo_app/src/KernelWithMappingCollectorListener.php +++ b/features/demo_app/src/KernelWithMappingCollectorListener.php @@ -3,46 +3,20 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class KernelWithMappingCollectorListener extends AbstractKernel { - public function registerBundles(): iterable - { - /** @noinspection PhpIncludeInspection */ - $contents = require $this->getProjectDir().'/'.$this->getConfigDirectory().'/bundles.php'; - foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { - yield new $class(); - } - } - } - - /** - * {@inheritdoc} - */ - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) - { - $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir().'/'.$this->getConfigDirectory(); - $loader->load($confDir.'/config'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob'); - } - /** * {@inheritdoc} */ - protected function configureRoutes(RouteCollectionBuilder $routes) + public function getConfigDirectoryName() : string { - $confDir = $this->getProjectDir().'/'.$this->getConfigDirectory(); - $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); + return 'mapping_collector_config'; } - /** - * {@inheritdoc} - */ - public function getConfigDirectory() : string + public function getConfigDir(): string { - return 'mapping_collector_config'; + return $this->getProjectDir().'/'.$this->getConfigDirectoryName(); } } From 3d132cd16b4e1e57b18a6e9f65fcdfde8e5d097e Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 19:36:58 +0200 Subject: [PATCH 02/38] Cleaning & fixes --- features/demo_app/src/AbstractKernel.php | 10 ++++++++-- features/demo_app/src/DefaultKernel.php | 4 ---- .../src/KernelWithMappingCollectorListener.php | 4 ---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/features/demo_app/src/AbstractKernel.php b/features/demo_app/src/AbstractKernel.php index 1179200..01af49c 100644 --- a/features/demo_app/src/AbstractKernel.php +++ b/features/demo_app/src/AbstractKernel.php @@ -7,6 +7,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseHttpKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use Symfony\Component\Routing\RouteCollectionBuilder; abstract class AbstractKernel extends BaseHttpKernel { @@ -55,13 +56,18 @@ public function getProjectDir() { return realpath(__DIR__.'/../'); } + /** - * {@inheritdoc} + * @param RouteCollectionBuilder|RoutingConfigurator $routes */ protected function configureRoutes($routes) { $confDir = $this->getConfigDir(); - $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); + if ($routes instanceof RoutingConfigurator) { + $routes->import($confDir . '/routes' . self::CONFIG_EXTS, 'glob'); + } else { + $routes->import($confDir . '/routes' . self::CONFIG_EXTS, '/', 'glob'); + } } /** diff --git a/features/demo_app/src/DefaultKernel.php b/features/demo_app/src/DefaultKernel.php index ae536f5..de495b7 100644 --- a/features/demo_app/src/DefaultKernel.php +++ b/features/demo_app/src/DefaultKernel.php @@ -1,10 +1,6 @@ Date: Sat, 18 Jun 2022 20:30:41 +0200 Subject: [PATCH 03/38] Supported symfony versions --- .travis.yml | 7 ++++--- composer.json | 16 ++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10076e3..ee992b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,9 @@ language: php php: - '7.2' - - '7.3' - '7.4' + - '8.0' + - '8.1' env: global: @@ -12,8 +13,8 @@ env: - PHPCS_REPORT_STYLE: 'full' - COMPOSER_OPTIONS: '--optimize-autoloader' jobs: - - SYMFONY_VERSION: '~4.0' - - SYMFONY_VERSION: '~5.0' + - SYMFONY_VERSION: '^4.4' + - SYMFONY_VERSION: '^5.4' jobs: fast_finish: true diff --git a/composer.json b/composer.json index 512a4b3..bf9e4d3 100644 --- a/composer.json +++ b/composer.json @@ -30,13 +30,13 @@ "yoanm/symfony-jsonrpc-http-server-doc": "JSON-RPC documentation Bundle" }, "require": { - "php": ">=7.2", + "php": "^7.2 || ^8.0", "yoanm/jsonrpc-server-sdk": "^3.0", - "symfony/http-foundation": "^4.0 || ^5.0", - "symfony/http-kernel": "^4.0 || ^5.0", - "symfony/config": "^4.0 || ^5.0", - "symfony/dependency-injection": "^4.0 || ^5.0", - "symfony/event-dispatcher": "^4.0 || ^5.0", + "symfony/http-foundation": "^4.4 || ^5.4", + "symfony/http-kernel": "^4.4 || ^5.4", + "symfony/config": "^4.4 || ^5.4", + "symfony/dependency-injection": "^4.4 || ^5.4", + "symfony/event-dispatcher": "^4.4 || ^5.4", "symfony/event-dispatcher-contracts": "^1.0 || ^2.0", "psr/container": "^1.0" }, @@ -46,8 +46,8 @@ "phpunit/phpunit": "^7.0 || ^8.0", "matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0", "matthiasnoback/symfony-config-test": "^3.0 || ^4.0", - "symfony/framework-bundle": "^4.0 || ^5.0", - "symfony/routing": "^4.0 || ^5.0", + "symfony/framework-bundle": "^4.4 || ^5.4", + "symfony/routing": "^4.4 || ^5.4", "yoanm/php-unit-extended": "~1.0" } } From cabc99fc468ef6e0103e376b56d3118d243c5f28 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 21:01:12 +0200 Subject: [PATCH 04/38] GHAction CI / PHP 8.1 / CodeCov / EditorConfig --- .editorconfig | 16 ++++ .github/.editorconfig | 3 + .github/dependabot.yml | 10 +-- .github/workflows/CI.yml | 141 +++++++++++++++++++++++++++++++ .scrutinizer.yml | 178 +++++++++++++++++++-------------------- .travis.yml | 42 --------- Makefile | 64 +++++++------- README.md | 14 ++- behat.yml | 35 +++++--- composer.json | 6 +- 10 files changed, 320 insertions(+), 189 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/.editorconfig create mode 100644 .github/workflows/CI.yml delete mode 100644 .travis.yml 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/.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/dependabot.yml b/.github/dependabot.yml index b7dd1d2..a5538c7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ version: 2 updates: -- package-ecosystem: composer - directory: "/" - schedule: - interval: monthly - open-pull-requests-limit: 10 + - package-ecosystem: composer + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 10 diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..db336b2 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,141 @@ +name: 'CI' +on: # rebuild any PRs and main branch changes + pull_request: + types: + - opened + - synchronize + push: + branches: [ master ] + +concurrency: + group: "CI-${{ github.head_ref }}" + cancel-in-progress: true + +env: + # Cache params + CACHE_VERSION: 2022061801 # To be able to create a new cache (YYYYMMDDXX) + CI: 'true' + COVERAGE_OUTPUT_STYLE: clover + TEST_OUTPUT_STYLE: 'pretty' + PHPCS_REPORT_STYLE: 'full' + COMPOSER_OPTIONS: '--optimize-autoloader' + +jobs: + unit-tests: + name: Unit / PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php-version: + - '7.4' + - '8.0' + - '8.1' + symfony-version: + - '4.4' + - '5.4' + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-version }}' + tools: composer + coverage: xdebug + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v2 + with: + path: | + ~/.composer + ./vendor + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: | + composer require \ + symfony/http-foundation:^${{ matrix.symfony-version }} \ + symfony/http-kernel:^${{ matrix.symfony-version }} \ + symfony/config:^${{ matrix.symfony-version }} \ + symfony/dependency-injection:^${{ matrix.symfony-version }} \ + symfony/event-dispatcher:^${{ matrix.symfony-version }} \ + symfony/routing:^${{ matrix.symfony-version }} \ + && make build + + - name: Test + run: make test-unit + + # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk + - name: Upload coverage to codecov + uses: codecov/codecov-action@v2 + with: + name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" + flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + fail_ci_if_error: true + + functional-tests: + name: Functional / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} + needs: [ unit-tests ] + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php-version: + - '7.4' + - '8.0' + - '8.1' + symfony-version: + - '4.4' + - '5.4' + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-version }}' + tools: composer + coverage: xdebug + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v2 + with: + path: | + ~/.composer + ./vendor + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: | + composer require \ + symfony/http-foundation:^${{ matrix.symfony-version }} \ + symfony/http-kernel:^${{ matrix.symfony-version }} \ + symfony/config:^${{ matrix.symfony-version }} \ + symfony/dependency-injection:^${{ matrix.symfony-version }} \ + symfony/event-dispatcher:^${{ matrix.symfony-version }} \ + symfony/routing:^${{ matrix.symfony-version }} \ + && make build + + - name: Test + run: make test-functional + + # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk + - name: Upload coverage to codecov + uses: codecov/codecov-action@v2 + with: + name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" + flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + fail_ci_if_error: true diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 2f16f37..4ad7776 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,98 +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 + - '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: - - - command: make build - title: Build deps - idle_timeout: 240 - tests: - stop_on_failure: true - override: - - - command: make coverage - title: Coverage - idle_timeout: 1200 - coverage: - file: 'build/coverage/clover.xml' - format: 'php-clover' - - - command: make codestyle - title: Code style - - - command: composer global require maglnet/composer-require-checker && composer-require-checker check composer.json - title: Composer-require-checker - - - command: php-scrutinizer-run --enable-security-analysis - title: Scrutinizer checks + 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/clover.xml' + format: 'php-clover' + - command: composer global require maglnet/composer-require-checker && composer-require-checker check composer.json + title: Composer-require-checker + - command: php-scrutinizer-run --enable-security-analysis + title: Scrutinizer checks - cache: - directories: - - ~/.composer - - vendor + 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' - php: - version: "7.3" - timezone: UTC - postgresql: false - redis: false + 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: "8.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 ee992b1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: php - -php: - - '7.2' - - '7.4' - - '8.0' - - '8.1' - -env: - global: - - CI: 'true' - - TEST_OUTPUT_STYLE: 'pretty' - - PHPCS_REPORT_STYLE: 'full' - - COMPOSER_OPTIONS: '--optimize-autoloader' - jobs: - - SYMFONY_VERSION: '^4.4' - - SYMFONY_VERSION: '^5.4' - -jobs: - fast_finish: true - -before_install: - # remove xdebug to speed up build - - phpenv config-rm xdebug.ini || true - -install: - - composer require symfony/http-foundation:$SYMFONY_VERSION symfony/http-kernel:$SYMFONY_VERSION symfony/config:$SYMFONY_VERSION symfony/dependency-injection:$SYMFONY_VERSION symfony/event-dispatcher:$SYMFONY_VERSION symfony/routing:$SYMFONY_VERSION - - make build -script: - - make test-technical - - make test-functional - -cache: - directories: - - $HOME/.composer - - vendor - -branches: - except: - - /.*\-dev$/ - - /^dev-.*$/ - - /.*\-patch(\-\d+)?$/ diff --git a/Makefile b/Makefile index 24c8bd3..72a61ca 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,11 @@ 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 +BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-behat COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml ## Commands options @@ -39,14 +38,18 @@ 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 ${COVERAGE_DIRECTORY} + BEHAT_COVERAGE_OPTION ?= --profile coverage-html + else ifeq ("${COVERAGE_OUTPUT_STYLE}","clover") + PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH} + BEHAT_COVERAGE_OPTION ?= --profile coverage-clover + else + PHPUNIT_COVERAGE_OPTION ?= --coverage-text + BEHAT_COVERAGE_OPTION ?= --profile coverage + endif endif ifneq ("${PHPCS_REPORT_FILE}","") @@ -71,39 +74,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_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_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 +scrutinizer-phpunit: ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} -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: + ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} ${BEHAT_COVERAGE_OPTION} --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 ${COVERAGE_DIRECTORY} ${BEHAT_COVERAGE_DIRECTORY} ${REPORTS_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 b6c62e8..952c629 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,17 @@ # Symfony JSON-RPC server -[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=yoanm/symfony-jsonrpc-http-server)](https://dependabot.com) +[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server) +[![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server) +[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=yoanm/symfony-jsonrpc-http-server)](https://dependabot.com) -[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/build-status/master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/symfony-jsonrpc-http-server/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/symfony-jsonrpc-http-server/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/?branch=master) +[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/build-status/master) +[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/symfony-jsonrpc-http-server/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/?branch=master) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/symfony-jsonrpc-http-server/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/?branch=master) -[![Travis Build Status](https://img.shields.io/travis/com/yoanm/symfony-jsonrpc-http-server/master.svg?label=Travis&logo=travis)](https://travis-ci.com/yoanm/symfony-jsonrpc-http-server) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-http-server.svg?logo=travis)](https://php.net/) [![Travis Symfony Versions](https://img.shields.io/badge/Symfony-v4%20%2F%20v5-8892BF.svg?logo=travis)](https://php.net/) +[![CI](https://github.com/yoanm/symfony-jsonrpc-http-server/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/yoanm/symfony-jsonrpc-http-server/actions/workflows/CI.yml) +[![codecov](https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server/branch/master/graph/badge.svg?token=NHdwEBUFK5)](https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server) -[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server) +[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server) +[![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server) Symfony JSON-RPC HTTP Server to convert an HTTP json-rpc request into HTTP json-rpc response. diff --git a/behat.yml b/behat.yml index 7fae20b..170e250 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\DemoAppContext: ~ 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 # no default value, you must specify diff --git a/composer.json b/composer.json index bf9e4d3..bb8fc0e 100644 --- a/composer.json +++ b/composer.json @@ -43,11 +43,13 @@ "require-dev": { "behat/behat": "~3.0", "squizlabs/php_codesniffer": "3.*", - "phpunit/phpunit": "^7.0 || ^8.0", + "phpunit/phpunit": "^9.0", "matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0", "matthiasnoback/symfony-config-test": "^3.0 || ^4.0", "symfony/framework-bundle": "^4.4 || ^5.4", "symfony/routing": "^4.4 || ^5.4", - "yoanm/php-unit-extended": "~1.0" + "yoanm/php-unit-extended": "~1.0", + "phpspec/prophecy-phpunit": "^2.0", + "dvdoug/behat-code-coverage": "^5.2" } } From cd45a96e02d6869e087a10744629deb5fd731fca Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 21:31:15 +0200 Subject: [PATCH 05/38] Add nightly --- .github/workflows/CI.yml | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index db336b2..3bde3ff 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -28,6 +28,7 @@ jobs: fail-fast: true matrix: php-version: + - '7.2' - '7.4' - '8.0' - '8.1' @@ -88,6 +89,7 @@ jobs: fail-fast: true matrix: php-version: + - '7.2' - '7.4' - '8.0' - '8.1' @@ -139,3 +141,65 @@ jobs: name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" fail_ci_if_error: true + + nightly-tests: + name: Nightly / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} + needs: [ functional-tests ] + runs-on: ubuntu-latest + strategy: + fail-fast: true + exclude: + - php-version: '8.1' # Already done above + symfony-version: '5.4' + matrix: + php-version: + - '8.1' + - '8.2' + symfony-version: + - '5.4' + - '6.2' + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-version }}' + tools: composer + coverage: xdebug + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v2 + with: + path: | + ~/.composer + ./vendor + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: | + composer require \ + symfony/http-foundation:^${{ matrix.symfony-version }} \ + symfony/http-kernel:^${{ matrix.symfony-version }} \ + symfony/config:^${{ matrix.symfony-version }} \ + symfony/dependency-injection:^${{ matrix.symfony-version }} \ + symfony/event-dispatcher:^${{ matrix.symfony-version }} \ + symfony/routing:^${{ matrix.symfony-version }} \ + && make build + + - name: Test + run: make test-functional + + # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk + - name: Upload coverage to codecov + uses: codecov/codecov-action@v2 + with: + name: "nightly-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" + flags: "nightly-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + fail_ci_if_error: false From 1c69a716b9423a42b10e363a8145fb3689a0672b Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 21:34:04 +0200 Subject: [PATCH 06/38] Move composer-require-checker as GHAction --- .github/workflows/CI.yml | 7 +++++++ .scrutinizer.yml | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3bde3ff..8df2bc4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,6 +21,13 @@ env: COMPOSER_OPTIONS: '--optimize-autoloader' jobs: + composer-require-checker: + name: ComposerRequireChecker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: ComposerRequireChecker + uses: docker://webfactory/composer-require-checker:3.2.0 unit-tests: name: Unit / PHP ${{ matrix.php-version }} runs-on: ubuntu-latest diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 4ad7776..ca67eb0 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -24,8 +24,6 @@ build: coverage: file: 'build/coverage/clover.xml' format: 'php-clover' - - command: composer global require maglnet/composer-require-checker && composer-require-checker check composer.json - title: Composer-require-checker - command: php-scrutinizer-run --enable-security-analysis title: Scrutinizer checks From 20a360d5130ec95e890a0d8dfd0ce0430cbc7b23 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 21:35:41 +0200 Subject: [PATCH 07/38] Fix CI config --- .github/workflows/CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8df2bc4..2ecfda3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -155,10 +155,10 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: true - exclude: - - php-version: '8.1' # Already done above - symfony-version: '5.4' matrix: + exclude: + - php-version: '8.1' # Already done above + symfony-version: '5.4' php-version: - '8.1' - '8.2' From f11b204c024e64ac55e203ac5fab79396cbcea35 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sat, 18 Jun 2022 21:36:53 +0200 Subject: [PATCH 08/38] Fix PHPUnit version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bb8fc0e..91b0031 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "require-dev": { "behat/behat": "~3.0", "squizlabs/php_codesniffer": "3.*", - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^8.0 || ^9.0", "matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0", "matthiasnoback/symfony-config-test": "^3.0 || ^4.0", "symfony/framework-bundle": "^4.4 || ^5.4", From f53846bf76109e721f14eb7731dcb0208f575551 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 05:01:26 +0200 Subject: [PATCH 09/38] Fix PHP 7.2 + composer-require-checker --- .github/workflows/CI.yml | 11 +++++++++++ composer.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2ecfda3..31af930 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -26,8 +26,19 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + tools: composer + env: + # Always use latest available patch for the version + update: true + - name: Build + run: make build - name: ComposerRequireChecker uses: docker://webfactory/composer-require-checker:3.2.0 + unit-tests: name: Unit / PHP ${{ matrix.php-version }} runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index 91b0031..1494ef0 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "symfony/framework-bundle": "^4.4 || ^5.4", "symfony/routing": "^4.4 || ^5.4", "yoanm/php-unit-extended": "~1.0", - "phpspec/prophecy-phpunit": "^2.0", - "dvdoug/behat-code-coverage": "^5.2" + "phpspec/prophecy-phpunit": "^1.0 || ^2.0", + "dvdoug/behat-code-coverage": "^5.0" } } From 3221d11e846e31d80afc0aa6f38968c3b2207929 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 05:09:53 +0200 Subject: [PATCH 10/38] Improve --- .github/workflows/CI.yml | 9 +++++++-- composer.json | 11 +++++++---- phpunit.xml.dist | 28 +++++++++------------------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 31af930..92fcead 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ concurrency: env: # Cache params - CACHE_VERSION: 2022061801 # To be able to create a new cache (YYYYMMDDXX) + CACHE_VERSION: 2022061901 # To be able to create a new cache (YYYYMMDDXX) CI: 'true' COVERAGE_OUTPUT_STYLE: clover TEST_OUTPUT_STYLE: 'pretty' @@ -44,6 +44,7 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: true + max-parallel: 4 matrix: php-version: - '7.2' @@ -105,6 +106,7 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: true + max-parallel: 4 matrix: php-version: - '7.2' @@ -164,8 +166,11 @@ jobs: name: Nightly / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} needs: [ functional-tests ] runs-on: ubuntu-latest + env: + COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' # Ignore upper PHP bound requirement strategy: - fail-fast: true + fail-fast: false + max-parallel: 2 matrix: exclude: - php-version: '8.1' # Already done above diff --git a/composer.json b/composer.json index 1494ef0..c03217a 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ }, "require": { "php": "^7.2 || ^8.0", - "yoanm/jsonrpc-server-sdk": "^3.0", - "symfony/http-foundation": "^4.4 || ^5.4", - "symfony/http-kernel": "^4.4 || ^5.4", + "psr/container": "^1.0", "symfony/config": "^4.4 || ^5.4", "symfony/dependency-injection": "^4.4 || ^5.4", "symfony/event-dispatcher": "^4.4 || ^5.4", "symfony/event-dispatcher-contracts": "^1.0 || ^2.0", - "psr/container": "^1.0" + "symfony/http-foundation": "^5.4", + "symfony/http-kernel": "^5.4", + "yoanm/jsonrpc-server-sdk": "^3.0" }, "require-dev": { "behat/behat": "~3.0", @@ -51,5 +51,8 @@ "yoanm/php-unit-extended": "~1.0", "phpspec/prophecy-phpunit": "^1.0 || ^2.0", "dvdoug/behat-code-coverage": "^5.0" + }, + "config": { + "sort-packages": true } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e85eeb9..144a6c8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,45 +1,35 @@ - - + bootstrap="vendor/autoload.php"> + + + src + + - - tests/Functional + tests/Functional/* - tests/Technical + tests/Technical/* - - - - src - - From b4fef957a9307749465420825208b1d4040850b3 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 05:46:02 +0200 Subject: [PATCH 11/38] Improve README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 952c629..32ee5db 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ [![CI](https://github.com/yoanm/symfony-jsonrpc-http-server/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/yoanm/symfony-jsonrpc-http-server/actions/workflows/CI.yml) [![codecov](https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server/branch/master/graph/badge.svg?token=NHdwEBUFK5)](https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server) +[![Symfony Versions](https://img.shields.io/badge/Symfony-v4%20%2F%20v5%20-8892BF.svg?logo=github)](https://symfony.com/) [![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server) From f1f6435bdbf8c9f1dab8a1c00328a4cf0111e02d Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 05:52:19 +0200 Subject: [PATCH 12/38] Fix phpunit conf for v8 --- phpunit.xml.dist | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 144a6c8..e85eeb9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,35 +1,45 @@ + - - - - src - - + + bootstrap="vendor/autoload.php" +> + - tests/Functional/* + tests/Functional - tests/Technical/* + tests/Technical + + + + src + + From bb8691bfc651dc6bab22ab973ae27d21e85db18f Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 06:30:48 +0200 Subject: [PATCH 13/38] Merge unit and functional tests --- .github/workflows/CI.yml | 96 ++++++++++------------------------------ Makefile | 14 +++--- 2 files changed, 32 insertions(+), 78 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 92fcead..ce68b78 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -39,8 +39,8 @@ jobs: - name: ComposerRequireChecker uses: docker://webfactory/composer-require-checker:3.2.0 - unit-tests: - name: Unit / PHP ${{ matrix.php-version }} + tests: + name: Tests / PHP ${{ matrix.php-version }} runs-on: ubuntu-latest strategy: fail-fast: true @@ -90,81 +90,27 @@ jobs: && make build - name: Test - run: make test-unit + run: make test-unit && make test-functional - # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk - - name: Upload coverage to codecov + # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server + - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v2 with: + file: "build/coverage/clover-unit.xml" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" fail_ci_if_error: true - - functional-tests: - name: Functional / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} - needs: [ unit-tests ] - runs-on: ubuntu-latest - strategy: - fail-fast: true - max-parallel: 4 - matrix: - php-version: - - '7.2' - - '7.4' - - '8.0' - - '8.1' - symfony-version: - - '4.4' - - '5.4' - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php-version }}' - tools: composer - coverage: xdebug - env: - # Always use latest available patch for the version - update: true - - - name: Setup cache - id: cache - uses: actions/cache@v2 - with: - path: | - ~/.composer - ./vendor - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} - - - name: Build - run: | - composer require \ - symfony/http-foundation:^${{ matrix.symfony-version }} \ - symfony/http-kernel:^${{ matrix.symfony-version }} \ - symfony/config:^${{ matrix.symfony-version }} \ - symfony/dependency-injection:^${{ matrix.symfony-version }} \ - symfony/event-dispatcher:^${{ matrix.symfony-version }} \ - symfony/routing:^${{ matrix.symfony-version }} \ - && make build - - - name: Test - run: make test-functional - - # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk - - name: Upload coverage to codecov + - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v2 with: + file: "build/coverage/clover-functional.xml,build/behat-coverage/clover.xml" name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" fail_ci_if_error: true nightly-tests: name: Nightly / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} - needs: [ functional-tests ] + needs: [ tests ] runs-on: ubuntu-latest env: COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' # Ignore upper PHP bound requirement @@ -172,15 +118,11 @@ jobs: fail-fast: false max-parallel: 2 matrix: - exclude: - - php-version: '8.1' # Already done above - symfony-version: '5.4' php-version: - - '8.1' - '8.2' symfony-version: + - '4.4' - '5.4' - - '6.2' steps: - name: Check out code uses: actions/checkout@v2 @@ -217,12 +159,20 @@ jobs: && make build - name: Test - run: make test-functional + run: make test-unit && make test-functional - # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk - - name: Upload coverage to codecov + # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server + - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v2 with: - name: "nightly-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "nightly-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + file: "build/coverage/clover-unit.xml" + name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" + flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + fail_ci_if_error: false + - name: Upload unit tests coverage to codecov + uses: codecov/codecov-action@v2 + with: + file: "build/coverage/clover-functional.xml,build/behat-coverage/clover.xml" + name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" + flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" fail_ci_if_error: false diff --git a/Makefile b/Makefile index 72a61ca..bf40c8f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,8 @@ BUILD_DIRECTORY ?= build REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-behat -COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml +PHPUNIT_UNIT_COVERAGE_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover-unit.xml +PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover-functional.xml ## Commands options ### Composer @@ -42,12 +43,15 @@ ifdef COVERAGE_OUTPUT_STYLE export XDEBUG_MODE=coverage ifeq ("${COVERAGE_OUTPUT_STYLE}","html") PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} + PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} BEHAT_COVERAGE_OPTION ?= --profile coverage-html else ifeq ("${COVERAGE_OUTPUT_STYLE}","clover") - PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH} - BEHAT_COVERAGE_OPTION ?= --profile coverage-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 @@ -84,11 +88,11 @@ test-unit: ifdef BEHAT_COVERAGE_OPTION test-functional: create-build-directories -else ifdef PHPUNIT_COVERAGE_OPTION +else ifdef PHPUNIT_FUNCTIONAL_COVERAGE_OPTION test-functional: create-build-directories endif test-functional: - ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} --testsuite functional + ./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-build-directories From 9478f39341fefb859022187af031c92707ec8e96 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 06:35:57 +0200 Subject: [PATCH 14/38] Fix --- .github/workflows/CI.yml | 30 ++++++++++++++++++------------ Makefile | 14 +++++++------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ce68b78..77b8c47 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,7 +40,7 @@ jobs: uses: docker://webfactory/composer-require-checker:3.2.0 tests: - name: Tests / PHP ${{ matrix.php-version }} + name: Tests / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} runs-on: ubuntu-latest strategy: fail-fast: true @@ -89,23 +89,23 @@ jobs: symfony/routing:^${{ matrix.symfony-version }} \ && make build - - name: Test + - name: Tests run: make test-unit && make test-functional # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v2 with: - file: "build/coverage/clover-unit.xml" + file: "build/coverage-phpunit/clover-unit.xml" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" fail_ci_if_error: true - - name: Upload unit tests coverage to codecov + move_coverage_to_trash: true + - name: Upload functional tests coverage to codecov uses: codecov/codecov-action@v2 with: - file: "build/coverage/clover-functional.xml,build/behat-coverage/clover.xml" name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" fail_ci_if_error: true nightly-tests: @@ -138,6 +138,7 @@ jobs: update: true - name: Setup cache + continue-on-error: true id: cache uses: actions/cache@v2 with: @@ -148,6 +149,7 @@ jobs: key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} - name: Build + continue-on-error: true run: | composer require \ symfony/http-foundation:^${{ matrix.symfony-version }} \ @@ -159,20 +161,24 @@ jobs: && make build - name: Test + continue-on-error: true run: make test-unit && make test-functional # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v2 + continue-on-error: true with: - file: "build/coverage/clover-unit.xml" + file: "build/coverage-phpunit/clover-unit.xml" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" fail_ci_if_error: false - - name: Upload unit tests coverage to codecov + move_coverage_to_trash: true + - name: Upload functional tests coverage to codecov + continue-on-error: true uses: codecov/codecov-action@v2 with: - file: "build/coverage/clover-functional.xml,build/behat-coverage/clover.xml" + file: "build/coverage-phpunit/clover-functional.xml,build/coverage-behat/clover.xml" name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}" + flags: "nightly,functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" fail_ci_if_error: false diff --git a/Makefile b/Makefile index bf40c8f..30f54e6 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,11 @@ TEST_OUTPUT_STYLE ?= dot ## DIRECTORY AND FILE BUILD_DIRECTORY ?= build -REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports -COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage +REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports # Codestyle BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-behat -PHPUNIT_UNIT_COVERAGE_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover-unit.xml -PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover-functional.xml +PHPUNIT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-phpunit +PHPUNIT_UNIT_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/clover-unit.xml +PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/clover-functional.xml ## Commands options ### Composer @@ -42,8 +42,8 @@ endif ifdef COVERAGE_OUTPUT_STYLE export XDEBUG_MODE=coverage ifeq ("${COVERAGE_OUTPUT_STYLE}","html") - PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} - PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} + 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} @@ -107,7 +107,7 @@ scrutinizer-behat: # Internal commands create-build-directories: - mkdir -p ${COVERAGE_DIRECTORY} ${BEHAT_COVERAGE_DIRECTORY} ${REPORTS_DIRECTORY} ${REPORTS_DIRECTORY} + mkdir -p ${PHPUNIT_COVERAGE_DIRECTORY} ${BEHAT_COVERAGE_DIRECTORY} ${REPORTS_DIRECTORY} .PHONY: build install configure test test-unit test-functional codestyle create-build-directories scrutinizer-behat scrutinizer-phpunit .DEFAULT: build From 6329c36252199226d03b40dabd78d81235f87f78 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 07:50:58 +0200 Subject: [PATCH 15/38] Fix scrutinizer and codecov tags --- .github/workflows/CI.yml | 26 ++++++++++---------------- .scrutinizer.yml | 9 ++++++++- Makefile | 4 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 77b8c47..9bb5f23 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -94,18 +94,18 @@ jobs: # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - name: Upload unit tests coverage to codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: file: "build/coverage-phpunit/clover-unit.xml" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" + flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true move_coverage_to_trash: true - name: Upload functional tests coverage to codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" + flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true nightly-tests: @@ -113,7 +113,7 @@ jobs: needs: [ tests ] runs-on: ubuntu-latest env: - COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' # Ignore upper PHP bound requirement + COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' strategy: fail-fast: false max-parallel: 2 @@ -138,7 +138,6 @@ jobs: update: true - name: Setup cache - continue-on-error: true id: cache uses: actions/cache@v2 with: @@ -149,9 +148,8 @@ jobs: key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} - name: Build - continue-on-error: true run: | - composer require \ + composer require ${COMPOSER_OPTIONS} \ symfony/http-foundation:^${{ matrix.symfony-version }} \ symfony/http-kernel:^${{ matrix.symfony-version }} \ symfony/config:^${{ matrix.symfony-version }} \ @@ -161,24 +159,20 @@ jobs: && make build - name: Test - continue-on-error: true run: make test-unit && make test-functional # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - name: Upload unit tests coverage to codecov - uses: codecov/codecov-action@v2 - continue-on-error: true + uses: codecov/codecov-action@v3 with: file: "build/coverage-phpunit/clover-unit.xml" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" + flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: false move_coverage_to_trash: true - name: Upload functional tests coverage to codecov - continue-on-error: true - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: - file: "build/coverage-phpunit/clover-functional.xml,build/coverage-behat/clover.xml" name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "nightly,functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}+" + flags: "nightly,functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: false diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ca67eb0..6e1a81c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -22,7 +22,12 @@ build: - command: make scrutinizer-phpunit idle_timeout: 1200 coverage: - file: 'build/coverage/clover.xml' + 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 @@ -41,6 +46,8 @@ build: COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml' php: version: "8.1" + ini: + memory_limit: "-1" timezone: UTC postgresql: false redis: false diff --git a/Makefile b/Makefile index 30f54e6..f171b36 100644 --- a/Makefile +++ b/Makefile @@ -99,10 +99,10 @@ 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} scrutinizer-phpunit: - ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} + XDEBUG_MODE=coverage ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --coverage-clover build/coverage-phpunit/scrutinizer.xml scrutinizer-behat: - ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} ${BEHAT_COVERAGE_OPTION} --no-snippets + XDEBUG_MODE=coverage ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --profile coverage-clover --no-snippets # Internal commands From bbdc0382367d7ad157a10b7f79c1ded3aa5efddb Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 08:25:59 +0200 Subject: [PATCH 16/38] Fix PHPUnit tests --- src/Event/SymfonyJsonRpcServerEvent.php | 1 + src/Resolver/MethodResolver.php | 1 + tests/Functional/DependencyInjection/ConfigFilesTest.php | 1 + .../Dispatcher/SymfonyJsonRpcServerDispatcherTest.php | 3 +++ tests/Functional/Endpoint/JsonRpcHttpEndpointTest.php | 3 +++ tests/Functional/Event/SymfonyJsonRpcServerEventTest.php | 3 +++ tests/Functional/Resolver/MethodResolverTest.php | 3 +++ 7 files changed, 15 insertions(+) diff --git a/src/Event/SymfonyJsonRpcServerEvent.php b/src/Event/SymfonyJsonRpcServerEvent.php index 3baa842..5f09690 100644 --- a/src/Event/SymfonyJsonRpcServerEvent.php +++ b/src/Event/SymfonyJsonRpcServerEvent.php @@ -1,6 +1,7 @@ So no [at]covers tag ! + * @coversNothing */ class ConfigFilesTest extends AbstractTestClass { diff --git a/tests/Functional/Dispatcher/SymfonyJsonRpcServerDispatcherTest.php b/tests/Functional/Dispatcher/SymfonyJsonRpcServerDispatcherTest.php index 0bb3a93..08b05b0 100644 --- a/tests/Functional/Dispatcher/SymfonyJsonRpcServerDispatcherTest.php +++ b/tests/Functional/Dispatcher/SymfonyJsonRpcServerDispatcherTest.php @@ -3,6 +3,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Yoanm\JsonRpcServer\Domain\Event\JsonRpcServerEvent; @@ -14,6 +15,8 @@ */ class SymfonyJsonRpcServerDispatcherTest extends TestCase { + use ProphecyTrait; + /** @var SymfonyJsonRpcServerDispatcher */ private $dispatcher; diff --git a/tests/Functional/Endpoint/JsonRpcHttpEndpointTest.php b/tests/Functional/Endpoint/JsonRpcHttpEndpointTest.php index 6ccddf6..3f76751 100644 --- a/tests/Functional/Endpoint/JsonRpcHttpEndpointTest.php +++ b/tests/Functional/Endpoint/JsonRpcHttpEndpointTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\Endpoint; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -13,6 +14,8 @@ */ class JsonRpcHttpEndpointTest extends TestCase { + use ProphecyTrait; + /** @var JsonRpcHttpEndpoint */ private $endpoint; diff --git a/tests/Functional/Event/SymfonyJsonRpcServerEventTest.php b/tests/Functional/Event/SymfonyJsonRpcServerEventTest.php index c858936..70b0131 100644 --- a/tests/Functional/Event/SymfonyJsonRpcServerEventTest.php +++ b/tests/Functional/Event/SymfonyJsonRpcServerEventTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\Event; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Yoanm\JsonRpcServer\Domain\Event\JsonRpcServerEvent; use Yoanm\SymfonyJsonRpcHttpServer\Event\SymfonyJsonRpcServerEvent; @@ -11,6 +12,8 @@ */ class SymfonyJsonRpcServerEventTest extends TestCase { + use ProphecyTrait; + /** @var JsonRpcServerEvent|ObjectProphecy */ private $jsonRpcServerEvent; /** @var SymfonyJsonRpcServerEvent */ diff --git a/tests/Functional/Resolver/MethodResolverTest.php b/tests/Functional/Resolver/MethodResolverTest.php index 4f16ffb..9e06b9e 100644 --- a/tests/Functional/Resolver/MethodResolverTest.php +++ b/tests/Functional/Resolver/MethodResolverTest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\Endpoint; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Psr\Container\ContainerInterface; use Yoanm\JsonRpcServer\Domain\JsonRpcMethodInterface; @@ -12,6 +13,8 @@ */ class MethodResolverTest extends TestCase { + use ProphecyTrait; + /** @var MethodResolver */ private $resolver; From bd4e06d33074334de59149b9faa5a07d47ff64ef Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 08:55:31 +0200 Subject: [PATCH 17/38] Drop PHP 7.2 Can't mix unit tests with phpspec/prophecy-phpunit v1 and v2 --- .github/workflows/CI.yml | 2 +- composer.json | 4 ++-- src/Event/SymfonyJsonRpcServerEvent.php | 1 - src/Resolver/MethodResolver.php | 1 - .../Dispatcher/SymfonyJsonRpcServerDispatcherTest.php | 2 +- tests/Functional/Resolver/MethodResolverTest.php | 2 +- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9bb5f23..094934c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -47,7 +47,7 @@ jobs: max-parallel: 4 matrix: php-version: - - '7.2' + - '7.3' - '7.4' - '8.0' - '8.1' diff --git a/composer.json b/composer.json index c03217a..7f78de8 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "yoanm/symfony-jsonrpc-http-server-doc": "JSON-RPC documentation Bundle" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "psr/container": "^1.0", "symfony/config": "^4.4 || ^5.4", "symfony/dependency-injection": "^4.4 || ^5.4", @@ -49,7 +49,7 @@ "symfony/framework-bundle": "^4.4 || ^5.4", "symfony/routing": "^4.4 || ^5.4", "yoanm/php-unit-extended": "~1.0", - "phpspec/prophecy-phpunit": "^1.0 || ^2.0", + "phpspec/prophecy-phpunit": "^2.0", "dvdoug/behat-code-coverage": "^5.0" }, "config": { diff --git a/src/Event/SymfonyJsonRpcServerEvent.php b/src/Event/SymfonyJsonRpcServerEvent.php index 5f09690..3baa842 100644 --- a/src/Event/SymfonyJsonRpcServerEvent.php +++ b/src/Event/SymfonyJsonRpcServerEvent.php @@ -1,7 +1,6 @@ Date: Sun, 19 Jun 2022 08:57:52 +0200 Subject: [PATCH 18/38] Fix composer requirements --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7f78de8..e9852d3 100644 --- a/composer.json +++ b/composer.json @@ -36,8 +36,8 @@ "symfony/dependency-injection": "^4.4 || ^5.4", "symfony/event-dispatcher": "^4.4 || ^5.4", "symfony/event-dispatcher-contracts": "^1.0 || ^2.0", - "symfony/http-foundation": "^5.4", - "symfony/http-kernel": "^5.4", + "symfony/http-foundation": "^4.4 || ^5.4", + "symfony/http-kernel": "^4.4 || ^5.4", "yoanm/jsonrpc-server-sdk": "^3.0" }, "require-dev": { From d30f18f07c1ce8c912355ffa2b736ce23c67b9e5 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 09:05:54 +0200 Subject: [PATCH 19/38] Auto-detected clover file naming --- .github/workflows/CI.yml | 4 ++-- Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 094934c..cdf3848 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -96,7 +96,7 @@ jobs: - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v3 with: - file: "build/coverage-phpunit/clover-unit.xml" + file: "build/coverage-phpunit/unit.clover" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true @@ -165,7 +165,7 @@ jobs: - name: Upload unit tests coverage to codecov uses: codecov/codecov-action@v3 with: - file: "build/coverage-phpunit/clover-unit.xml" + file: "build/coverage-phpunit/unit.clover" name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: false diff --git a/Makefile b/Makefile index f171b36..fdbc8a1 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ BUILD_DIRECTORY ?= build 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}/clover-unit.xml -PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/clover-functional.xml +PHPUNIT_UNIT_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/unit.clover +PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${PHPUNIT_COVERAGE_DIRECTORY}/functional.clover ## Commands options ### Composer From 1378a9e9f969c63a077384c23e57e51c7962ff3f Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 09:23:23 +0200 Subject: [PATCH 20/38] Try specifing coverages files --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cdf3848..13ed43f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -100,10 +100,10 @@ jobs: name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true - move_coverage_to_trash: true - name: Upload functional tests coverage to codecov uses: codecov/codecov-action@v3 with: + files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover" name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true @@ -169,10 +169,10 @@ jobs: name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: false - move_coverage_to_trash: true - name: Upload functional tests coverage to codecov uses: codecov/codecov-action@v3 with: + files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover" name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "nightly,functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: false From 16cddf3dc9c2f2add183b5321d0879ec02c47ada Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 09:49:48 +0200 Subject: [PATCH 21/38] Add codecov config --- codecov.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..67430e5 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,16 @@ +codecov: + bot: "codecov-io" + notify: + after_n_builds: 4 + +coverage: + precision: 2 + round: down + range: "80...100" + +flags: + nightly: + joined: false + +github_checks: + annotations: true From cf39b6dda8fbcb71c2a801f5b878d2873d178741 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 09:50:02 +0200 Subject: [PATCH 22/38] Remove useless --- behat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/behat.yml b/behat.yml index 170e250..4244bfa 100644 --- a/behat.yml +++ b/behat.yml @@ -27,4 +27,4 @@ coverage-clover: DVDoug\Behat\CodeCoverage\Extension: reports: clover: - target: build/coverage-behat/clover.xml # no default value, you must specify + target: build/coverage-behat/clover.xml From b9af974ba9cee038c28886332c4290ef598f4814 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 10:02:18 +0200 Subject: [PATCH 23/38] Improve / Remove useless --- .github/workflows/CI.yml | 5 ++++- codecov.yml | 7 ------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 13ed43f..edaf15f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,11 +1,14 @@ name: 'CI' -on: # rebuild any PRs and main branch changes +on: # Build any PRs and main branch changes pull_request: types: - opened + - edited - synchronize push: branches: [ master ] + schedule: + - "0 0 1 * *" # Every month concurrency: group: "CI-${{ github.head_ref }}" diff --git a/codecov.yml b/codecov.yml index 67430e5..45030d6 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,11 +1,4 @@ -codecov: - bot: "codecov-io" - notify: - after_n_builds: 4 - coverage: - precision: 2 - round: down range: "80...100" flags: From 847cdf389508778a0781cfa09e88329601af3159 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 11:30:28 +0200 Subject: [PATCH 24/38] Add codacy --- .github/workflows/CI.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index edaf15f..5ed1fc2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,6 +22,9 @@ env: TEST_OUTPUT_STYLE: 'pretty' PHPCS_REPORT_STYLE: 'full' COMPOSER_OPTIONS: '--optimize-autoloader' + CODACY_TMP_DIR: '~/.codacy' + CODACY_BIN: '$CODACY_TMP_DIR/codacy.sh' + CODACY_REPORTER_TMP_FOLDER: '$CODACY_TMP_DIR' jobs: composer-require-checker: @@ -78,6 +81,7 @@ jobs: path: | ~/.composer ./vendor + $CODACY_TMP_DIR # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} @@ -111,6 +115,39 @@ jobs: flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true + - name: Download codacy installer + if: steps.cache.outputs.cache-hit != 'true' + run: mkdir -p $CODACY_TMP_DIR && curl -Ls https://coverage.codacy.com/get.sh -o $CODACY_BIN + + - name: Upload coverages to Codacy + run: | + bash <$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 + + finalize-codacy-coverage-report: + runs-on: ubuntu-latest + name: Finalize Codacy coverage report + needs: [ tests ] + steps: + - name: Setup cache + id: cache + uses: actions/cache@v2 + with: + path: | + $CODACY_TMP_DIR + key: ${{ env.CACHE_VERSION }}-codacy + + - name: Download codacy installer + if: steps.cache.outputs.cache-hit != 'true' + run: mkdir -p $CODACY_TMP_DIR && curl -Ls https://coverage.codacy.com/get.sh -o $CODACY_BIN + + - name: Finalize reporting + run: bash < $CODACY_BIN final -t ${{ secrets.CODACY_PROJECT_TOKEN }} + nightly-tests: name: Nightly / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} needs: [ tests ] @@ -147,6 +184,7 @@ jobs: path: | ~/.composer ./vendor + $CODACY_TMP_DIR # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} From 4858aecd0240d25be5753659d711a856064725e4 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 11:37:53 +0200 Subject: [PATCH 25/38] Add Dependency Review action --- .github/workflows/CI.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5ed1fc2..7036ac3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -42,8 +42,10 @@ jobs: update: true - name: Build run: make build - - name: ComposerRequireChecker + - name: Composer Require Checker uses: docker://webfactory/composer-require-checker:3.2.0 + - name: Dependency Review + uses: actions/dependency-review-action@v1 tests: name: Tests / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} From 00c81cd3c4cd5b083d0d66c0d7903e071398443c Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 11:42:28 +0200 Subject: [PATCH 26/38] Fix config --- .github/workflows/CI.yml | 72 +++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7036ac3..61cc7e6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -8,7 +8,7 @@ on: # Build any PRs and main branch changes push: branches: [ master ] schedule: - - "0 0 1 * *" # Every month + - cron: '0 0 1 * *' # Every month concurrency: group: "CI-${{ github.head_ref }}" @@ -17,21 +17,18 @@ concurrency: env: # Cache params CACHE_VERSION: 2022061901 # To be able to create a new cache (YYYYMMDDXX) - CI: 'true' COVERAGE_OUTPUT_STYLE: clover - TEST_OUTPUT_STYLE: 'pretty' - PHPCS_REPORT_STYLE: 'full' - COMPOSER_OPTIONS: '--optimize-autoloader' - CODACY_TMP_DIR: '~/.codacy' - CODACY_BIN: '$CODACY_TMP_DIR/codacy.sh' - CODACY_REPORTER_TMP_FOLDER: '$CODACY_TMP_DIR' + TEST_OUTPUT_STYLE: pretty + COMPOSER_OPTIONS: --optimize-autoloader + CODACY_REPORTER_TMP_FOLDER: ~/.codacy jobs: - composer-require-checker: - name: ComposerRequireChecker + static-tests: + name: Static tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -40,15 +37,28 @@ jobs: env: # Always use latest available patch for the version update: true + + - name: Setup cache + id: cache + uses: actions/cache@v2 + with: + path: | + ~/.composer + ./vendor + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} + - name: Build run: make build - - name: Composer Require Checker + + - name: ComposerRequireChecker uses: docker://webfactory/composer-require-checker:3.2.0 + - name: Dependency Review uses: actions/dependency-review-action@v1 tests: - name: Tests / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} + name: UTs & FTs - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} runs-on: ubuntu-latest strategy: fail-fast: true @@ -83,7 +93,7 @@ jobs: path: | ~/.composer ./vendor - $CODACY_TMP_DIR + ${{ env.CODACY_REPORTER_TMP_FOLDER }} # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} @@ -117,18 +127,16 @@ jobs: flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true - - name: Download codacy installer + - name: Download codacy binary if: steps.cache.outputs.cache-hit != 'true' - run: mkdir -p $CODACY_TMP_DIR && curl -Ls https://coverage.codacy.com/get.sh -o $CODACY_BIN - - - name: Upload coverages to Codacy run: | - bash <$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 + mkdir -p ${{ env.CODACY_REPORTER_TMP_FOLDER }} \ + && curl -Ls https://coverage.codacy.com/get.sh -o ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ + && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ + && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download + +# - name: Upload coverages to Codacy +# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh 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 finalize-codacy-coverage-report: runs-on: ubuntu-latest @@ -140,18 +148,22 @@ jobs: uses: actions/cache@v2 with: path: | - $CODACY_TMP_DIR + ${{ env.CODACY_REPORTER_TMP_FOLDER }} key: ${{ env.CACHE_VERSION }}-codacy - - name: Download codacy installer + - name: Download codacy binary if: steps.cache.outputs.cache-hit != 'true' - run: mkdir -p $CODACY_TMP_DIR && curl -Ls https://coverage.codacy.com/get.sh -o $CODACY_BIN + run: | + mkdir -p ${{ env.CODACY_REPORTER_TMP_FOLDER }} \ + && curl -Ls https://coverage.codacy.com/get.sh -o ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ + && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ + && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download - - name: Finalize reporting - run: bash < $CODACY_BIN final -t ${{ secrets.CODACY_PROJECT_TOKEN }} +# - name: Finalize reporting +# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh final -t ${{ secrets.CODACY_PROJECT_TOKEN }} nightly-tests: - name: Nightly / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} + name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} needs: [ tests ] runs-on: ubuntu-latest env: @@ -186,7 +198,7 @@ jobs: path: | ~/.composer ./vendor - $CODACY_TMP_DIR + ${{ env.CODACY_REPORTER_TMP_FOLDER }} # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} From c606877dfa4473d8144d4cf71e2474f0c127b4c6 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 13:07:46 +0200 Subject: [PATCH 27/38] Send report to codacy --- .github/workflows/CI.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 61cc7e6..ebd4372 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -135,8 +135,11 @@ jobs: && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download -# - name: Upload coverages to Codacy -# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh 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 + - name: DEBUG + run: ls -ail ${{ env.CODACY_REPORTER_TMP_FOLDER }} ${{ env.CODACY_REPORTER_TMP_FOLDER }}/* + + - name: Upload coverages to Codacy + run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh 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 finalize-codacy-coverage-report: runs-on: ubuntu-latest @@ -159,8 +162,8 @@ jobs: && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download -# - name: Finalize reporting -# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh final -t ${{ secrets.CODACY_PROJECT_TOKEN }} + - name: Finalize reporting + run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh final -t ${{ secrets.CODACY_PROJECT_TOKEN }} nightly-tests: name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} From c81fe5ea83d3d7dcd2f85c578d62def482782334 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 13:14:12 +0200 Subject: [PATCH 28/38] Add behat coverage cache --- .github/workflows/CI.yml | 11 +++++++---- behat.yml | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ebd4372..ca31d90 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -94,6 +94,7 @@ jobs: ~/.composer ./vendor ${{ env.CODACY_REPORTER_TMP_FOLDER }} + build/behat-code-coverage-cache # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} @@ -138,8 +139,8 @@ jobs: - name: DEBUG run: ls -ail ${{ env.CODACY_REPORTER_TMP_FOLDER }} ${{ env.CODACY_REPORTER_TMP_FOLDER }}/* - - name: Upload coverages to Codacy - run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh 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 +# - name: Upload coverages to Codacy +# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh 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 finalize-codacy-coverage-report: runs-on: ubuntu-latest @@ -162,8 +163,8 @@ jobs: && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download - - name: Finalize reporting - run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh final -t ${{ secrets.CODACY_PROJECT_TOKEN }} +# - name: Finalize reporting +# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh final -t ${{ secrets.CODACY_PROJECT_TOKEN }} nightly-tests: name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} @@ -202,6 +203,7 @@ jobs: ~/.composer ./vendor ${{ env.CODACY_REPORTER_TMP_FOLDER }} + build/behat-code-coverage-cache # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} @@ -227,6 +229,7 @@ jobs: name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: false + - name: Upload functional tests coverage to codecov uses: codecov/codecov-action@v3 with: diff --git a/behat.yml b/behat.yml index 4244bfa..25d85f1 100644 --- a/behat.yml +++ b/behat.yml @@ -1,6 +1,7 @@ default: extensions: DVDoug\Behat\CodeCoverage\Extension: + cache: build/behat-code-coverage-cache filter: include: directories: From 531b6362cd73be4f84c710007d4cfa7d89bcee50 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 13:25:54 +0200 Subject: [PATCH 29/38] Fix codacy install --- .github/workflows/CI.yml | 49 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ca31d90..94c7184 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,11 +16,12 @@ concurrency: env: # Cache params - CACHE_VERSION: 2022061901 # To be able to create a new cache (YYYYMMDDXX) + CACHE_VERSION: 2022061902 # To be able to create a new cache (YYYYMMDDXX) COVERAGE_OUTPUT_STYLE: clover TEST_OUTPUT_STYLE: pretty COMPOSER_OPTIONS: --optimize-autoloader - CODACY_REPORTER_TMP_FOLDER: ~/.codacy + CODACY_CACHE_PATH: $HOME/.cache/codacy + CODACY_BIN: $HOME/.cache/codacy/codacy.sh jobs: static-tests: @@ -93,11 +94,22 @@ jobs: path: | ~/.composer ./vendor - ${{ env.CODACY_REPORTER_TMP_FOLDER }} + $CODACY_CACHE_PATH build/behat-code-coverage-cache # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} + - name: Download codacy binary + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p $CODACY_CACHE_PATH \ + && echo $CODACY_BIN \ + && touch $( echo $CODACY_BIN ) \ + && (ls -ail $CODACY_CACHE_PATH $CODACY_BIN || true) \ + && curl -LN https://coverage.codacy.com/get.sh -o $( echo $CODACY_BIN ) \ + && chmod +x $CODACY_BIN \ + && $CODACY_BIN download + - name: Build run: | composer require \ @@ -128,19 +140,8 @@ jobs: flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true - - name: Download codacy binary - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir -p ${{ env.CODACY_REPORTER_TMP_FOLDER }} \ - && curl -Ls https://coverage.codacy.com/get.sh -o ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ - && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ - && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download - - - name: DEBUG - run: ls -ail ${{ env.CODACY_REPORTER_TMP_FOLDER }} ${{ env.CODACY_REPORTER_TMP_FOLDER }}/* - -# - name: Upload coverages to Codacy -# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh 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 + - name: Upload coverages to Codacy + run: $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 finalize-codacy-coverage-report: runs-on: ubuntu-latest @@ -152,19 +153,19 @@ jobs: uses: actions/cache@v2 with: path: | - ${{ env.CODACY_REPORTER_TMP_FOLDER }} + $CODACY_CACHE_PATH key: ${{ env.CACHE_VERSION }}-codacy - name: Download codacy binary if: steps.cache.outputs.cache-hit != 'true' run: | - mkdir -p ${{ env.CODACY_REPORTER_TMP_FOLDER }} \ - && curl -Ls https://coverage.codacy.com/get.sh -o ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ - && chmod +x ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh \ - && ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh download + mkdir -p $CODACY_CACHE_PATH \ + && curl -LN https://coverage.codacy.com/get.sh -o $( echo $CODACY_BIN ) \ + && chmod +x $CODACY_BIN \ + && $CODACY_BIN download -# - name: Finalize reporting -# run: ${{ env.CODACY_REPORTER_TMP_FOLDER }}/codacy.sh final -t ${{ secrets.CODACY_PROJECT_TOKEN }} + - name: Finalize reporting + run: $CODACY_BIN final -t ${{ secrets.CODACY_PROJECT_TOKEN }} nightly-tests: name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} @@ -202,7 +203,7 @@ jobs: path: | ~/.composer ./vendor - ${{ env.CODACY_REPORTER_TMP_FOLDER }} + $CODACY_CACHE_PATH build/behat-code-coverage-cache # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} From f89d68af9fe87cdfd65a5845d85ae89508731f1d Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 15:17:13 +0200 Subject: [PATCH 30/38] Clean --- .github/workflows/CI.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 94c7184..66844fb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,7 +16,7 @@ concurrency: env: # Cache params - CACHE_VERSION: 2022061902 # To be able to create a new cache (YYYYMMDDXX) + CACHE_VERSION: 2022061903 # To be able to create a new cache (YYYYMMDDXX) COVERAGE_OUTPUT_STYLE: clover TEST_OUTPUT_STYLE: pretty COMPOSER_OPTIONS: --optimize-autoloader @@ -103,10 +103,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: | mkdir -p $CODACY_CACHE_PATH \ - && echo $CODACY_BIN \ - && touch $( echo $CODACY_BIN ) \ - && (ls -ail $CODACY_CACHE_PATH $CODACY_BIN || true) \ - && curl -LN https://coverage.codacy.com/get.sh -o $( echo $CODACY_BIN ) \ + && curl -LN https://coverage.codacy.com/get.sh -o $CODACY_BIN \ && chmod +x $CODACY_BIN \ && $CODACY_BIN download @@ -160,7 +157,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: | mkdir -p $CODACY_CACHE_PATH \ - && curl -LN https://coverage.codacy.com/get.sh -o $( echo $CODACY_BIN ) \ + && curl -LN https://coverage.codacy.com/get.sh -o $CODACY_BIN \ && chmod +x $CODACY_BIN \ && $CODACY_BIN download From c1db91f5d53635bdfd42b486a9331dff5cd0d0d7 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 15:36:24 +0200 Subject: [PATCH 31/38] Trigger CI with cache From 17790487f25a52488f0489b3c837df66176c478f Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 15:41:03 +0200 Subject: [PATCH 32/38] Try to fix cache --- .github/workflows/CI.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 66844fb..576a373 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,12 +16,12 @@ concurrency: env: # Cache params - CACHE_VERSION: 2022061903 # To be able to create a new cache (YYYYMMDDXX) + CACHE_VERSION: 2022061905 # To be able to create a new cache (YYYYMMDDXX) COVERAGE_OUTPUT_STYLE: clover TEST_OUTPUT_STYLE: pretty COMPOSER_OPTIONS: --optimize-autoloader - CODACY_CACHE_PATH: $HOME/.cache/codacy - CODACY_BIN: $HOME/.cache/codacy/codacy.sh + CODACY_CACHE_PATH: ~/.cache/codacy + CODACY_BIN: ~/.cache/codacy/codacy.sh jobs: static-tests: @@ -94,7 +94,7 @@ jobs: path: | ~/.composer ./vendor - $CODACY_CACHE_PATH + ${{ env.CODACY_CACHE_PATH }} build/behat-code-coverage-cache # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} @@ -102,10 +102,10 @@ jobs: - name: Download codacy binary if: steps.cache.outputs.cache-hit != 'true' run: | - mkdir -p $CODACY_CACHE_PATH \ - && curl -LN https://coverage.codacy.com/get.sh -o $CODACY_BIN \ - && chmod +x $CODACY_BIN \ - && $CODACY_BIN download + 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: | @@ -138,7 +138,7 @@ jobs: fail_ci_if_error: true - name: Upload coverages to Codacy - run: $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 + 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 finalize-codacy-coverage-report: runs-on: ubuntu-latest @@ -150,19 +150,19 @@ jobs: uses: actions/cache@v2 with: path: | - $CODACY_CACHE_PATH - key: ${{ env.CACHE_VERSION }}-codacy + ${{ env.CODACY_CACHE_PATH }} + key: ${{ env.CACHE_VERSION }}-codacy-final - name: Download codacy binary if: steps.cache.outputs.cache-hit != 'true' run: | - mkdir -p $CODACY_CACHE_PATH \ - && curl -LN https://coverage.codacy.com/get.sh -o $CODACY_BIN \ - && chmod +x $CODACY_BIN \ - && $CODACY_BIN download + 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: $CODACY_BIN final -t ${{ secrets.CODACY_PROJECT_TOKEN }} + run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} nightly-tests: name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} @@ -200,7 +200,7 @@ jobs: path: | ~/.composer ./vendor - $CODACY_CACHE_PATH + ${{ env.CODACY_CACHE_PATH }} build/behat-code-coverage-cache # Clear the cache if composer json (as composer.lock is in the repo) has been updated key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} From facaa0ef75703cc2f1b7c92c88faced42d701876 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 16:16:08 +0200 Subject: [PATCH 33/38] trigger CI with cache From 04f692301036c3c115a161bcae004dc1f218b900 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 16:43:42 +0200 Subject: [PATCH 34/38] Improve --- .github/workflows/CI.yml | 82 +++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 576a373..572eea7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -66,13 +66,11 @@ jobs: max-parallel: 4 matrix: php-version: - - '7.3' - - '7.4' - - '8.0' - - '8.1' + - '7.3' # Lowest supported + - '8.1' # Latest supported symfony-version: - - '4.4' - - '5.4' + - '4.4' # Lowest LTS + - '5.4' # Latest LTS steps: - name: Check out code uses: actions/checkout@v2 @@ -164,6 +162,68 @@ jobs: - name: Finalize reporting run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} + # Test against others impactful php versions (without coverage) + tests-extra-versions: + name: UTs & FTs - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} + runs-on: ubuntu-latest + needs: [ tests ] + strategy: + fail-fast: true + max-parallel: 4 + matrix: + include: + - php-version: '7.4' # Latest php 7 version + symfony-version: '4.4' + - php-version: '8.0' # First php 8 version + symfony-version: '5.4' + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-version }}' + tools: composer + env: + # Always use latest available patch for the version + update: true + + - name: Setup cache + id: cache + uses: actions/cache@v2 + with: + path: | + ~/.composer + ./vendor + ${{ env.CODACY_CACHE_PATH }} + build/behat-code-coverage-cache + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ 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 require \ + symfony/http-foundation:^${{ matrix.symfony-version }} \ + symfony/http-kernel:^${{ matrix.symfony-version }} \ + symfony/config:^${{ matrix.symfony-version }} \ + symfony/dependency-injection:^${{ matrix.symfony-version }} \ + symfony/event-dispatcher:^${{ matrix.symfony-version }} \ + symfony/routing:^${{ matrix.symfony-version }} \ + && make build + + - name: Tests + run: make test-unit && make test-functional + + # Perform tests against current php dev version and next Symfony minor version to manage nightly-tests: name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} needs: [ tests ] @@ -175,10 +235,14 @@ jobs: max-parallel: 2 matrix: php-version: - - '8.2' + - '8.2' # Current php dev version symfony-version: - - '4.4' - - '5.4' + - '4.4' # Lowest LTS + - '5.4' # Latest LTS + include: + - symfony-version: '6.0' # Next symfony minor version to manage with latest supported PHP version + php-version: '8.1' + steps: - name: Check out code uses: actions/checkout@v2 From 8c09980e9d7a162791055daa2131b9734e6bd8e5 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 16:53:10 +0200 Subject: [PATCH 35/38] Improve --- .github/workflows/CI.yml | 116 ++++++++++----------------------------- 1 file changed, 29 insertions(+), 87 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 572eea7..d9eb70e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,7 +17,6 @@ concurrency: env: # Cache params CACHE_VERSION: 2022061905 # To be able to create a new cache (YYYYMMDDXX) - COVERAGE_OUTPUT_STYLE: clover TEST_OUTPUT_STYLE: pretty COMPOSER_OPTIONS: --optimize-autoloader CODACY_CACHE_PATH: ~/.cache/codacy @@ -35,6 +34,7 @@ jobs: with: php-version: '8.1' tools: composer + coverage: none env: # Always use latest available patch for the version update: true @@ -59,28 +59,44 @@ jobs: uses: actions/dependency-review-action@v1 tests: - name: UTs & FTs - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} + name: UTs & FTs - Symfony ${{ matrix.symfony-version }} runs-on: ubuntu-latest + env: + COVERAGE_TYPE: none strategy: fail-fast: true max-parallel: 4 matrix: php-version: - '7.3' # Lowest supported + - '7.4' # Latest php 7 version + - '8.0' # First php 8 version - '8.1' # Latest supported symfony-version: - '4.4' # Lowest LTS - '5.4' # Latest LTS + exclude: + # Run all symfony version only on Lowest and Latest php versions, run it only one time for others + - php-version: '8.0' + symfony-version: '4.4' + - php-version: '7.4' + symfony-version: '5.4' steps: - name: Check out code uses: actions/checkout@v2 + - name: Enable coverage + if: ${{ matrix.php-version == '8.1' }} + run: | + echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV + echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php-version }}' tools: composer - coverage: xdebug + coverage: ${{ env.COVERAGE_TYPE }} env: # Always use latest available patch for the version update: true @@ -107,7 +123,7 @@ jobs: - name: Build run: | - composer require \ + composer require -W \ symfony/http-foundation:^${{ matrix.symfony-version }} \ symfony/http-kernel:^${{ matrix.symfony-version }} \ symfony/config:^${{ matrix.symfony-version }} \ @@ -121,13 +137,16 @@ jobs: # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - 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 }}-${{ matrix.symfony-version }}" flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" fail_ci_if_error: true + - 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" @@ -136,6 +155,7 @@ jobs: fail_ci_if_error: true - name: Upload coverages to Codacy + if: ${{ 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 finalize-codacy-coverage-report: @@ -162,77 +182,16 @@ jobs: - name: Finalize reporting run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} - # Test against others impactful php versions (without coverage) - tests-extra-versions: - name: UTs & FTs - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} - runs-on: ubuntu-latest - needs: [ tests ] - strategy: - fail-fast: true - max-parallel: 4 - matrix: - include: - - php-version: '7.4' # Latest php 7 version - symfony-version: '4.4' - - php-version: '8.0' # First php 8 version - symfony-version: '5.4' - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php-version }}' - tools: composer - env: - # Always use latest available patch for the version - update: true - - - name: Setup cache - id: cache - uses: actions/cache@v2 - with: - path: | - ~/.composer - ./vendor - ${{ env.CODACY_CACHE_PATH }} - build/behat-code-coverage-cache - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ 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 require \ - symfony/http-foundation:^${{ matrix.symfony-version }} \ - symfony/http-kernel:^${{ matrix.symfony-version }} \ - symfony/config:^${{ matrix.symfony-version }} \ - symfony/dependency-injection:^${{ matrix.symfony-version }} \ - symfony/event-dispatcher:^${{ matrix.symfony-version }} \ - symfony/routing:^${{ matrix.symfony-version }} \ - && make build - - - name: Tests - run: make test-unit && make test-functional - # Perform tests against current php dev version and next Symfony minor version to manage nightly-tests: - name: Nightly - PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} - needs: [ tests ] + name: Nightly - Symfony ${{ matrix.symfony-version }} + needs: [ static-tests, tests ] runs-on: ubuntu-latest env: COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' strategy: fail-fast: false - max-parallel: 2 + max-parallel: 4 matrix: php-version: - '8.2' # Current php dev version @@ -252,7 +211,7 @@ jobs: with: php-version: '${{ matrix.php-version }}' tools: composer - coverage: xdebug + coverage: none env: # Always use latest available patch for the version update: true @@ -271,7 +230,7 @@ jobs: - name: Build run: | - composer require ${COMPOSER_OPTIONS} \ + composer require -W ${COMPOSER_OPTIONS} \ symfony/http-foundation:^${{ matrix.symfony-version }} \ symfony/http-kernel:^${{ matrix.symfony-version }} \ symfony/config:^${{ matrix.symfony-version }} \ @@ -282,20 +241,3 @@ jobs: - name: Test run: make test-unit && make test-functional - - # See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server - - name: Upload unit tests coverage to codecov - uses: codecov/codecov-action@v3 - with: - file: "build/coverage-phpunit/unit.clover" - name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "nightly,unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" - fail_ci_if_error: false - - - name: Upload functional tests coverage to codecov - uses: codecov/codecov-action@v3 - with: - files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover" - name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" - flags: "nightly,functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" - fail_ci_if_error: false From 424295aa215c57caab77fca750a45a927940fbcd Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 18:11:35 +0200 Subject: [PATCH 36/38] Split CI --- .../workflows/CI-ComposerRequireChecker.yml | 50 ++++++++++ .github/workflows/CI-DepsChecker.yml | 50 ++++++++++ .github/workflows/CI-nightly.yml | 75 +++++++++++++++ .github/workflows/CI.yml | 95 ------------------- 4 files changed, 175 insertions(+), 95 deletions(-) create mode 100644 .github/workflows/CI-ComposerRequireChecker.yml create mode 100644 .github/workflows/CI-DepsChecker.yml create mode 100644 .github/workflows/CI-nightly.yml diff --git a/.github/workflows/CI-ComposerRequireChecker.yml b/.github/workflows/CI-ComposerRequireChecker.yml new file mode 100644 index 0000000..4725ea6 --- /dev/null +++ b/.github/workflows/CI-ComposerRequireChecker.yml @@ -0,0 +1,50 @@ +name: 'CI - ComposerRequireChecker' +on: + workflow_run: + workflows: ["CI"] + types: + - requested + +concurrency: + group: "CI-${{ github.head_ref }}" + cancel-in-progress: true + +env: + # Cache params + CACHE_VERSION: 2022061906 # To be able to create a new cache (YYYYMMDDXX) + +jobs: + check: + name: ComposerRequireChecker + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - '8.1' # Latest supported + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + 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@v2 + with: + path: | + ~/.composer + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: make build + + - name: ComposerRequireChecker + uses: docker://webfactory/composer-require-checker:3.2.0 diff --git a/.github/workflows/CI-DepsChecker.yml b/.github/workflows/CI-DepsChecker.yml new file mode 100644 index 0000000..148b9af --- /dev/null +++ b/.github/workflows/CI-DepsChecker.yml @@ -0,0 +1,50 @@ +name: 'CI - Dependencies check' +on: + workflow_run: + workflows: ["CI"] + types: + - requested + +concurrency: + group: "CI-${{ github.head_ref }}" + cancel-in-progress: true + +env: + # Cache params + CACHE_VERSION: 2022061906 # To be able to create a new cache (YYYYMMDDXX) + +jobs: + check: + name: Dependencies check + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - '8.1' # Latest supported + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + 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@v2 + with: + path: | + ~/.composer + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: make build + + - name: Dependencies check + uses: actions/dependency-review-action@v1 diff --git a/.github/workflows/CI-nightly.yml b/.github/workflows/CI-nightly.yml new file mode 100644 index 0000000..4c4f562 --- /dev/null +++ b/.github/workflows/CI-nightly.yml @@ -0,0 +1,75 @@ +name: 'CI - Nightly' +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +concurrency: + group: "CI-${{ github.head_ref }}" + cancel-in-progress: true + +env: + # Cache params + CACHE_VERSION: 2022061906 # To be able to create a new cache (YYYYMMDDXX) + TEST_OUTPUT_STYLE: pretty + COMPOSER_OPTIONS: --optimize-autoloader --ignore-platform-req=php+ + +jobs: + tests: + name: Nightly - Symfony ${{ matrix.symfony-version }} + needs: [ static-tests, tests ] + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 4 + # Perform tests against: + # - current php dev version with all supported symfony version + # - next Symfony minor version to manage with latest supported php version + matrix: + php-version: + - '8.2' # Current php dev version + symfony-version: + - '4.4' # Lowest LTS + - '5.4' # Latest LTS + include: + - symfony-version: '6.0' # Next symfony minor version to manage with latest supported PHP version + php-version: '8.1' + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup PHP + 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@v2 + with: + path: | + ~/.composer + ./vendor + # Clear the cache if composer json (as composer.lock is in the repo) has been updated + key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} + + - name: Build + run: | + composer require -W ${{ env.COMPOSER_OPTIONS }} \ + symfony/http-foundation:^${{ matrix.symfony-version }} \ + symfony/http-kernel:^${{ matrix.symfony-version }} \ + symfony/config:^${{ matrix.symfony-version }} \ + symfony/dependency-injection:^${{ matrix.symfony-version }} \ + symfony/event-dispatcher:^${{ matrix.symfony-version }} \ + symfony/routing:^${{ matrix.symfony-version }} \ + && make build + + - name: Test + run: make test-unit && make test-functional diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d9eb70e..0674cd5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,41 +23,6 @@ env: CODACY_BIN: ~/.cache/codacy/codacy.sh jobs: - static-tests: - name: Static tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer - coverage: none - env: - # Always use latest available patch for the version - update: true - - - name: Setup cache - id: cache - uses: actions/cache@v2 - with: - path: | - ~/.composer - ./vendor - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} - - - name: Build - run: make build - - - name: ComposerRequireChecker - uses: docker://webfactory/composer-require-checker:3.2.0 - - - name: Dependency Review - uses: actions/dependency-review-action@v1 - tests: name: UTs & FTs - Symfony ${{ matrix.symfony-version }} runs-on: ubuntu-latest @@ -181,63 +146,3 @@ jobs: - name: Finalize reporting run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} - - # Perform tests against current php dev version and next Symfony minor version to manage - nightly-tests: - name: Nightly - Symfony ${{ matrix.symfony-version }} - needs: [ static-tests, tests ] - runs-on: ubuntu-latest - env: - COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' - strategy: - fail-fast: false - max-parallel: 4 - matrix: - php-version: - - '8.2' # Current php dev version - symfony-version: - - '4.4' # Lowest LTS - - '5.4' # Latest LTS - include: - - symfony-version: '6.0' # Next symfony minor version to manage with latest supported PHP version - php-version: '8.1' - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Setup PHP - 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@v2 - with: - path: | - ~/.composer - ./vendor - ${{ env.CODACY_CACHE_PATH }} - build/behat-code-coverage-cache - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} - - - name: Build - run: | - composer require -W ${COMPOSER_OPTIONS} \ - symfony/http-foundation:^${{ matrix.symfony-version }} \ - symfony/http-kernel:^${{ matrix.symfony-version }} \ - symfony/config:^${{ matrix.symfony-version }} \ - symfony/dependency-injection:^${{ matrix.symfony-version }} \ - symfony/event-dispatcher:^${{ matrix.symfony-version }} \ - symfony/routing:^${{ matrix.symfony-version }} \ - && make build - - - name: Test - run: make test-unit && make test-functional From ed875ea55be972221a9ba1662bacc8c98308e50a Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 18:16:53 +0200 Subject: [PATCH 37/38] Improve --- .github/workflows/CI-ComposerRequireChecker.yml | 3 ++- .github/workflows/CI-DepsChecker.yml | 3 ++- .github/workflows/CI-nightly.yml | 4 +++- .github/workflows/CI.yml | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI-ComposerRequireChecker.yml b/.github/workflows/CI-ComposerRequireChecker.yml index 4725ea6..e86b4b1 100644 --- a/.github/workflows/CI-ComposerRequireChecker.yml +++ b/.github/workflows/CI-ComposerRequireChecker.yml @@ -1,5 +1,6 @@ name: 'CI - ComposerRequireChecker' on: + workflow_dispatch: # Allows to run the workflow manually from the Actions tab workflow_run: workflows: ["CI"] types: @@ -24,7 +25,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup PHP + - name: Setup PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} diff --git a/.github/workflows/CI-DepsChecker.yml b/.github/workflows/CI-DepsChecker.yml index 148b9af..5dc3d51 100644 --- a/.github/workflows/CI-DepsChecker.yml +++ b/.github/workflows/CI-DepsChecker.yml @@ -1,5 +1,6 @@ name: 'CI - Dependencies check' on: + workflow_dispatch: # Allows to run the workflow manually from the Actions tab workflow_run: workflows: ["CI"] types: @@ -24,7 +25,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup PHP + - name: Setup PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} diff --git a/.github/workflows/CI-nightly.yml b/.github/workflows/CI-nightly.yml index 4c4f562..8445a9e 100644 --- a/.github/workflows/CI-nightly.yml +++ b/.github/workflows/CI-nightly.yml @@ -1,5 +1,6 @@ name: 'CI - Nightly' on: + workflow_dispatch: # Allows to run the workflow manually from the Actions tab workflow_run: workflows: ["CI"] types: @@ -20,6 +21,7 @@ jobs: name: Nightly - Symfony ${{ matrix.symfony-version }} needs: [ static-tests, tests ] runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} strategy: fail-fast: false max-parallel: 4 @@ -40,7 +42,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - - name: Setup PHP + - name: Setup PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php-version }}' diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0674cd5..ab081a5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,5 +1,6 @@ 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 @@ -56,7 +57,7 @@ jobs: echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV - - name: Setup PHP + - name: Setup PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php-version }}' From 1a179d56ef4570870b6aacf2c35aeb472f5e0975 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Sun, 19 Jun 2022 18:42:53 +0200 Subject: [PATCH 38/38] Enable carryforward flags --- codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codecov.yml b/codecov.yml index 45030d6..ad6143e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -5,5 +5,8 @@ flags: nightly: joined: false +comment: + show_carryforward_flags: true + github_checks: annotations: true