From 14d320e233628f6ed0fa910ed5c88abffdafc9f6 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 15:48:15 +0000 Subject: [PATCH 01/15] Add sonar config. Bump php version in composer.json --- .github/workflows/code_quality.yml | 38 +++++++++--------------------- composer.json | 2 +- sonar-project.properties | 28 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index bed9754..1e4eedb 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -1,32 +1,16 @@ -name: Qodana +name: Code Quality on: workflow_dispatch: - pull_request: push: - branches: # Specify your branches here - - main # The 'main' branch - - 'releases/*' # The release branches + branches: + - main + pull_request: + types: [ opened, synchronize, reopened ] jobs: - qodana: - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - checks: write - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - name: 'Install composer dependencies' - uses: php-actions/composer@v6 - with: - php_version: '8.3' - version: 2 - ssh_key: ${{ secrets.CLONE_SSH_KEY }} - ssh_key_pub: ${{ secrets.CLONE_SSH_KEY_PUB }} - - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2025.2 - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} + code_analysis: + name: Code Analysis + uses: kununu/shared-github-workflows/.github/workflows/backend_libraries_tests_and_code_quality.yml@sonarcloud + secrets: inherit + with: + php-version: 8.4 diff --git a/composer.json b/composer.json index 018a54e..82e36f8 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": ">=8.3", + "php": ">=8.4", "phpat/phpat": "^0.11.4", "phpstan/phpstan": "^2.1", "composer-plugin-api": "^2.0", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..cb26ac6 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,28 @@ +# ###################################################################################################################### +# Project configuration +# ###################################################################################################################### +sonar.projectKey=kununu_code-tools +sonar.organization=kununu +sonar.projectName=code-tools +sonar.projectVersion=1.0 +sonar.sourceEncoding=UTF-8 + +# ###################################################################################################################### +# Directories +# ###################################################################################################################### +sonar.sources=Kununu +sonar.tests=tests +sonar.php.coverage.reportPaths=clover.xml +sonar.php.tests.reportPath=junit.xml + +# ###################################################################################################################### +# Code coverage exclusions +# ###################################################################################################################### +sonar.coverage.exclusions=\ + tests/**,\ + +# ###################################################################################################################### +# Code duplication detections exclusions +# ###################################################################################################################### +sonar.cpd.exclusions=\ + tests/**,\ From efc85427b86830762ab72f93a5a70fc4d0405fac Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 15:50:34 +0000 Subject: [PATCH 02/15] Update php version in CI --- .github/workflows/cs_sniff.yml | 4 ++-- .github/workflows/testing.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cs_sniff.yml b/.github/workflows/cs_sniff.yml index 3de262e..9d22d3b 100644 --- a/.github/workflows/cs_sniff.yml +++ b/.github/workflows/cs_sniff.yml @@ -12,7 +12,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: none - name: Cache Composer dependencies @@ -25,7 +25,7 @@ jobs: - name: Install composer dependencies uses: php-actions/composer@v6 with: - php_version: '8.3' + php_version: '8.4' version: 2 args: --optimize-autoloader --no-progress --no-interaction ssh_key: ${{ secrets.CLONE_SSH_KEY }} diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 002c718..3a30bff 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,7 +12,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: none - name: Cache Composer dependencies @@ -25,11 +25,11 @@ jobs: - name: Install composer dependencies uses: php-actions/composer@v6 with: - php_version: '8.3' + php_version: '8.4' version: 2 args: --optimize-autoloader --no-progress --no-interaction ssh_key: ${{ secrets.CLONE_SSH_KEY }} ssh_key_pub: ${{ secrets.CLONE_SSH_KEY_PUB }} - name: Run tests - run: vendor/bin/phpunit \ No newline at end of file + run: vendor/bin/phpunit From 41111bae3baeb7bbb6462280b2107cbad4101268 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 16:44:47 +0000 Subject: [PATCH 03/15] Support both symfony 6.4 and 7.4 in tests --- .../Unit/Kununu/CsFixer/Command/CsFixerCommandTest.php | 5 ++++- .../CsFixer/Command/CsFixerGitHookCommandTest.php | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/Unit/Kununu/CsFixer/Command/CsFixerCommandTest.php b/tests/Unit/Kununu/CsFixer/Command/CsFixerCommandTest.php index 0c6ef34..f883037 100644 --- a/tests/Unit/Kununu/CsFixer/Command/CsFixerCommandTest.php +++ b/tests/Unit/Kununu/CsFixer/Command/CsFixerCommandTest.php @@ -22,7 +22,10 @@ public function testCsFixerCommand(string $before, string $after): void } $application = new Application(); - $application->add(new CsFixerCommand()); + $command = new CsFixerCommand(); + method_exists($application, 'addCommand') + ? $application->addCommand($command) + : $application->add($command); $command = $application->find('kununu:cs-fixer'); $tester = new CommandTester($command); diff --git a/tests/Unit/Kununu/CsFixer/Command/CsFixerGitHookCommandTest.php b/tests/Unit/Kununu/CsFixer/Command/CsFixerGitHookCommandTest.php index aa6f179..9a2b069 100644 --- a/tests/Unit/Kununu/CsFixer/Command/CsFixerGitHookCommandTest.php +++ b/tests/Unit/Kununu/CsFixer/Command/CsFixerGitHookCommandTest.php @@ -17,7 +17,10 @@ final class CsFixerGitHookCommandTest extends TestCase public function testFailsWhenNotAGitRepo(): void { $app = new Application(); - $app->add(new CsFixerGitHookCommand()); + $command = new CsFixerGitHookCommand(); + method_exists($app, 'addCommand') + ? $app->addCommand($command) + : $app->add($command); $command = $app->find('kununu:cs-fixer-git-hook'); $tester = new CommandTester($command); @@ -51,7 +54,10 @@ public function testInstallsHookSuccessfully(): void @chmod($binDir . '/php-cs-fixer', 0755); $app = new Application(); - $app->add(new CsFixerGitHookCommand()); + $command = new CsFixerGitHookCommand(); + method_exists($app, 'addCommand') + ? $app->addCommand($command) + : $app->add($command); $command = $app->find('kununu:cs-fixer-git-hook'); $tester = new CommandTester($command); From 84968595b6a2d55e60834b0d420ac72422fa7327 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 17:04:45 +0000 Subject: [PATCH 04/15] Empty commit From 62dc299532ad44a7d603ccf2964109c70786f587 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 17:24:29 +0000 Subject: [PATCH 05/15] Centralized CI --- .github/workflows/code_quality.yml | 16 --- .github/workflows/continuous-integration.yml | 123 +++++++++++++++++++ .github/workflows/cs_sniff.yml | 44 ------- .github/workflows/testing.yml | 35 ------ 4 files changed, 123 insertions(+), 95 deletions(-) delete mode 100644 .github/workflows/code_quality.yml create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .github/workflows/cs_sniff.yml delete mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml deleted file mode 100644 index 1e4eedb..0000000 --- a/.github/workflows/code_quality.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Code Quality -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - types: [ opened, synchronize, reopened ] - -jobs: - code_analysis: - name: Code Analysis - uses: kununu/shared-github-workflows/.github/workflows/backend_libraries_tests_and_code_quality.yml@sonarcloud - secrets: inherit - with: - php-version: 8.4 diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..4ac5fc5 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,123 @@ +name: Continuous Integration + +on: + push: + branches: + - main + pull_request: + types: [ opened, synchronize, reopened ] + +env: + fail-fast: true + +jobs: + checks: + name: Code Checks + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + coverage: none + tools: composer-dependency-analyser, composer-normalize, composer-require-checker + + - name: Install Composer Dependencies + uses: ramsey/composer-install@v3 + with: + dependency-versions: "highest" + composer-options: "--prefer-stable --optimize-autoloader --no-progress --no-interaction" + + - name: Run Composer Dependency Analyser + run: composer-dependency-analyser + + - name: Run Composer Require Checker + run: composer-require-checker + + - name: Run Composer Normalize + run: composer-normalize --dry-run --indent-size 2 --indent-style space --no-check-lock --no-update-lock + + - name: Run code style sniffer + run: vendor/bin/phpcs --standard=phpcs.xml Kununu/ tests/ + + - name: Run PHP CS Fixer + run: vendor/bin/php-cs-fixer check --using-cache=no --config php-cs-fixer.php + + - name: Run PHPStan + run: vendor/bin/phpstan analyse + + - name: Run Rector + run: vendor/bin/rector process --ansi --dry-run --config rector.php Kununu/ tests/ + + build: + needs: checks + name: PHPUnit + runs-on: ubuntu-latest + strategy: + matrix: + dependencies: + - lowest + - highest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + coverage: pcov + + - name: Install Composer Dependencies + uses: ramsey/composer-install@v3 + with: + dependency-versions: ${{ matrix.dependencies }} + composer-options: "--prefer-stable --optimize-autoloader --no-progress --no-interaction" + + - name: Run PHPUnit + run: | + vendor/bin/phpunit --colors=always --testdox \ + --log-junit tests/.results/tests-junit.xml \ + --coverage-clover tests/.results/tests-clover.xml + + - name: Upload coverage files + uses: actions/upload-artifact@v4 + with: + name: ${{ github.job }}-8.4-${{ matrix.dependencies }}-coverage + include-hidden-files: true + path: tests/.results/ + + sonarcloud: + needs: build + name: SonarCloud Checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v4 + with: + name: build-8.4-highest-coverage + path: tests/.results/ + + - name: Fix Code Coverage Paths + working-directory: tests/.results/ + run: | + sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' tests-clover.xml + sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' tests-junit.xml + + - name: SonarCloud Scan + uses: SonarSource/sonarqube-scan-action@v6.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/cs_sniff.yml b/.github/workflows/cs_sniff.yml deleted file mode 100644 index 9d22d3b..0000000 --- a/.github/workflows/cs_sniff.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: CI -on: - pull_request: - -jobs: - cs: - name: cs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.4' - coverage: none - - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer - - - name: Install composer dependencies - uses: php-actions/composer@v6 - with: - php_version: '8.4' - version: 2 - args: --optimize-autoloader --no-progress --no-interaction - ssh_key: ${{ secrets.CLONE_SSH_KEY }} - ssh_key_pub: ${{ secrets.CLONE_SSH_KEY_PUB }} - - - name: Run code style sniffer - run: vendor/bin/phpcs --standard=phpcs.xml Kununu/ tests/ - - - name: Run PHP CS Fixer - run: vendor/bin/php-cs-fixer check --using-cache=no --config php-cs-fixer.php - - - name: Run PHPStan - run: vendor/bin/phpstan analyse - - - name: Run Rector - run: vendor/bin/rector process --ansi --dry-run --config rector.php Kununu/ tests/ diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index 3a30bff..0000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: CI -on: - pull_request: - -jobs: - tests: - name: tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.4' - coverage: none - - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer - - - name: Install composer dependencies - uses: php-actions/composer@v6 - with: - php_version: '8.4' - version: 2 - args: --optimize-autoloader --no-progress --no-interaction - ssh_key: ${{ secrets.CLONE_SSH_KEY }} - ssh_key_pub: ${{ secrets.CLONE_SSH_KEY_PUB }} - - - name: Run tests - run: vendor/bin/phpunit From 9d93f40fc7fd5758ab4e6628f4e9716625336fb6 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 17:25:46 +0000 Subject: [PATCH 06/15] Remove steps --- .github/workflows/continuous-integration.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4ac5fc5..ceb7d56 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,15 +34,6 @@ jobs: dependency-versions: "highest" composer-options: "--prefer-stable --optimize-autoloader --no-progress --no-interaction" - - name: Run Composer Dependency Analyser - run: composer-dependency-analyser - - - name: Run Composer Require Checker - run: composer-require-checker - - - name: Run Composer Normalize - run: composer-normalize --dry-run --indent-size 2 --indent-style space --no-check-lock --no-update-lock - - name: Run code style sniffer run: vendor/bin/phpcs --standard=phpcs.xml Kununu/ tests/ From a4955b163a8a644d3554fe17165bdae957af0468 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 17:29:53 +0000 Subject: [PATCH 07/15] Require symfony/console for tests --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d0f8e9f..1897de5 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "symfony/yaml": "^6.4 || ^7.4" }, "require-dev": { - "phpunit/phpunit": "^11.5" + "phpunit/phpunit": "^11.5", + "symfony/console": "^6.4 || ^7.4" }, "autoload": { "psr-4": { From c9bd799ebac0ba6c2f266eec08ac1d052e72f18b Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 17:52:44 +0000 Subject: [PATCH 08/15] Set conflict versions in composer.json --- composer.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/composer.json b/composer.json index 1897de5..c1e3d84 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,17 @@ "phpunit/phpunit": "^11.5", "symfony/console": "^6.4 || ^7.4" }, + "conflict": { + "symfony/yaml": "<6.4", + "symfony/console": "<6.4", + "symfony/stopwatch": "<6.4", + "symfony/string": "<6.4", + "symfony/event-dispatcher": "<6.4", + "symfony/filesystem": "<6.4", + "symfony/finder": "<6.4", + "symfony/options-resolver": "<6.4", + "symfony/process": "<6.4" + }, "autoload": { "psr-4": { "Kununu\\": "Kununu/" From dbc3992f8a5b2ba8b210d0e040298360d8efeaeb Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 18:08:24 +0000 Subject: [PATCH 09/15] Fix friendsofphp/php-cs-fixer minimum version --- composer.json | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/composer.json b/composer.json index c1e3d84..ee666ba 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "phpstan/phpstan": "^2.1", "composer-plugin-api": "^2.0", "composer/composer": "^2.8", - "friendsofphp/php-cs-fixer": "^3.75", + "friendsofphp/php-cs-fixer": "^3.93", "rector/rector": "^2.0", "squizlabs/php_codesniffer": "^3.10", "symfony/yaml": "^6.4 || ^7.4" @@ -24,17 +24,6 @@ "phpunit/phpunit": "^11.5", "symfony/console": "^6.4 || ^7.4" }, - "conflict": { - "symfony/yaml": "<6.4", - "symfony/console": "<6.4", - "symfony/stopwatch": "<6.4", - "symfony/string": "<6.4", - "symfony/event-dispatcher": "<6.4", - "symfony/filesystem": "<6.4", - "symfony/finder": "<6.4", - "symfony/options-resolver": "<6.4", - "symfony/process": "<6.4" - }, "autoload": { "psr-4": { "Kununu\\": "Kununu/" From b3b500946dc84583fe084ba795ae91c33ae3ea42 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 18:14:17 +0000 Subject: [PATCH 10/15] Change code-owners to kununu/backend-libraries --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bdc7455..b1dbae1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @kununu/rosa-mota-backend +* @kununu/backend-libraries From 3714dac2174e8d0dd1e31405fe84a3ed55b11b4e Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Feb 2026 18:19:17 +0000 Subject: [PATCH 11/15] Update quality badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 51b8790..ae313ee 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Qodana](https://github.com/kununu/code-tools/actions/workflows/code_quality.yml/badge.svg)](https://github.com/kununu/code-tools/actions/workflows/code_quality.yml) - +![Continuous Integration](https://github.com/kununu/code-tools/actions/workflows/continuous-integration.yml/badge.svg) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=kununu_code-tools&metric=alert_status)](https://sonarcloud.io/dashboard?id=kununu_code-tools)

