diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 00219fa5..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,91 +0,0 @@ -# PHP CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-php/ for more details -# -version: 2.1 - -executors: - php-docker: # declares a reusable executor - parameters: - version: - description: "PHP version tag" - type: string - docker: - - image: cimg/php:<> - -jobs: - test: - parameters: - version: - description: "PHP version tag" - type: string - symfony: - description: "Symfony framework version tag" - type: string - - executor: - name: php-docker - version: <> - - steps: - - checkout - - - run: - name: Add PHP8 APT repository - command: sudo add-apt-repository ppa:ondrej/php -y - - run: sudo apt-get update - - run: sudo apt-get install -y php<>-zip php<>-sqlite3 - - # Download and cache dependencies - - restore_cache: - keys: - - composer-deps-<>-{{ checksum "composer.json" }} - # fallback to using the latest cache if no exact match is found - #- composer-deps- - - - run: - name: Install dependencies - command: COMPOSER_MEMORY_LIMIT=-1 composer require "symfony/framework-bundle=<>" -n --prefer-dist - - - save_cache: - key: composer-deps-<>-{{ checksum "composer.json" }} - paths: - - ./vendor - - # CIRCLE_PR_REPONAME indicates an external contributor PR - - run: - name: Get API Key Dealer client - command: | - if [ "$CIRCLE_PR_REPONAME" ]; then - curl -s https://algoliasearch-client-keygen.herokuapp.com | sh >> $BASH_ENV - fi - - - run: - name: Run static analysis - command: if [[ <> < "8.3" ]]; then composer test:install && composer test:types; fi - - - run: - name: Check code styles - command: if [[ <> < "8.3" ]]; then composer test:lint; fi - - # Run tests with phpunit - # - # If the PR is open by an Algolia, we run all the tests - # with the keys in the env variables - # If the PR was open from a fork (community PR) - # we get API keys from the API key dealer https://alg.li/api-key-dealer - - run: - name: Run tests - no_output_timeout: 15m - command: | - export COMPOSER_PROCESS_TIMEOUT=900 - composer test:unit - -workflows: - workflow: - jobs: - - test: - matrix: - parameters: - version: ['8.2', '8.3'] - symfony: ['^7.0'] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..65bbbbf4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.2', '8.3', '8.4', '8.5'] + symfony: ['^7.0'] + + name: PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: zip, sqlite3 + coverage: none + + - name: Cache Composer dependencies + uses: actions/cache@v4 + with: + path: vendor + key: composer-deps-${{ matrix.php }}-${{ hashFiles('composer.json') }} + restore-keys: | + composer-deps-${{ matrix.php }}- + + - name: Install dependencies + run: COMPOSER_MEMORY_LIMIT=-1 composer require "symfony/framework-bundle=${{ matrix.symfony }}" -n --prefer-dist + + - name: Run static analysis + run: composer test:install && composer test:types + + - name: Check code styles + run: composer test:lint + + - name: Run tests + if: ${{ !github.event.pull_request.head.repo.fork }} + timeout-minutes: 15 + env: + COMPOSER_PROCESS_TIMEOUT: 900 + ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} + ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} + ALGOLIA_PREFIX: sf_phpunit_${{ matrix.php }}_ + run: composer test:unit diff --git a/composer.json b/composer.json index 5b6d7c49..7f03425c 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "doctrine/event-manager": "^1.1 || ^2.0", "doctrine/persistence": "^2.1 || ^3.0", "symfony/filesystem": "^7.0", + "symfony/http-kernel": "^7.0", "symfony/property-access": "^7.0", "symfony/serializer": "^7.0" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 0919687e..10fbff32 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,7 +1,6 @@ includes: - tests/QualityTools/vendor/phpstan/phpstan-strict-rules/rules.neon - - tests/QualityTools/vendor/localheinz/phpstan-rules/rules.neon - - tests/QualityTools/vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + - tests/QualityTools/vendor/ergebnis/phpstan-rules/rules.neon parameters: level: 3 @@ -14,8 +13,6 @@ parameters: - '#File is missing a "declare\(strict_types=1\)" declaration.#' - '#Method Algolia\\SearchBundle\\DependencyInjection\\AlgoliaSearchExtension::load\(\) has a parameter .* with a type declaration of Symfony\\Component\\DependencyInjection\\ContainerBuilder, but containers should not be injected.#' - '#(Method|Function|Constructor).*has parameter.*with.*default value.#' - - '#Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder constructor#' - - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::root\(\).#' - '#Class Algolia\\SearchBundle\\Services\\NullSearchService is neither abstract nor final.#' - '#Class Algolia\\SearchBundle\\Settings\\SettingsManager is neither abstract nor final.#' - '#Class Algolia\\SearchBundle\\EventListener\\SearchIndexerSubscriber is neither abstract nor final.#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 685ec4b5..3b5f36ce 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -17,7 +17,7 @@ - + diff --git a/src/AlgoliaSearchBundle.php b/src/AlgoliaSearchBundle.php index 528ad496..e2b763bb 100644 --- a/src/AlgoliaSearchBundle.php +++ b/src/AlgoliaSearchBundle.php @@ -13,10 +13,7 @@ final class AlgoliaSearchBundle extends Bundle */ public const VERSION = '7.0.0'; - /** - * @return void - */ - public function boot() + public function boot(): void { parent::boot(); diff --git a/src/Command/SearchImportCommand.php b/src/Command/SearchImportCommand.php index 3b9bcb48..7930170f 100644 --- a/src/Command/SearchImportCommand.php +++ b/src/Command/SearchImportCommand.php @@ -37,7 +37,7 @@ public function __construct( SearchService $searchService, SearchService $searchServiceForAtomicReindex, ManagerRegistry $managerRegistry, - SearchClient $searchClient + SearchClient $searchClient, ) { parent::__construct($searchService); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 33f9e8b6..bf019cf1 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -16,15 +16,8 @@ final class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder(): TreeBuilder { - if (\method_exists(TreeBuilder::class, 'getRootNode')) { - $treeBuilder = new TreeBuilder('algolia_search'); - $rootNode = $treeBuilder->getRootNode(); - } else { - // @codeCoverageIgnoreStart - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('algolia_search'); - // @codeCoverageIgnoreEnd - } + $treeBuilder = new TreeBuilder('algolia_search'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/SearchableEntity.php b/src/SearchableEntity.php index e7426ba6..7493bc47 100644 --- a/src/SearchableEntity.php +++ b/src/SearchableEntity.php @@ -101,7 +101,7 @@ private function setId() throw new Exception('Entity has no primary key'); } - if (1 == count($ids)) { + if (1 === count($ids)) { $this->id = reset($ids); } else { $objectID = ''; diff --git a/tests/QualityTools/composer.json b/tests/QualityTools/composer.json index 3f7e31f2..84367f77 100644 --- a/tests/QualityTools/composer.json +++ b/tests/QualityTools/composer.json @@ -1,8 +1,7 @@ { "require-dev": { - "phpstan/phpstan": "^1.11", - "localheinz/phpstan-rules": "^2.2", - "phpstan/phpstan-strict-rules": "^1.6", - "thecodingmachine/phpstan-strict-rules": "^1.0" + "phpstan/phpstan": "^2.1", + "ergebnis/phpstan-rules": "^2.13", + "phpstan/phpstan-strict-rules": "^2.0" } } diff --git a/tests/TestCase/ClientProxyTest.php b/tests/TestCase/ClientProxyTest.php index 15ed63bd..3f62fbd1 100644 --- a/tests/TestCase/ClientProxyTest.php +++ b/tests/TestCase/ClientProxyTest.php @@ -41,9 +41,15 @@ public static function tearDownAfterClass(): void public function testClientIsProxied(): void { - $interfaces = class_implements($this->get('search.client')); - - self::assertContains(LazyObjectInterface::class, $interfaces); + $client = $this->get('search.client'); + + if (PHP_VERSION_ID >= 80400) { + $reflector = new \ReflectionClass($client); + self::assertTrue($reflector->isUninitializedLazyObject($client)); + } else { + $interfaces = class_implements($client); + self::assertContains(LazyObjectInterface::class, $interfaces); + } } public function testProxiedClientFailIfNoEnvVarsFound(): void diff --git a/tests/config/algolia_search.yml b/tests/config/algolia_search.yml index d822f746..7e9d86d0 100644 --- a/tests/config/algolia_search.yml +++ b/tests/config/algolia_search.yml @@ -1,5 +1,5 @@ algolia_search: - prefix: '%env(ALGOLIA_PREFIX)%%env(CIRCLE_BUILD_NUM)%_' + prefix: '%env(ALGOLIA_PREFIX)%%env(GITHUB_RUN_NUMBER)%_' nbResults: 12 batchSize: 100 settingsDirectory: '/tests/cache/settings'