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

Try running html5lib tests efficiently. #6963

Closed
wants to merge 5 commits into from

Conversation

desrosj
Copy link
Contributor

@desrosj desrosj commented Jul 3, 2024

Trac ticket: https://core.trac.wordpress.org/ticket/61209.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

github-actions bot commented Jul 3, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@dmsnell
Copy link
Member

dmsnell commented Aug 8, 2024

@sirreal check out this awesome work @desrosj is doing - runs the html5lib tests in a separate job and only once, instead of on every version of PHP and MySQL. should make it nicer to have the full test suite run on every change without holding up the CI process.

@desrosj desrosj marked this pull request as ready for review August 8, 2024 13:48
Copy link

github-actions bot commented Aug 8, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props desrosj, jonsurrell, dmsnell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal
Copy link
Member

sirreal commented Aug 8, 2024

This is great! At the moment, it appears to be running the tests on this branch, is that expected?

I expected it not to run because there are no changes to the relevant files.

@desrosj
Copy link
Contributor Author

desrosj commented Aug 8, 2024

It's running for this PR because I included the two relevant GitHub Action workflow files in the list that should run the tests when updated. If there are changes to the PHPUnit workflows, it's possible they could change how the html5lib tests are run, so we should run them just to confirm.

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

This seems good, thanks!

@@ -36,7 +36,7 @@ jobs:
#
test-with-mysql:
name: PHP ${{ matrix.php }}
uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk
uses: desrosj/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@try/html5lib-tests
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be updated before landing.


#
# Creates a PHPUnit test job for each PHP/MariaDB combination.
#
test-with-mariadb:
name: PHP ${{ matrix.php }}
uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk
uses: desrosj/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@try/html5lib-tests
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be updated before landing.

@dmsnell
Copy link
Member

dmsnell commented Aug 8, 2024

Can we not go ahead and run the tests on changes to every file in Core? there are connections through the WP_Token_Map and kses.php. The test suite is quite fast, executing in 1.44s on my laptop, including the PHPUnit setup time.

Seems like this wouldn't be much of a cost on the CI runners or delay PRs but could provide important early warnings that something unintentionally changed the parser.

@desrosj
Copy link
Contributor Author

desrosj commented Aug 8, 2024

an we not go ahead and run the tests on changes to every file in Core?

The test group should only run if the following files are changed or patterns matched:

  • src/wp-includes/html-api/**.php
  • tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
  • tests/phpunit/data/html5lib-tests/**.dat
  • .github/workflows/phpunit-tests.yml
  • .github/workflows/reusable-phpunit-tests-v3.yml

Any other time the workflow runs the test group will not be run. They are running for this PR because the last two files in that list are being updated to support testing that specific group separately. Are you seeing something indicating differently @dmsnell?

@dmsnell
Copy link
Member

dmsnell commented Aug 8, 2024

@desrosj exactly. my point is that I don't understand why we're limiting it to running only when files in the wp-includes/html-api/ directory change. For one, other files in Core can affect the parser behavior, for two, the tests are really cheap to run. Is there a compelling reason to avoid running them on changes to any Core files?

@desrosj
Copy link
Contributor Author

desrosj commented Aug 8, 2024

Ah! Apologies, I misread your comment. This was based on the description on the Trac ticket and the original attempt to solve this in #6546.

@jorbin do you recall any context to that detail?

@sirreal
Copy link
Member

sirreal commented Aug 9, 2024

The reason these tests were excluded from the main test run is mentioned on the ticket:

The html-api-html5lib-tests group of tests is excluded by default since it contains many intentionally and dynamically skipped tests (see discussion in #60227 for why this is the best route for these tests).

These tests currently skip 568 tests:

OK, but incomplete, skipped, or risky tests!
Tests: 1498, Assertions: 930, Skipped: 568.

The amount of skipped tests were some of the main concerns in the original work: https://core.trac.wordpress.org/ticket/60227

The skipped tests may come down a bit more and at some point we may be able to hardcode lists of tests that we do not plan to support to omit them entirely (without skipping).

We can always revisit the decision and consider running these tests along with the rest of the tests.

@sirreal
Copy link
Member

sirreal commented Sep 3, 2024

I'd be very happy to see this move ahead, is there any way I can help?

Anecdotally, some (minor) failures in the html5lib tests slipped into trunk recently. It wasn't a big problem and has already been fixed, but this work would have prevented that from happening.

@desrosj
Copy link
Contributor Author

desrosj commented Oct 21, 2024

It looks like today there are 421 skipped tests. Great work getting that number way down, everyone! The total counts for reference are Tests: 1508, Assertions: 1087, Skipped: 421..

I've gone and opened #7602, which is an alternative approach. Core-59251 added the ability to run only a specific test group, so the new PR takes advantage of that. I think I like the simplicity of that approach instead with the trade off of running the tests more frequently. With the numbers above, the group is now at a ~70% run rate.

@desrosj
Copy link
Contributor Author

desrosj commented Dec 17, 2024

Going to close this out in favor of #7602.

@desrosj desrosj closed this Dec 17, 2024
@desrosj desrosj deleted the try/html5lib-tests branch December 17, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants