From ef2ed8a54a99ec1f3a9037b20cd38efa2be8b7dd Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Thu, 26 Feb 2026 13:03:09 +0100 Subject: [PATCH 1/2] Improve workflow - Split workflow files and use Rollerscapes Inspector for CS - Don't cache vcs in workflow - Allow newer versions of PHPUnit --- .github/composer-config.json | 13 ++ .github/workflows/ci.yaml | 159 ---------------------- .github/workflows/composer-validate.yaml | 51 +++++++ .github/workflows/inspector-bot.yaml | 16 +++ .github/workflows/phpstan.yaml | 62 +++++++++ .github/workflows/unit-tests.yml | 76 +++++++++++ composer.json | 5 +- tests/Bundle/BundleInitializationTest.php | 10 ++ 8 files changed, 231 insertions(+), 161 deletions(-) create mode 100644 .github/composer-config.json delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/composer-validate.yaml create mode 100644 .github/workflows/inspector-bot.yaml create mode 100644 .github/workflows/phpstan.yaml create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/composer-config.json b/.github/composer-config.json new file mode 100644 index 0000000..3cf8468 --- /dev/null +++ b/.github/composer-config.json @@ -0,0 +1,13 @@ +{ + "config": { + "cache-vcs-dir": "/dev/null", + "platform-check": false, + "preferred-install": { + "*": "dist" + }, + "allow-plugins": { + "ergebnis/composer-normalize": true, + "symfony/flex": true + } + } +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index c4c3ff3..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,159 +0,0 @@ -name: 'CI' - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - cs-fixer: - name: 'PHP CS Fixer' - - runs-on: 'ubuntu-latest' - - strategy: - matrix: - php-version: - - '8.2' - - steps: - - - name: 'Check out' - uses: 'actions/checkout@v4' - - - - name: 'Set up PHP' - uses: 'shivammathur/setup-php@v2' - with: - php-version: '${{ matrix.php-version }}' - coverage: 'none' - - - - name: 'Get Composer cache directory' - id: 'composer-cache' - run: 'echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - - - - name: 'Cache dependencies' - uses: 'actions/cache@v3' - with: - path: '${{ steps.composer-cache.outputs.cache_dir }}' - key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: 'php-${{ matrix.php-version }}-composer-locked-' - - - - name: 'Install dependencies' - run: 'composer install --no-progress' - - - - name: 'Check the code style' - run: 'make cs' - - phpstan: - name: 'PhpStan' - - runs-on: 'ubuntu-latest' - - strategy: - matrix: - php-version: - - '8.2' - - steps: - - - name: 'Check out' - uses: 'actions/checkout@v4' - - - - name: 'Set up PHP' - uses: 'shivammathur/setup-php@v2' - with: - php-version: '${{ matrix.php-version }}' - coverage: 'none' - - - - name: 'Get Composer cache directory' - id: 'composer-cache' - run: 'echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - - - - name: 'Cache dependencies' - uses: 'actions/cache@v3' - with: - path: '${{ steps.composer-cache.outputs.cache_dir }}' - key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: 'php-${{ matrix.php-version }}-composer-locked-' - - - - name: 'Install dependencies' - run: 'composer install --no-progress' - - - - name: 'Run PhpStan' - run: 'vendor/bin/phpstan analyze --no-progress' - - tests: - name: 'PHPUnit' - - runs-on: 'ubuntu-latest' - - strategy: - matrix: - include: - - - php-version: '8.2' - composer-options: '--prefer-stable' - symfony-version: '^7.4' - remove-http-client: 'yes' - - - - php-version: '8.4' - composer-options: '--prefer-stable' - symfony-version: '^8.0' - - steps: - - - name: 'Check out' - uses: 'actions/checkout@v4' - - - - name: 'Set up PHP' - uses: 'shivammathur/setup-php@v2' - with: - php-version: '${{ matrix.php-version }}' - coverage: 'none' - - - - name: 'Get Composer cache directory' - id: 'composer-cache' - run: 'echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - - - - name: 'Cache dependencies' - uses: 'actions/cache@v3' - with: - path: '${{ steps.composer-cache.outputs.cache_dir }}' - key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: 'php-${{ matrix.php-version }}-composer-locked-' - - - - name: 'Install dependencies' - env: - COMPOSER_OPTIONS: '${{ matrix.composer-options }}' - SYMFONY_REQUIRE: '${{ matrix.symfony-version }}' - REMOVE_HTTP_CLIENT: '${{ matrix.remove-http-client }}' - run: | - if [ "$REMOVE_HTTP_CLIENT" == "yes" ]; then - composer remove --dev symfony/http-client - fi - - composer global config --no-plugins allow-plugins.symfony/flex true - composer global require --no-progress --no-scripts --no-plugins symfony/flex - composer update --no-progress $COMPOSER_OPTIONS - - - - name: 'Run tests' - run: make phpunit diff --git a/.github/workflows/composer-validate.yaml b/.github/workflows/composer-validate.yaml new file mode 100644 index 0000000..4eaa602 --- /dev/null +++ b/.github/workflows/composer-validate.yaml @@ -0,0 +1,51 @@ +name: Composer Validate + +on: + push: + paths: + - 'composer.json' + pull_request: + paths: + - 'composer.json' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + composer-sync: + name: 'Composer validation' + runs-on: ubuntu-24.04 + env: + php-version: '8.4' + + steps: + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.php-version }} + ini-values: "memory_limit=-1" + coverage: none + + - + name: Checkout target branch + uses: actions/checkout@v6 + + - + name: 'Install dependencies' + run: | + COMPOSER_HOME="$(composer config home)" + ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" + composer global require -q "ergebnis/composer-normalize" + composer install --no-progress + + - + name: 'Normalized composer.json' + run: | + echo "composer.json" + composer validate + composer normalize diff --git a/.github/workflows/inspector-bot.yaml b/.github/workflows/inspector-bot.yaml new file mode 100644 index 0000000..34e2125 --- /dev/null +++ b/.github/workflows/inspector-bot.yaml @@ -0,0 +1,16 @@ +name: CS + +on: + pull_request: + +permissions: + contents: read + +jobs: + call-inspector-bot: + name: InspectorBot + uses: rollerscapes/inspector-bot/.github/workflows/inspector-bot.yml@main + with: + package: PdbSymfonyBridge + check_license: true + diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml new file mode 100644 index 0000000..6169481 --- /dev/null +++ b/.github/workflows/phpstan.yaml @@ -0,0 +1,62 @@ +name: PHPStan + +on: + pull_request: + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-24.04 + + env: + php-version: '8.2' + steps: + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.php-version }} + ini-values: "memory_limit=-1" + coverage: none + + - + name: Checkout target branch + uses: actions/checkout@v6 + with: + ref: ${{ github.base_ref }} + + - + name: Checkout PR + uses: actions/checkout@v6 + + - + name: Install dependencies + run: | + COMPOSER_HOME="$(composer config home)" + ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" + composer install --no-progress --ansi --no-plugins + + - + name: Generate PHPStan baseline + run: | + git checkout composer.json + git checkout -m ${{ github.base_ref }} + vendor/bin/phpstan analyze --generate-baseline --allow-empty-baseline --no-progress + git checkout -m FETCH_HEAD + + - + name: PHPStan + run: | + vendor/bin/phpstan analyze --no-progress --error-format=github + diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..f4c0335 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,76 @@ +name: CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + + test: + + name: 'PHPUnit with PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }}' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - + php-version: '8.2' + composer-options: '--prefer-stable' + symfony-version: '^7.4' + remove-http-client: 'yes' + + - + php-version: '8.2' + composer-options: '--prefer-stable' + symfony-version: '^7.4' + + - + php-version: '8.3' + composer-options: '--prefer-stable' + symfony-version: '^7.4' + + - + php-version: '8.4' + composer-options: '--prefer-stable' + symfony-version: '^8.0' + + - + php-version: '8.5' + composer-options: '--prefer-stable' + symfony-version: '^8.0' + steps: + - + name: Checkout + uses: actions/checkout@v6 + + - + name: 'Set up PHP' + uses: 'shivammathur/setup-php@v2' + with: + php-version: '${{ matrix.php-version }}' + coverage: none + env: + update: true + + - + name: 'Install dependencies' + env: + COMPOSER_OPTIONS: '${{ matrix.composer-options }}' + SYMFONY_REQUIRE: '${{ matrix.symfony-version }}' + run: | + if [ "$REMOVE_HTTP_CLIENT" == "yes" ]; then + composer remove --dev symfony/http-client + fi + + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins symfony/flex + composer update --no-progress --no-interaction --optimize-autoloader $COMPOSER_OPTIONS + + - + name: Run Tests + run: make phpunit diff --git a/composer.json b/composer.json index 661e395..366eebe 100644 --- a/composer.json +++ b/composer.json @@ -23,12 +23,13 @@ "require-dev": { "matthiasnoback/symfony-dependency-injection-test": "^5.1 || ^6.2", "nyholm/symfony-bundle-test": "^2.0 || ^3.1", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.0 || ^11.5 || ^12.5 || ^13.0", "rollerscapes/standards": "^1.0", "symfony/console": "^7.4 || ^8.0", "symfony/framework-bundle": "^7.4 || ^8.0", "symfony/http-client": "^7.4 || ^8.0", - "symfony/phpunit-bridge": "^7.4 || ^8.0" + "symfony/phpunit-bridge": "^7.4 || ^8.0", + "symfony/polyfill-php85": "^1.33" }, "conflict": { "symfony/framework-bundle": "<7.4" diff --git a/tests/Bundle/BundleInitializationTest.php b/tests/Bundle/BundleInitializationTest.php index 8e3aebe..ca00606 100644 --- a/tests/Bundle/BundleInitializationTest.php +++ b/tests/Bundle/BundleInitializationTest.php @@ -111,4 +111,14 @@ public function test_works_without_http_client(): void $service = $container->get('rollerworks_pdb.pdb_manager'); $this->assertInstanceOf(StaticPdpManager::class, $service); } + + protected function tearDown(): void + { + parent::tearDown(); + + while (get_exception_handler() !== null) { + restore_exception_handler(); + } + } + } From 425bdd1f6991b56b9911e22e0df5b99d20ac254a Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Thu, 26 Feb 2026 13:07:29 +0100 Subject: [PATCH 2/2] Fix CS --- src/StaticPdpManager.php | 2 +- tests/Bundle/BundleInitializationTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/StaticPdpManager.php b/src/StaticPdpManager.php index b610109..84586e0 100644 --- a/src/StaticPdpManager.php +++ b/src/StaticPdpManager.php @@ -70,7 +70,7 @@ public function updateCaches(): void $this->topLevelDomainListCache->remember(ResourceUri::TOP_LEVEL_DOMAIN_LIST_URI, TopLevelDomains::fromPath($this->topLevelDomainList)); } - public function populateCaches(string $publicSuffixList, $topLevelDomainList): void + public function populateCaches(string $publicSuffixList, string $topLevelDomainList): void { $this->publicSuffixListCache->remember(ResourceUri::PUBLIC_SUFFIX_LIST_URI, Rules::fromPath($publicSuffixList)); $this->topLevelDomainListCache->remember(ResourceUri::TOP_LEVEL_DOMAIN_LIST_URI, TopLevelDomains::fromPath($topLevelDomainList)); diff --git a/tests/Bundle/BundleInitializationTest.php b/tests/Bundle/BundleInitializationTest.php index ca00606..0848d23 100644 --- a/tests/Bundle/BundleInitializationTest.php +++ b/tests/Bundle/BundleInitializationTest.php @@ -31,6 +31,9 @@ protected static function getKernelClass(): string return TestKernel::class; } + /** + * @param array $options + */ protected static function createKernel(array $options = []): KernelInterface { /** @var TestKernel $kernel */