From f6c910bd11c486075189738b9c6e0b10fcf0b67c Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Thu, 16 Nov 2023 12:24:17 +0100 Subject: [PATCH] Allow Symfony 7 --- .github/workflows/qa.yaml | 104 ++++++++-------------- README.md | 2 +- composer.json | 20 ++--- qa/php-cs-fixer/composer.json | 5 ++ src/CacheWarmer/SerializerCacheWarmer.php | 2 +- 5 files changed, 54 insertions(+), 79 deletions(-) create mode 100644 qa/php-cs-fixer/composer.json diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 55d48e32..262739a1 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -5,59 +5,14 @@ on: pull_request: jobs: - build: - name: Build - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - php-versions: ['7.1', '8.1'] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP, extensions and composer with shivammathur/setup-php - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json, mbstring, pdo - env: - update: true - - - name: Validate composer.json - run: composer validate --strict - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Install Lowest Composer dependencies - if: "matrix.php-versions < '8.1'" - run: composer update --prefer-lowest --no-progress --prefer-dist --optimize-autoloader - - - name: Install PHPUnit - run: vendor/bin/simple-phpunit install - - - name: Cache composer dependencies - uses: actions/cache@v1 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - php-version: ${{ matrix.php-versions }} - qa: name: Quality - needs: build runs-on: ubuntu-latest strategy: fail-fast: true matrix: - php-versions: ['8.1'] + php-versions: + - 8.2 steps: - name: Checkout @@ -68,28 +23,39 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, intl, dom, filter - tools: symfony env: update: true - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + run: composer install --working-dir=qa/php-cs-fixer - name: PHP-CS-Fixer - run: symfony php ./vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --verbose --diff + run: ./qa/vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --verbose --diff test: name: Tests - needs: build runs-on: ubuntu-latest strategy: fail-fast: true matrix: - php-versions: ['7.1', '8.1'] + php-versions: + - 8.1 + - 8.2 + - 8.3 + symfony-versions: + - 5.4.* + - 6.3.* + - 6.4.* + - 7.0.* + dependencies: + - '' + include: + - php-versions: '8.1' + symfony-versions: '5.4.*' + dependencies: 'lowest' + exclude: + - php-versions: '8.1' + symfony-versions: '7.0.*' steps: - name: Checkout @@ -99,21 +65,25 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: mbstring, xml, ctype, intl, dom, filter - tools: symfony + extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, json + tools: flex env: update: true - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + - name: Install Composer + if: "matrix.dependencies == ''" + run: composer update --no-progress --ansi --prefer-stable + env: + SYMFONY_REQUIRE: ${{ matrix.symfony-versions }} - name: Install Lowest Composer dependencies - if: "matrix.php-versions < '8.1'" - run: composer install --no-progress --prefer-dist --optimize-autoloader + if: "matrix.dependencies == 'lowest'" + run: composer update --no-progress --ansi --prefer-stable --prefer-lowest + env: + SYMFONY_REQUIRE: ${{ matrix.symfony-versions }} + + - name: Validate composer + run: composer validate --strict --no-check-lock - name: Execute unit tests - run: symfony php ./vendor/bin/simple-phpunit + run: ./vendor/bin/simple-phpunit diff --git a/README.md b/README.md index 454fdb59..8a24ba2a 100644 --- a/README.md +++ b/README.md @@ -324,5 +324,5 @@ previous, and "all" could define its own rules too. ## Contributing -PRs are welcomed :). Please target the `3.x` branch for bug fixes and `master` +PRs are welcomed :). Please target the `4.x` branch for bug fixes and `master` for new features. diff --git a/composer.json b/composer.json index e2c50218..66c7335c 100644 --- a/composer.json +++ b/composer.json @@ -12,17 +12,16 @@ } ], "require": { - "php": "^7.1.3 || ^8.0.0", + "php": "^8.1", "ezyang/htmlpurifier": "~4.14", - "symfony/config": "~4.4 || ^5.0 || ^6.0", - "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", - "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0" + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", - "symfony/form": "^4.4 || ^5.0 || ^6.0", - "symfony/phpunit-bridge": "^6.0", - "twig/twig": "^1.35.0 || ^2.4.4 || ^3.0" + "symfony/form": "^5.4 || ^6.0 || ^7.0", + "symfony/phpunit-bridge": "^7.0", + "twig/twig": "^2.4.4 || ^3.0" }, "autoload": { "psr-4": { "Exercise\\HTMLPurifierBundle\\": "src/" } @@ -35,7 +34,8 @@ }, "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } - } + }, + "minimum-stability": "dev" } diff --git a/qa/php-cs-fixer/composer.json b/qa/php-cs-fixer/composer.json new file mode 100644 index 00000000..2fbac5dd --- /dev/null +++ b/qa/php-cs-fixer/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "friendsofphp/php-cs-fixer": "^3.38" + } +} diff --git a/src/CacheWarmer/SerializerCacheWarmer.php b/src/CacheWarmer/SerializerCacheWarmer.php index 0f9e3d66..4e7fe7cf 100644 --- a/src/CacheWarmer/SerializerCacheWarmer.php +++ b/src/CacheWarmer/SerializerCacheWarmer.php @@ -37,7 +37,7 @@ public function __construct(array $paths, array $profiles, HTMLPurifiersRegistry $this->filesystem = $filesystem; } - public function warmUp($cacheDir): array + public function warmUp($cacheDir, string $buildDir = null): array { foreach ($this->paths as $path) { $this->filesystem->remove($path); // clean previous cache