Skip to content

Fix deprecations in tests #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2025
Merged

Fix deprecations in tests #390

merged 2 commits into from
Jul 13, 2025

Conversation

norkunas
Copy link
Collaborator

@norkunas norkunas commented Jul 8, 2025

Pull Request

Related issue

Fixes #389

What does this PR do?

  • Fixes deprecations and CI run
  • Add's cron to run once per week to spot deprecations/errors earlier

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Summary by CodeRabbit

  • New Features

    • Added support for native lazy objects in Doctrine ORM when compatible, with automatic configuration adjustments based on PHP version and environment.
    • Introduced a new configuration file to ensure compatibility with older proxy mechanisms.
  • Bug Fixes

    • Improved compatibility checks to ensure correct class resolution and configuration loading across different Doctrine ORM and PHP versions.
  • Tests

    • Updated tests to conditionally skip scenarios incompatible with native lazy objects.
    • Suppressed deprecation warnings related to Doctrine ORM proxies in test outputs.
  • Chores

    • Scheduled automated test runs every Monday at 03:00 UTC.

@norkunas norkunas added enhancement New feature or request maintenance Anything related to maintenance (CI, tests, refactoring...) labels Jul 8, 2025
@norkunas norkunas requested a review from curquiza July 8, 2025 12:51
Copy link

coderabbitai bot commented Jul 8, 2025

Warning

Rate limit exceeded

@norkunas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 70f72ef and c1858f5.

📒 Files selected for processing (8)
  • .github/workflows/tests.yml (1 hunks)
  • .php-cs-fixer.dist.php (1 hunks)
  • src/Services/MeilisearchService.php (2 hunks)
  • tests/Integration/AggregatorTest.php (2 hunks)
  • tests/Kernel.php (2 hunks)
  • tests/baseline-ignore (1 hunks)
  • tests/config/config.yaml (1 hunks)
  • tests/config/config_old_proxy.yaml (1 hunks)