Brancher

From 055a943b2687354aa8c613f510a67e7afc7aee36 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Thu, 12 Feb 2026 08:40:28 +0000 Subject: [PATCH 12/15] Remove qodana config --- qodana.yaml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 qodana.yaml diff --git a/qodana.yaml b/qodana.yaml deleted file mode 100644 index b78eaf2..0000000 --- a/qodana.yaml +++ /dev/null @@ -1,17 +0,0 @@ -version: "1.0" -linter: jetbrains/qodana-php:2025.2 -profile: - name: qodana.recommended -exclude: - - name: All - paths: - - rector.php - - name: PhpDisabledQualityToolComposerInspection - - name: DuplicatedCode - paths: - - Kununu/Sniffs -failureConditions: - severityThresholds: - critical: 0 - high: 0 - moderate: 0 From 6db05484e10e65c93ee96bf26cd1d27a68365778 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Thu, 12 Feb 2026 08:45:53 +0000 Subject: [PATCH 13/15] Fix sonar config --- .github/workflows/continuous-integration.yml | 3 +-- sonar-project.properties | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ceb7d56..8e07dc9 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -26,7 +26,6 @@ jobs: with: php-version: 8.4 coverage: none - tools: composer-dependency-analyser, composer-normalize, composer-require-checker - name: Install Composer Dependencies uses: ramsey/composer-install@v3 @@ -108,7 +107,7 @@ jobs: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' tests-junit.xml - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@v6.0.0 + uses: SonarSource/sonarqube-scan-action@v7.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties index cb26ac6..b17bf22 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,8 +12,8 @@ sonar.sourceEncoding=UTF-8 # ###################################################################################################################### sonar.sources=Kununu sonar.tests=tests -sonar.php.coverage.reportPaths=clover.xml -sonar.php.tests.reportPath=junit.xml +sonar.php.coverage.reportPaths=tests/.results/tests-clover.xml +sonar.php.tests.reportPath=tests/.results/tests-junit.xml # ###################################################################################################################### # Code coverage exclusions From 8e1b58a4f1cb8b68daa1fdd3507a5c0dc2784fe8 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Thu, 12 Feb 2026 09:15:26 +0000 Subject: [PATCH 14/15] Add composer dependency analyser --- .github/workflows/continuous-integration.yml | 4 +++ composer-dependency-analyser.php | 27 ++++++++++++++++++++ composer.json | 8 +++--- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 composer-dependency-analyser.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8e07dc9..99904d8 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -26,6 +26,7 @@ jobs: with: php-version: 8.4 coverage: none + tools: composer-dependency-analyser, composer-normalize, composer-require-checker - name: Install Composer Dependencies uses: ramsey/composer-install@v3 @@ -33,6 +34,9 @@ jobs: dependency-versions: "highest" composer-options: "--prefer-stable --optimize-autoloader --no-progress --no-interaction" + - name: Run Composer Dependency Analyser + run: composer-dependency-analyser + - name: Run code style sniffer run: vendor/bin/phpcs --standard=phpcs.xml Kununu/ tests/ diff --git a/composer-dependency-analyser.php b/composer-dependency-analyser.php new file mode 100644 index 0000000..236115a --- /dev/null +++ b/composer-dependency-analyser.php @@ -0,0 +1,27 @@ +addPathToExclude(__DIR__ . '/tests') + ->ignoreErrorsOnPath(__DIR__ . '/Kununu/Sniffs/', [ErrorType::UNKNOWN_CLASS]) + ->ignoreErrorsOnExtensions( + [ + 'ext-mbstring', + 'ext-tokenizer', + ], + [ErrorType::SHADOW_DEPENDENCY] + ) + ->ignoreErrorsOnPackages( + [ + 'friendsofphp/php-cs-fixer', + 'phpstan/phpstan', + 'rector/rector', + 'squizlabs/php_codesniffer', + ], + [ErrorType::UNUSED_DEPENDENCY] + ); diff --git a/composer.json b/composer.json index ee666ba..6713df5 100644 --- a/composer.json +++ b/composer.json @@ -11,18 +11,20 @@ ], "require": { "php": ">=8.4", - "phpat/phpat": "^0.11.4", - "phpstan/phpstan": "^2.1", "composer-plugin-api": "^2.0", "composer/composer": "^2.8", "friendsofphp/php-cs-fixer": "^3.93", + "phpat/phpat": "^0.11.4", + "phpstan/phpstan": "^2.1", "rector/rector": "^2.0", "squizlabs/php_codesniffer": "^3.10", + "symfony/console": "^6.4 || ^7.4", + "symfony/process": "^6.4 || ^7.4", "symfony/yaml": "^6.4 || ^7.4" }, "require-dev": { "phpunit/phpunit": "^11.5", - "symfony/console": "^6.4 || ^7.4" + "shipmonk/composer-dependency-analyser": "^1.8" }, "autoload": { "psr-4": { From d59bc1aee8b608a9c6f61ad2f368a9e444417037 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Thu, 12 Feb 2026 09:27:03 +0000 Subject: [PATCH 15/15] Add Composer Require Checker and Composer Normalize --- .github/workflows/continuous-integration.yml | 6 + composer-require-checker.json | 27 ++++ composer.json | 130 ++++++++++--------- 3 files changed, 100 insertions(+), 63 deletions(-) create mode 100644 composer-require-checker.json diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 99904d8..de9023b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,6 +37,12 @@ jobs: - name: Run Composer Dependency Analyser run: composer-dependency-analyser + - name: Run Composer Require Checker + run: composer-require-checker + + - name: Run Composer Normalize + run: composer-normalize --dry-run --indent-size 2 --indent-style space --no-check-lock --no-update-lock + - name: Run code style sniffer run: vendor/bin/phpcs --standard=phpcs.xml Kununu/ tests/ diff --git a/composer-require-checker.json b/composer-require-checker.json new file mode 100644 index 0000000..36cdc19 --- /dev/null +++ b/composer-require-checker.json @@ -0,0 +1,27 @@ +{ + "symbol-whitelist": [ + "mb_strlen", + "PHP_CodeSniffer\\Exceptions\\DeepExitException", + "PHP_CodeSniffer\\Files\\File", + "PHP_CodeSniffer\\Sniffs\\Sniff", + "PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\LineLengthSniff", + "T_CLASS", + "T_FUNCTION", + "T_CLOSE_CURLY_BRACKET", + "T_COMMA", + "T_NULLABLE", + "T_OPEN_TAG", + "T_PRIVATE", + "T_PROTECTED", + "T_PUBLIC", + "T_READONLY", + "T_SEMICOLON", + "T_STRING", + "T_USE", + "T_VAR", + "T_VARIABLE", + "T_WHITESPACE", + "T_CONST", + "T_DECLARE" + ] +} diff --git a/composer.json b/composer.json index 6713df5..94c5298 100644 --- a/composer.json +++ b/composer.json @@ -1,67 +1,71 @@ { - "name": "kununu/code-tools", - "description": "Code Tools", - "type": "composer-plugin", - "license": "MIT", - "authors": [ - { - "name": "Team Rosa Mota", - "email": "rosamota-dev@kununu.com" - } - ], - "require": { - "php": ">=8.4", - "composer-plugin-api": "^2.0", - "composer/composer": "^2.8", - "friendsofphp/php-cs-fixer": "^3.93", - "phpat/phpat": "^0.11.4", - "phpstan/phpstan": "^2.1", - "rector/rector": "^2.0", - "squizlabs/php_codesniffer": "^3.10", - "symfony/console": "^6.4 || ^7.4", - "symfony/process": "^6.4 || ^7.4", - "symfony/yaml": "^6.4 || ^7.4" - }, - "require-dev": { - "phpunit/phpunit": "^11.5", - "shipmonk/composer-dependency-analyser": "^1.8" - }, - "autoload": { - "psr-4": { - "Kununu\\": "Kununu/" - } - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } + "name": "kununu/code-tools", + "description": "Code Tools", + "license": "MIT", + "type": "composer-plugin", + "authors": [ + { + "name": "Team Rosa Mota", + "email": "rosamota-dev@kununu.com" + } + ], + "require": { + "php": ">=8.4", + "composer-plugin-api": "^2.0", + "composer/composer": "^2.8", + "friendsofphp/php-cs-fixer": "^3.93", + "phpat/phpat": "^0.11.4", + "phpstan/phpstan": "^2.1", + "rector/rector": "^2.0", + "squizlabs/php_codesniffer": "^3.10", + "symfony/console": "^6.4 || ^7.4", + "symfony/process": "^6.4 || ^7.4", + "symfony/yaml": "^6.4 || ^7.4" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.50", + "phpunit/phpunit": "^11.5", + "shipmonk/composer-dependency-analyser": "^1.8" + }, + "autoload": { + "psr-4": { + "Kununu\\": "Kununu/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "bin": [ + "bin/code-tools", + "bin/php-in-k8s" + ], + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true }, - "bin": [ - "bin/code-tools", - "bin/php-in-k8s" + "process-timeout": 900, + "sort-packages": true + }, + "extra": { + "class": "Kununu\\CsFixer\\CsFixerPlugin" + }, + "scripts": { + "ci-checks": [ + "@cs-fixer-check", + "@cs-check", + "@stan", + "@rector", + "@test-unit" ], - "config": { - "sort-packages": true, - "process-timeout": 900 - }, - "extra": { - "class": "Kununu\\CsFixer\\CsFixerPlugin" - }, - "scripts": { - "test-unit": "phpunit", - "cs-fixer-check": "php-cs-fixer check --config=php-cs-fixer.php", - "cs-fixer-fix": "php-cs-fixer fix --config=php-cs-fixer.php", - "cs-check": "phpcs --standard=phpcs.xml Kununu/ tests/", - "cs-fix": "phpcbf --standard=phpcs.xml Kununu/ tests/", - "stan": "phpstan analyze", - "rector": "rector process --dry-run Kununu/ tests/ -vvv", - "rector-fix": "rector process Kununu/ tests/", - "ci-checks": [ - "@cs-fixer-check", - "@cs-check", - "@stan", - "@rector", - "@test-unit" - ] - } + "cs-check": "phpcs --standard=phpcs.xml Kununu/ tests/", + "cs-fix": "phpcbf --standard=phpcs.xml Kununu/ tests/", + "cs-fixer-check": "php-cs-fixer check --config=php-cs-fixer.php", + "cs-fixer-fix": "php-cs-fixer fix --config=php-cs-fixer.php", + "rector": "rector process --dry-run Kununu/ tests/ -vvv", + "rector-fix": "rector process Kununu/ tests/", + "stan": "phpstan analyze", + "test-unit": "phpunit" + } }