From d0d41a328fc844e1e1d7ec92c0a8c9a43378e178 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 6 Dec 2021 08:45:07 +0100 Subject: [PATCH 1/2] switch to github actions --- .github/workflows/.editorconfig | 2 + .github/workflows/tests.yml | 99 +++++++++++++++++++++++++++++++++ .travis.yml | 60 -------------------- README.md | 2 +- phpspec.yml.ci | 2 +- 5 files changed, 103 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/.editorconfig create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/.editorconfig b/.github/workflows/.editorconfig new file mode 100644 index 0000000..7bd3346 --- /dev/null +++ b/.github/workflows/.editorconfig @@ -0,0 +1,2 @@ +[*.yml] +indent_size = 2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b3a108d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,99 @@ +name: tests + +on: + push: + branches: + - master + pull_request: + +jobs: + latest: + name: PHP ${{ matrix.php }} Latest with Symfony ${{ matrix.symfony-require }} + runs-on: ubuntu-latest + strategy: + matrix: + php: ['7.3', '7.4', '8.0'] + symfony-require: ['*'] + include: + - php: '7.4' + symfony-require: 3.4.* + - php: '7.4' + symfony-require: 4.4.* + - php: '8.0' + symfony-require: 5.4.* + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + + - name: Composer validate + run: composer validate --strict --no-check-lock + + - name: Globally install symfony/flex + if: matrix.symfony-require != '*' + run: composer global require --no-progress --no-scripts --no-plugins symfony/flex + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --no-progress + + - name: Execute tests + run: composer test + + lowest: + name: PHP ${{ matrix.php }} Lowest + runs-on: ubuntu-latest + strategy: + matrix: + php: ['7.3'] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + + - name: Install dependencies + run: composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress + + - name: Execute tests + run: composer test + + coverage: + name: Code Coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + tools: composer:v2 + coverage: xdebug + + - name: Install dependencies + run: | + composer require "friends-of-phpspec/phpspec-code-coverage:^6.1.0" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-progress + + - name: Execute tests + run: composer test-ci + + - name: Upload coverage + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b1b988d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: php -sudo: false - -cache: - directories: - - $HOME/.composer/cache/files - -env: - global: - - TEST_COMMAND="composer test" - -branches: - except: - - /^analysis-.*$/ - -matrix: - fast_finish: true - include: - # Test with lowest dependencies - - php: 7.3 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" - - # Test the latest stable release - - php: 7.3 - - php: 7.4 - - php: 8.0snapshot - - # Force some major versions of Symfony - - php: 7.3 - env: DEPENDENCIES="dunglas/symfony-lock:^3" - - php: 7.3 - env: DEPENDENCIES="dunglas/symfony-lock:^4" - - php: 7.3 - env: SYMFONY_REQUIRE="5" - - # Latest commit to master - - php: 8.0snapshot - env: STABILITY="dev" - - allow_failures: - # Dev-master is allowed to fail. - - env: STABILITY="dev" - -before_install: - - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi - - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; - - if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; - -install: - # To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 - - if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi - - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction - -script: - - composer validate --strict --no-check-lock - - $TEST_COMMAND - -after_success: - - if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi diff --git a/README.md b/README.md index da2ddf6..6132345 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Latest Version](https://img.shields.io/github/release/php-http/stopwatch-plugin.svg?style=flat-square)](https://github.com/php-http/stopwatch-plugin/releases) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![Build Status](https://img.shields.io/travis/php-http/stopwatch-plugin.svg?style=flat-square)](https://travis-ci.org/php-http/stopwatch-plugin) +[![Build Status](https://github.com/php-http/stopwatch-plugin/actions/workflows/tests.yml/badge.svg)](https://github.com/php-http/stopwatch-plugin/actions/workflows/tests.yml) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/stopwatch-plugin.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/stopwatch-plugin) [![Quality Score](https://img.shields.io/scrutinizer/g/php-http/stopwatch-plugin.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/stopwatch-plugin) [![Total Downloads](https://img.shields.io/packagist/dt/php-http/stopwatch-plugin.svg?style=flat-square)](https://packagist.org/packages/php-http/stopwatch-plugin) diff --git a/phpspec.yml.ci b/phpspec.yml.ci index d6f9310..f438833 100644 --- a/phpspec.yml.ci +++ b/phpspec.yml.ci @@ -4,7 +4,7 @@ suites: psr4_prefix: Http\Client\Common\Plugin formatter.name: pretty extensions: - - PhpSpec\Extension\CodeCoverageExtension + FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension: ~ code_coverage: format: clover output: build/coverage.xml From a78a3d5711ea157fa028959a792097c4c7ed117c Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 6 Dec 2021 09:25:54 +0100 Subject: [PATCH 2/2] Apply fixes from StyleCI (#19) Co-authored-by: David Buchmann --- src/StopwatchPlugin.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/StopwatchPlugin.php b/src/StopwatchPlugin.php index 5e574a5..96d35a2 100644 --- a/src/StopwatchPlugin.php +++ b/src/StopwatchPlugin.php @@ -24,9 +24,6 @@ final class StopwatchPlugin implements Plugin */ private $stopwatch; - /** - * @param Stopwatch $stopwatch - */ public function __construct(Stopwatch $stopwatch) { $this->stopwatch = $stopwatch; @@ -51,8 +48,6 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca /** * Generates the event name. * - * @param RequestInterface $request - * * @return string */ private function getStopwatchEventName(RequestInterface $request)