"""

Walkthrough

The changes introduce compatibility for Doctrine ORM's native lazy objects by updating configuration, conditional logic, and test handling. A scheduled CI workflow trigger is added. Deprecation warnings are suppressed, and configuration files are loaded based on PHP version and Doctrine features. Tests are conditionally skipped or configured to match the runtime environment.

Changes

File(s) Change Summary
.github/workflows/tests.yml Added a scheduled workflow trigger to run tests every Monday at 03:00 UTC.
src/Services/MeilisearchService.php Updated class resolution logic to check for LegacyReflectionFields for native lazy objects compatibility.
tests/Integration/AggregatorTest.php Skips a test if LegacyReflectionFields exists, acknowledging proxy changes with native lazy objects.
tests/Kernel.php Conditional loading of config files based on PHP version and presence of LegacyReflectionFields.
tests/baseline-ignore Added suppression for Doctrine ORM deprecation warnings and notices.
tests/config/config.yaml Set auto_generate_proxy_classes to false; enabled enable_native_lazy_objects.
tests/config/config_old_proxy.yaml New config file for older PHP/Doctrine environments with legacy proxy settings.
.php-cs-fixer.dist.php Added disabled rule get_class_to_class_keyword for future PHP 8+ support.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant Kernel
    participant DoctrineORM
    participant ConfigLoader

    TestRunner->>Kernel: Start test suite
    Kernel->>ConfigLoader: Check PHP version & LegacyReflectionFields
    alt PHP >= 8.4 and LegacyReflectionFields exists
        ConfigLoader->>Kernel: Load config.yaml (native lazy objects)
    else
        ConfigLoader->>Kernel: Load config_old_proxy.yaml (legacy proxies)
    end
    Kernel->>DoctrineORM: Initialize ORM with selected config
    TestRunner->>TestRunner: Run/skip tests based on environment
Loading

Assessment against linked issues

Objective Addressed Explanation
Fix test suite to run successfully without errors or exit code 1 in CI (#389)
Suppress or address Doctrine ORM deprecation warnings during test runs (#389)
Ensure codebase compatibility with Doctrine ORM native lazy objects and upcoming changes (#389)
Conditional test execution/configuration based on environment and Doctrine features (#389)

Poem

A bunny hops through fields of code,
Where proxies once would dwell—
Now lazy objects natively load,
And tests are running well!
Deprecations swept aside with care,
The CI clock ticks on,
As rabbits cheer this tidy lair—
Hooray, the bugs are gone! 🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eec319d and 934bef2.

📒 Files selected for processing (7)
  • .github/workflows/tests.yml (1 hunks)
  • src/Services/MeilisearchService.php (2 hunks)
  • tests/Integration/AggregatorTest.php (2 hunks)
  • tests/Kernel.php (2 hunks)
  • tests/baseline-ignore (1 hunks)
  • tests/config/config.yaml (1 hunks)
  • tests/config/config_old_proxy.yaml (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Tests
tests/Integration/AggregatorTest.php

[warning] 40-40: Test skipped: 'testAggregatorProxyClass' skipped because proxies are not wrapped anymore with lazy native objects.

src/Services/MeilisearchService.php

[warning] 23-23: TooManyPublicMethods: The class MeilisearchService has 11 public methods. Consider refactoring MeilisearchService to keep number of public methods under 10.


[warning] 23-23: ExcessiveClassComplexity: The class MeilisearchService has an overall complexity of 55 which is very high. The configured complexity threshold is 50.


[warning] 23-23: CouplingBetweenObjects: The class MeilisearchService has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.


[warning] 44-44: LongVariable: Avoid excessively long variable names like $classToSerializerGroup. Keep variable name length under 20.


[warning] 52-52: StaticAccess: Avoid using static access to class '\Symfony\Component\PropertyAccess\PropertyAccess' in method '__construct'.


[warning] 337-337: LongVariable: Avoid excessively long variable names like $searchableEntitiesChunk. Keep variable name length under 20.


[warning] 385-385: StaticAccess: Avoid using static access to class '\Doctrine\ORM\Proxy\DefaultProxyClassNameResolver' in method 'resolveClass'.


[warning] 389-389: StaticAccess: Avoid using static access to class '\Doctrine\Common\Util\ClassUtils' in method 'resolveClass'.

🪛 actionlint (1.7.7)
.github/workflows/tests.yml

11-11: unexpected key "schedule" for "push" section. expected one of "branches", "branches-ignore", "paths", "paths-ignore", "tags", "tags-ignore", "types", "workflows"

(syntax-check)

🪛 Gitleaks (8.26.0)
tests/config/config_old_proxy.yaml

3-3: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (9)
tests/config/config_old_proxy.yaml (1)

1-27: LGTM! Configuration correctly implements legacy proxy support.

This configuration file appropriately handles backward compatibility for environments without native lazy objects support. The framework secret is a standard Symfony test key, not a security concern.

tests/config/config.yaml (1)

16-17: LGTM! Correctly enables native lazy objects support.

The configuration changes appropriately enable native lazy objects and disable deprecated proxy class auto-generation, aligning with modern Doctrine ORM best practices.

tests/baseline-ignore (1)

4-9: LGTM! Appropriately suppresses transitional deprecation warnings.

The added baseline entries correctly suppress deprecation warnings for legacy Doctrine ORM proxy features during the transition to native lazy objects.

tests/Integration/AggregatorTest.php (2)

7-7: LGTM! Correctly imports the class for conditional logic.

The import is appropriately added to support the conditional test skipping logic.


39-41: LGTM! Conditional test skip logic is correct.

The test is appropriately skipped when native lazy objects are available, as the proxy wrapping behavior being tested is no longer relevant in that environment.

src/Services/MeilisearchService.php (2)

8-8: LGTM! Import added for native lazy objects compatibility.

The import is correctly added to support the new conditional check for Doctrine ORM's native lazy objects feature.


378-381: LGTM! Native lazy objects compatibility check implemented correctly.

The conditional logic correctly handles the transition to Doctrine ORM's native lazy objects by checking for LegacyReflectionFields existence. When native lazy objects are available, it appropriately returns $object::class directly, bypassing the proxy resolution logic.

The hierarchical approach (native lazy objects → ORM v3+ → legacy) ensures backward compatibility while leveraging newer features when available.

tests/Kernel.php (2)

10-10: LGTM! Import added for test environment compatibility.

The import is correctly added to support the conditional configuration loading based on native lazy objects availability.


33-37: LGTM! Conditional configuration loading handles Doctrine ORM compatibility correctly.

The logic properly handles the transition to native lazy objects by:

  • Loading config.yaml only when both PHP 8.4+ and LegacyReflectionFields are available (native lazy objects supported)
  • Falling back to config_old_proxy.yaml for older PHP versions or when native lazy objects aren't available

This ensures the test environment uses the appropriate Doctrine ORM configuration matching the runtime capabilities.

@norkunas
Copy link
Collaborator Author

norkunas commented Jul 8, 2025

Ffs, coderabbit commitable suggestion duplicates the whole block in CI

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/tests.yml (1)

41-72: Matrix / exclude list drift

php-version: '8.0' is excluded, yet '8.0' isn’t present in the matrix, making the exclusion a no-op and potentially confusing. Consider dropping the redundant entry (lines 68-69) or adding '8.0' back into the matrix intentionally.

Similarly, '8.4' is listed; ensure shivammathur/setup-php can actually install it (currently only nightly builds).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 934bef2 and 48697dd.

📒 Files selected for processing (1)
  • .github/workflows/tests.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/tests.yml

11-11: key "on" is duplicated in workflow. previously defined at line:3,col:1

(syntax-check)

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.40%. Comparing base (164af5a) to head (c1858f5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #390      +/-   ##
============================================
+ Coverage     88.37%   88.40%   +0.02%     
  Complexity        1        1              
============================================
  Files            20       20              
  Lines           886      888       +2     
============================================
+ Hits            783      785       +2     
  Misses          103      103              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@norkunas norkunas force-pushed the ci branch 6 times, most recently from 8fd9a02 to 8bdf75b Compare July 9, 2025 04:25
@norkunas norkunas added the skip-changelog The PR will not appear in the release changelogs label Jul 9, 2025
@norkunas norkunas changed the title Fix deprecations Fix deprecations in tests Jul 9, 2025
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you very much @norkunas

bors merge

@curquiza
Copy link
Member

bors hates me
I merge manually

@curquiza curquiza merged commit 9d7643d into meilisearch:main Jul 13, 2025
23 of 24 checks passed
@norkunas norkunas deleted the ci branch July 13, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maintenance Anything related to maintenance (CI, tests, refactoring...) skip-changelog The PR will not appear in the release changelogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests do not run
2 participants