From b4add092016df7567af6dd046653512e05c82f70 Mon Sep 17 00:00:00 2001 From: Simon R Jones Date: Wed, 26 Jun 2024 06:14:07 +0100 Subject: [PATCH 1/3] Update to PHP 8.1, Symfony 6/7 --- .github/workflows/php.yml | 44 +++++++++++-------- README.md | 8 ++-- composer.json | 18 ++++---- src/ResponseHelper/SymfonyResponseHelper.php | 5 ++- .../SymfonyResponseHelperTest.php | 3 +- 5 files changed, 42 insertions(+), 36 deletions(-) rename {tests => src}/ResponseHelper/SymfonyResponseHelperTest.php (96%) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index dc89e40..cb02ee7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,54 +2,60 @@ name: PHP tests on: push: - branches: [ main ] + branches: + - main + - release/** pull_request: - branches: [ main ] + branches: + - main jobs: build: strategy: matrix: - php-versions: ['7.4'] + php: ['8.1', '8.2', '8.3'] + symfony: ['6.4', '7.1'] + exclude: + - php: '8.1' + symfony: '7.1' runs-on: ubuntu-latest + name: On PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }} + steps: + # https://github.com/marketplace/actions/checkout - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 # https://github.com/marketplace/actions/setup-php-action - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php }} extensions: mbstring, intl ini-values: post_max_size=256M, max_execution_time=180 - - uses: actions/checkout@v2 - - name: Check PHP version run: php -v - name: Validate composer.json and composer.lock run: composer validate - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v2 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' run: composer install --prefer-dist --no-progress - - name: Code lint PHP files - run: ./vendor/bin/phplint + - name: Install Symfony ${{ matrix.symfony }} packages + run: | + composer update symfony/http-kernel:${{ matrix.symfony }} + composer update symfony/yaml:${{ matrix.symfony }} + + - name: Lint PHP files + run: | + curl -Ls https://github.com/overtrue/phplint/releases/latest/download/phplint.phar -o /usr/local/bin/phplint + chmod +x /usr/local/bin/phplint + /usr/local/bin/phplint --no-cache --no-progress -v - name: Coding standards run: ./vendor/bin/phpcs diff --git a/README.md b/README.md index 7621def..1a9e0fe 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Please note this software is in development, usage may change before the 1.0 rel ## Requirements -* PHP 7.4+ -* Symfony 5.2+ +* PHP 8.1+ +* Symfony 6.4+ * [Composer](https://getcomposer.org/) ## Installation @@ -16,10 +16,10 @@ Please note this software is in development, usage may change before the 1.0 rel Install via Composer: ``` -composer require strata/symfony-frontend:^0.8 +composer require strata/symfony-frontend:^0.9 ``` -Please see [Strata Frontend installation docs](https://docs.strata.dev/frontend/getting-started/installation). +Please see [Strata Frontend installation docs](https://docs.strata.dev/frontend/installation). ## Contributing diff --git a/composer.json b/composer.json index 1cee6a0..651f3af 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,10 @@ } ], "require": { - "php": ">=7.4", - "strata/frontend": "^0.8", - "symfony/http-kernel": "^5.3", - "twig/twig": "^3.0", - "symfony/framework-bundle": "^5.3" + "php": "^8.1", + "strata/frontend": "^0.9", + "symfony/http-kernel": "^6.4|^7.1", + "twig/twig": "^3.10" }, "autoload": { "psr-4": { @@ -27,10 +26,11 @@ } }, "require-dev": { - "overtrue/phplint": "^2.3", - "squizlabs/php_codesniffer": "^3.5", - "phpunit/phpunit": "^9.5", - "symfony/test-pack": "^1.0" + "phpunit/phpunit": "9.5", + "squizlabs/php_codesniffer": "^3.10", + "phpstan/phpstan": "^1.11", + "roave/security-advisories": "dev-latest", + "symfony/test-pack": "^1.1" }, "config": { "allow-plugins": false diff --git a/src/ResponseHelper/SymfonyResponseHelper.php b/src/ResponseHelper/SymfonyResponseHelper.php index cf7f0ec..9974290 100644 --- a/src/ResponseHelper/SymfonyResponseHelper.php +++ b/src/ResponseHelper/SymfonyResponseHelper.php @@ -4,7 +4,6 @@ namespace Strata\SymfonyBundle\ResponseHelper; -use Strata\Data\Helper\UnionTypes; use Strata\Frontend\ResponseHelper\HeaderValue; use Strata\Frontend\ResponseHelper\ResponseHelperAbstract; use Symfony\Component\HttpFoundation\Response; @@ -21,7 +20,9 @@ class SymfonyResponseHelper extends ResponseHelperAbstract */ public function apply($response): Response { - UnionTypes::assert('response', $response, Response::class); + if ($response instanceof Response === false) { + throw new \InvalidArgumentException('Response must be an instance of Symfony\Component\HttpFoundation\Response'); + } foreach ($this->getHeaders() as $name => $values) { /** @var HeaderValue $header */ diff --git a/tests/ResponseHelper/SymfonyResponseHelperTest.php b/src/ResponseHelper/SymfonyResponseHelperTest.php similarity index 96% rename from tests/ResponseHelper/SymfonyResponseHelperTest.php rename to src/ResponseHelper/SymfonyResponseHelperTest.php index ccb5a86..8a8eea6 100644 --- a/tests/ResponseHelper/SymfonyResponseHelperTest.php +++ b/src/ResponseHelper/SymfonyResponseHelperTest.php @@ -2,14 +2,13 @@ declare(strict_types=1); -namespace Test\ResponseHelper; +namespace Strata\SymfonyBundle\ResponseHelper; use FOS\HttpCache\ResponseTagger; use PHPUnit\Framework\TestCase; use Strata\Data\Http\Rest; use Strata\Data\Query\Query; use Strata\Data\Query\QueryManager; -use Strata\SymfonyBundle\ResponseHelper\SymfonyResponseHelper; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\HttpFoundation\Response; From 7e0283f7716ab8bb2d946c6ef589074e00c6413f Mon Sep 17 00:00:00 2001 From: Simon R Jones Date: Wed, 26 Jun 2024 06:22:13 +0100 Subject: [PATCH 2/3] Add release automation --- .github/workflows/release.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..eb82587 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: release-please + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + # Uses https://github.com/marketplace/actions/release-please-action + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + with: + release-type: php + From 74eca343dceb56758b3f141279ec451d6cbb3127 Mon Sep 17 00:00:00 2001 From: Simon R Jones Date: Wed, 26 Jun 2024 06:25:15 +0100 Subject: [PATCH 3/3] Alter PHP workflow --- .github/workflows/php.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index cb02ee7..71b3122 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -48,8 +48,7 @@ jobs: - name: Install Symfony ${{ matrix.symfony }} packages run: | - composer update symfony/http-kernel:${{ matrix.symfony }} - composer update symfony/yaml:${{ matrix.symfony }} + composer update symfony/http-kernel:^${{ matrix.symfony }} - name: Lint PHP files run: |