Skip to content
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

Make performanceHints and Adminonly run in coverage GH action #6896

Conversation

MathieuLamiot
Copy link
Contributor

@MathieuLamiot MathieuLamiot commented Aug 22, 2024

Description

Fixes #6889

Make performanceHints and Adminonly run in coverage GH action
Add coverage variations for unit, integartion, performanceHints and Adminonly test commands

To showcase the change:

Documentation

User documentation

composer "run-tests" commands are modified a bit so that AdminOnly and PerformanceHints are running as part of the coverage GH action.

Technical documentation

For unit, integration general, adminonly and performanceHints, there are now vazriations that do the same but also compute coverage.
A new composer command run those 4 variations to get the coverage. This is now used in the coverage GH action.

Type of change

Delete options that are not relevant.

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).

New dependencies

NA

Risks

  • The CI will be a bit slower as running more tests with coverage takes longer.
  • The AdminOnly group now throws 16 warnings when running, while I could not see them before. But I think they are legit warnings, so I don't think this is a regression from this change. For those warnings, the "uses" seems to reference files that don't exist, hence the warning I think:
here were 16 warnings:

1) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_AddRegenerateMenuItem::testShouldDoExpected with data set "testShouldDoNothingWhenNoCap" (false, true, true, true, '/wp-admin/', false)
"@uses \WP_Rocket\Tests\CriticalPath\Admin\Admin::add_regenerate_menu_item" is invalid

2) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_AddRegenerateMenuItem::testShouldDoExpected with data set "testShouldDoNothingWhenNotAdmin" (true, false, true, true, '/wp-admin/', false)
"@uses \WP_Rocket\Tests\CriticalPath\Admin\Admin::add_regenerate_menu_item" is invalid

3) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_AddRegenerateMenuItem::testShouldDoExpected with data set "testShouldDoNothingWhenOptionDisabled" (true, true, false, true, '/wp-admin/', false)
"@uses \WP_Rocket\Tests\CriticalPath\Admin\Admin::add_regenerate_menu_item" is invalid

4) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_AddRegenerateMenuItem::testShouldDoExpected with data set "testShouldDoNothingWhenFilterDisabled" (true, true, true, false, '/wp-admin/', false)
"@uses \WP_Rocket\Tests\CriticalPath\Admin\Admin::add_regenerate_menu_item" is invalid

5) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_AddRegenerateMenuItem::testShouldDoExpected with data set "testShouldAddMenuItem" (true, true, true, true, '/wp-admin/', stdClass Object (...))
"@uses \WP_Rocket\Tests\CriticalPath\Admin\Admin::add_regenerate_menu_item" is invalid

6) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testCallbackIsRegistered
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

7) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldBailOutAtDisabledAsyncCSS" (array(true, array(0)), array(true, 'wp_send_json_error'))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

8) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldBailOutWithoutRocketPermissions" (array(true, array(1), false), array(true, 'wp_send_json_error'))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

9) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldBailOutWithoutCriticalCSSPermissions" (array(true, array(1), true, false), array(true, 'wp_send_json_error'))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

10) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldStopNoDataInTransient" (array(true, array(1), true, true, array(), false), array(false, true, 'wp_send_json_success', array('cpcss_complete')))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

11) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldRunSingleDataInTransientWithProcessGenerateReturnWPError" (array(true, array(1), true, true, array(array('https://example.org/', 'front_page.css', false, false, 0, 'home')), array(true, 404, false, 'cpcss_generation_failed', 'Critical CSS for home not generated.', array('failed')), array('Critical CSS for home not generated.', array(1, array(array(array(array('Critical CSS for home not generated.', false)))))), true), array(false, true, 'wp_send_json_success', array('cpcss_complete')))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

12) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldRunSingleDataInTransientWithProcessGenerateReturnSuccess" (array(true, array(1), true, true, array(array('https://example.org/', 'front_page.css', false, false, 0, 'home')), array(200, true, 'cpcss_generation_successful', 'Critical CSS for home generated.', array('complete', '.critical_path { color: red; }')), array(array(1, array(array(array(array('Critical CSS for home generated.', true)))))), true), array(false, true, 'wp_send_json_success', array('cpcss_complete')))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

13) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldRunSingleDataInTransientWithProcessGenerateReturnFailed" (array(true, array(1), true, true, array(array('https://example.org/', 'front_page.css', false, false, 0, 'home')), array(404, false, 'cpcss_generation_failed', 'Critical CSS for home not generated.', array('failed')), array(array(1, array(array(array(array('Critical CSS for home not generated.', false)))))), true), array(false, true, 'wp_send_json_success', array('cpcss_complete'), array()))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

14) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldRunSingleDataInTransientWithProcessGenerateReturnTimeout" (array(true, array(1), true, true, array(array('https://example.org/', 'front_page.css', false, false, 11, 'home')), array(200, true, 'cpcss_generation_pending', 'Critical CSS for home in progress.', array('pending')), true, array()), array(false, true, true, true, 'wp_send_json_success', array('cpcss_complete'), array()))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

15) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldRunSingleDataInTransientWithProcessGeneratePending" (array(true, array(1), true, true, array(array('https://example.org/', 'front_page.css', false, false, 0, 'home')), array(200, true, 'cpcss_generation_pending', 'Critical CSS for home in progress.', array('pending'))), array(false, false, 'wp_send_json_success', array('cpcss_running'), array(array('https://example.org/', 'front_page.css', false, false, 1, 'home'))))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

16) WP_Rocket\Tests\Integration\inc\Engine\CriticalPath\Admin\Subscriber\Test_CpcssHeartbeat::testShouldGenerateCPCSS with data set "testShouldMultipleDataInTransientWithCpcssRunning" (array(true, array(1), true, true, array(array('https://example.org/', 'front_page.css', false, false, 0, 'home'), array('https://example.org/category/', 'category.css', false, false, 0)), array(404, false, 'cpcss_generation_failed', 'Critical CSS for https://exam...rated./', array('failed')), array(array(2, array(array(array(array('Critical CSS for https://exam...rated./', false)))))), true), array(false, false, true, 'wp_send_json_success', array('cpcss_running'), array(array('https://example.org/category/', 'category.css', false, false, 0))))
"@uses \WP_Rocket\Engine\CriticalPath\DataManager::get_job_details" is invalid

--

Checklists

Feature validation

  • I validated all the Acceptance Criteria. If possible, provide sreenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.

Documentation

  • I prepared the user documentation for the feature/enhancement and shared it in the PR or the GitHub issue.
  • The user documentation covers new/changed entry points (endpoints, WP hooks, configuration files, ...).
  • I prepared the technical documentation if needed, and shared it in the PR or the GitHub issue.

Code style

  • I wrote self-explanatory code about what it does.
  • I wrote comments to explain why it does it.
  • I named variables and functions explicitely.
  • I protected entry points against unexpected inputs.
  • I did not introduce unecessary complexity.
  • I listed the introduced external dependencies explicitely on the PR.
  • I validated the repo-specific guidelines from CONTRIBUTING.md.

Observability

  • I handled errors when needed.
  •  I wrote user-facing messages that are understandable and provide actionable feedbacks.
  • I prepared ways to observe the implemented system (logs, data, etc.).

Risks

  •  I explicitely mentioned performance risks in the PR.
  • I explicitely mentioned security risks in the PR.

Add coverage variations for unit, integartion, performanceHints and Adminonly test commands
@MathieuLamiot MathieuLamiot self-assigned this Aug 22, 2024
Copy link

codacy-production bot commented Aug 22, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for e40643e1 (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e40643e) Report Missing Report Missing Report Missing
Head commit (abe531e) 37544 9455 25.18%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6896) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@MathieuLamiot MathieuLamiot requested a review from a team August 22, 2024 18:52
@remyperona
Copy link
Contributor

I fixed the annotations

@remyperona remyperona added this pull request to the merge queue Aug 22, 2024
Merged via the queue into develop with commit 6c03904 Aug 22, 2024
12 checks passed
@remyperona remyperona deleted the enhancement/6889-add-adminonly-and-performancehints-to-coverage branch August 22, 2024 21:45
@remyperona remyperona added devops type: enhancement Improvements that slightly enhance existing functionality and are fast to implement labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Codacy test result with specific group test
2 participants