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

Run PHPUnit jobs across multiple PHP versions #46510

Merged
merged 79 commits into from
Jan 16, 2023

Conversation

anton-vlasenko
Copy link
Contributor

@anton-vlasenko anton-vlasenko commented Dec 13, 2022

What?

This PR:

  • Removes PHP related checks from the Unit Tests Github CI job;
  • Adds 2 new Github CI Jobs: PHPUnit Tests and PHP Coding Standards (the same way it's implemented in Core);
  • brings ability to run PHPUnit tests on all PHP versions (5.6 through 8.2) using the CI jobs;
  • shows code style errors on the "Files changed" tab (same as Core);
  • Fixes an issue with wp-env as it used non-optimal PHPUnit versions on PHP 7.3 and 7.4 (props to @jrfnl);

Why?

Gutenberg should support the same PHP versions as Core.

How?

This PR adds 2 new Github CI Jobs: PHPUnit Tests and PHP Coding Standards.
These PHP CI jobs were backported from Core to ensure that we test Gutenberg PRs in the same fashion.

Testing Instructions

  1. Make sure that the CI jobs run without errors.
  2. Observe there are PHP_VERSION (multisite) on ubuntu-latest jobs for each supported PHP version (5.6 through 8.2).

Props @jrfnl , @dmsnell , @anton-vlasenko

@github-actions
Copy link

github-actions bot commented Dec 13, 2022

Size Change: 0 B

Total Size: 1.33 MB

ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 993 B
build/annotations/index.min.js 2.78 kB
build/api-fetch/index.min.js 2.27 kB
build/autop/index.min.js 2.15 kB
build/blob/index.min.js 483 B
build/block-directory/index.min.js 7.16 kB
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 3.59 kB
build/block-editor/content.css 3.59 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-editor/index.min.js 184 kB
build/block-editor/style-rtl.css 14.2 kB
build/block-editor/style.css 14.2 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 138 B
build/block-library/blocks/audio/theme.css 138 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 84 B
build/block-library/blocks/avatar/style.css 84 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 485 B
build/block-library/blocks/button/editor.css 485 B
build/block-library/blocks/button/style-rtl.css 532 B
build/block-library/blocks/button/style.css 532 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 100 B
build/block-library/blocks/categories/style.css 100 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 406 B
build/block-library/blocks/columns/style.css 406 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 612 B
build/block-library/blocks/cover/editor.css 613 B
build/block-library/blocks/cover/style-rtl.css 1.57 kB
build/block-library/blocks/cover/style.css 1.56 kB
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 138 B
build/block-library/blocks/embed/theme.css 138 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 253 B
build/block-library/blocks/file/style.css 254 B
build/block-library/blocks/file/view.min.js 353 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 984 B
build/block-library/blocks/gallery/editor.css 988 B
build/block-library/blocks/gallery/style-rtl.css 1.55 kB
build/block-library/blocks/gallery/style.css 1.55 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 654 B
build/block-library/blocks/group/editor.css 654 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 76 B
build/block-library/blocks/heading/style.css 76 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 829 B
build/block-library/blocks/image/editor.css 828 B
build/block-library/blocks/image/style-rtl.css 627 B
build/block-library/blocks/image/style.css 630 B
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/latest-comments/style-rtl.css 298 B
build/block-library/blocks/latest-comments/style.css 298 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 507 B
build/block-library/blocks/media-text/style.css 505 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 716 B
build/block-library/blocks/navigation-link/editor.css 715 B
build/block-library/blocks/navigation-link/style-rtl.css 115 B
build/block-library/blocks/navigation-link/style.css 115 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation/editor-rtl.css 2.13 kB
build/block-library/blocks/navigation/editor.css 2.14 kB
build/block-library/blocks/navigation/style-rtl.css 2.22 kB
build/block-library/blocks/navigation/style.css 2.2 kB
build/block-library/blocks/navigation/view-modal.min.js 2.81 kB
build/block-library/blocks/navigation/view.min.js 447 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 376 B
build/block-library/blocks/page-list/editor.css 376 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 174 B
build/block-library/blocks/paragraph/editor.css 174 B
build/block-library/blocks/paragraph/style-rtl.css 279 B
build/block-library/blocks/paragraph/style.css 281 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 501 B
build/block-library/blocks/post-comments-form/style.css 501 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 586 B
build/block-library/blocks/post-featured-image/editor.css 584 B
build/block-library/blocks/post-featured-image/style-rtl.css 318 B
build/block-library/blocks/post-featured-image/style.css 318 B
build/block-library/blocks/post-navigation-link/style-rtl.css 153 B
build/block-library/blocks/post-navigation-link/style.css 153 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 282 B
build/block-library/blocks/post-template/style.css 282 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 326 B
build/block-library/blocks/pullquote/style.css 325 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 440 B
build/block-library/blocks/query/editor.css 440 B
build/block-library/blocks/quote/style-rtl.css 213 B
build/block-library/blocks/quote/style.css 213 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 409 B
build/block-library/blocks/search/style.css 406 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 490 B
build/block-library/blocks/site-logo/editor.css 490 B
build/block-library/blocks/site-logo/style-rtl.css 203 B
build/block-library/blocks/site-logo/style.css 203 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 674 B
build/block-library/blocks/social-links/editor.css 673 B
build/block-library/blocks/social-links/style-rtl.css 1.4 kB
build/block-library/blocks/social-links/style.css 1.39 kB
build/block-library/blocks/spacer/editor-rtl.css 332 B
build/block-library/blocks/spacer/editor.css 332 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 457 B
build/block-library/blocks/table/editor.css 457 B
build/block-library/blocks/table/style-rtl.css 651 B
build/block-library/blocks/table/style.css 650 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 404 B
build/block-library/blocks/template-part/editor.css 404 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 691 B
build/block-library/blocks/video/editor.css 694 B
build/block-library/blocks/video/style-rtl.css 179 B
build/block-library/blocks/video/style.css 179 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 162 B
build/block-library/classic.css 162 B
build/block-library/common-rtl.css 1.05 kB
build/block-library/common.css 1.05 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 11.7 kB
build/block-library/editor.css 11.7 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 199 kB
build/block-library/reset-rtl.css 478 B
build/block-library/reset.css 478 B
build/block-library/style-rtl.css 12.4 kB
build/block-library/style.css 12.4 kB
build/block-library/theme-rtl.css 698 B
build/block-library/theme.css 703 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.83 kB
build/blocks/index.min.js 50.4 kB
build/components/index.min.js 203 kB
build/components/style-rtl.css 11.6 kB
build/components/style.css 11.6 kB
build/compose/index.min.js 12.3 kB
build/core-data/index.min.js 15.9 kB
build/customize-widgets/index.min.js 11.7 kB
build/customize-widgets/style-rtl.css 1.41 kB
build/customize-widgets/style.css 1.41 kB
build/data-controls/index.min.js 663 B
build/data/index.min.js 7.69 kB
build/date/index.min.js 32.1 kB
build/deprecated/index.min.js 518 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.71 kB
build/edit-navigation/index.min.js 16.2 kB
build/edit-navigation/style-rtl.css 4.12 kB
build/edit-navigation/style.css 4.13 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-post/index.min.js 34.4 kB
build/edit-post/style-rtl.css 7.45 kB
build/edit-post/style.css 7.44 kB
build/edit-site/index.min.js 66.4 kB
build/edit-site/style-rtl.css 9.31 kB
build/edit-site/style.css 9.3 kB
build/edit-widgets/index.min.js 16.8 kB
build/edit-widgets/style-rtl.css 4.46 kB
build/edit-widgets/style.css 4.47 kB
build/editor/index.min.js 44.1 kB
build/editor/style-rtl.css 3.69 kB
build/editor/style.css 3.68 kB
build/element/index.min.js 4.93 kB
build/escape-html/index.min.js 548 B
build/experiments/index.min.js 882 B
build/format-library/index.min.js 7.2 kB
build/format-library/style-rtl.css 598 B
build/format-library/style.css 597 B
build/hooks/index.min.js 1.66 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.79 kB
build/is-shallow-equal/index.min.js 535 B
build/keyboard-shortcuts/index.min.js 1.79 kB
build/keycodes/index.min.js 1.88 kB
build/list-reusable-blocks/index.min.js 2.14 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.99 kB
build/notices/index.min.js 977 B
build/plugins/index.min.js 1.95 kB
build/preferences-persistence/index.min.js 2.23 kB
build/preferences/index.min.js 1.35 kB
build/primitives/index.min.js 960 B
build/priority-queue/index.min.js 1.59 kB
build/react-i18n/index.min.js 702 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.75 kB
build/reusable-blocks/index.min.js 2.26 kB
build/reusable-blocks/style-rtl.css 283 B
build/reusable-blocks/style.css 283 B
build/rich-text/index.min.js 10.8 kB
build/server-side-render/index.min.js 2.09 kB
build/shortcode/index.min.js 1.52 kB
build/style-engine/index.min.js 1.53 kB
build/token-list/index.min.js 650 B
build/url/index.min.js 3.69 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 1.09 kB
build/warning/index.min.js 280 B
build/widgets/index.min.js 7.31 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.06 kB

compressed-size-action

@anton-vlasenko anton-vlasenko changed the title Ensure parity between Core and Gutenberg PHP CI jobs Ensure parity with Core's PHP CI jobs Dec 15, 2022
anton-vlasenko referenced this pull request Dec 15, 2022
… document

It can be helpful to track a location in an HTML document while updates
are being made to it such that we can instruct the Tag Processor to seek
to the location of one of the bookmarks.

In this patch we're introducing a bookmarks system to do just that.
Bookmarks are referenced by name and handled internally by a tracking
object which will follow all updates made to the document. It will be
possible to rewind or jump around a document by setting a bookmark and
then calling `seek( $bookmark_name )` to move there.

Co-authored-by: Adam Zielinski <adam@adamziel.com>
Co-authored-by: Dennis Snell <dennis.snell@automattic.com>
@dmsnell dmsnell force-pushed the fix/parity-with-cores-php-ci-jobs branch from 78d42bb to fd9a0a2 Compare December 15, 2022 23:32
@anton-vlasenko anton-vlasenko force-pushed the fix/parity-with-cores-php-ci-jobs branch from fd9a0a2 to 7fe4a56 Compare December 16, 2022 07:17
@anton-vlasenko anton-vlasenko changed the title Ensure parity with Core's PHP CI jobs Ensure PHPUnit tests run on all PHP versions Dec 19, 2022
@anton-vlasenko anton-vlasenko changed the title Ensure PHPUnit tests run on all PHP versions Ensure PHP CI jobs run PHPUnit tests run on all PHP versions Dec 19, 2022
@@ -17,6 +17,9 @@ yarn.lock
/composer.lock

.cache
!/.cache/
/.cache/**
!/.cache/.gitkeep
Copy link
Contributor Author

@anton-vlasenko anton-vlasenko Dec 19, 2022

Choose a reason for hiding this comment

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

This ignores all .cache/.gitkeep files but /.cache/.gitkeep.
The /.cache/ folder is needed for the PHP Coding Standards CI job.

Copy link
Member

Choose a reason for hiding this comment

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

This deserves an explanatory comment inline as it's going to be really hard to find this PR comment when someone is trying to understand why the .cache directory is so zig-zagged here. Can we add the explanation, and include why a simpler formulation of the rules cannot provide what we need?

Is it not possible to have PHP Coding Standards use another directory? What is the reason for its use of .cache here anyway?

Copy link
Member

Choose a reason for hiding this comment

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

I also now see that we're telling git to keep the .cache directory, which seems surprising to me. why do we need to do this?

if this weren't .gitkeep'd then this surprising change to .gitignore presumably would also not be necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for zig-zagging is the following:

It is not possible to re-include a file if a parent directory of that file is excluded. 

This deserves an explanatory comment inline as it's going to be really hard to find this PR comment when someone is trying to understand why the .cache directory is so zig-zagged here.

I agree. Fixed in 89a4d738e13c7d6ff51d54cfa2477eb0c713c67b

Currently, Gutenberg ignores all .cache folders (regardless of their location).
For compatibility reasons, these folders should still be ignored, while allowing the /.cache folder (in the root).
I haven't been able to come up with a simpler pattern that would allow that.

if this weren't .gitkeep'd then this surprising change to .gitignore presumably would also not be necessary

Git doesn't allow to commit empty folders. If it did, I would commit an empty folder.

Is it not possible to have PHP Coding Standards use another directory? What is the reason for its use of .cache here anyway?

Yes, it's possible, but I don't understand what's wrong with /.cache.

A similar Core job uses a folder with the same name - .cache.

Copy link
Member

Choose a reason for hiding this comment

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

sure but why do we need or want to commit an empty directory?

Copy link
Member

@jrfnl jrfnl Dec 20, 2022

Choose a reason for hiding this comment

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

Because PHPCS expects the directory to which to write the cache file to exist. It will not create it.

So if the ruleset dictates that the cache file should be written to the .cache directory, that directory must exist as otherwise PHPCS will error out.
You could, of course, choose to just let the cache file be written to the system temp directory or to the project root...

Note: the PHPCS cache file itself should definitely be gitignored.

Copy link
Member

Choose a reason for hiding this comment

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

my suspicion was that it was something like this, but if that's the case, that doesn't explain why it needs to be in git, it merely notes that the directory needs to be present when running the linter.

if the entire purpose of coercing git to include an empty directory in the repo is so that a linter can run in CI then it would be simpler to create the directory when running the CI script with mkdir -p .cache or the equivalent.

Copy link
Member

Choose a reason for hiding this comment

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

Well, that depends. If the ruleset contains the cache directive, local CS runs will also expect the directory.

If the caching is only used in CI, I agree, a mkdir would suffice, but then again, why would the caching be limited to CI ?

Also note - in most projects which use a .cache directory for the PHPCS cache placement, it is generally because they want to cache those files in CI and Travis (yes, that's the completely outdated reason), didn't allow for caching individual files, only allowed for caching directories, which is why people resorted to having a .cache directory for this.

GH Actions, however, does allow for caching individual files, so I honestly don't know why that .cache directory is still used, especially for projects setting this up from scratch. (I can understand people not having revisited their previous reason for setting it up when converting from Travis to GHA, but that's not the case here)

# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
Copy link
Member

Choose a reason for hiding this comment

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

Can we get an explanation of why we want to clear the cache once a week?
Generally time-based caches are useful in rare and somewhat emergency situations.

What is the reason we can't use a content-based cache?
Also do we know we need the cache? What do we expect it to provide for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This cache is both content and time-based.

hashFiles('**/composer.json', 'phpcs.xml.dist')

ensures that the cache key is content-based.

Also do we know we need the cache? What do we expect it to provide for us?

The main benefit of using the cache is to speed up the CI jobs.

Copy link
Member

Choose a reason for hiding this comment

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

What have you measured as the speedup in the CI jobs system?

Copy link
Contributor Author

@anton-vlasenko anton-vlasenko Dec 20, 2022

Choose a reason for hiding this comment

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

In my tests,

phpcs -n --report-full 

takes about 12 seconds when the cache is disabled and 0 seconds (that's what GitHub shows) when the cache is enabled.
As the quantity of .php files in the project is growing, this difference will only increase over time.

Copy link
Member

Choose a reason for hiding this comment

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

hm. what if we introduced this first without the cache? in the grander scheme of all the test suites 12s is a drop in the bucket but the cache is going to likely create a non-trivial amount of headache at the point it causes problems in a PR.

I don't think these tests are going to be the slowest workflow suite, which means they aren't in the hot path, and if we merge first without the cache then if we think one is truly warranted then we can make a PR and gather a statistical measurement to determine if, when put into the system with 1700 open branches and lots of CI activity, if it still makes 12s of an improvement and if we think that's worth the additional complexity

Copy link
Member

Choose a reason for hiding this comment

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

Can we get an explanation of why we want to clear the cache once a week?
What is the reason we can't use a content-based cache?

Without having looked at the implementation in this particular workflow...

  • Caches in GitHub Actions work differently than people often expect from other CI systems.
  • A cache in GHA is created based on a key and NEVER updated.
  • The only way to vacate the cache is to create a new cache with a new key.

So, for caches where the key doesn't change often, the cache tends to go more and more out of date over time. Adding a time based factor to the key helps to vacate the cache regularly.

Also see: ramsey/composer-install#234

hm. what if we introduced this first without the cache?

In case it would be decided to go that way, I would strongly recommend adding the --no-cache CLI argument to the PHPCS command in GHA.
As the cache directive is in the ruleset, PHPCS would otherwise needlessly create the cache file from scratch each time, which has a significant impact on the runtime of PHPCS due to the file-write operations.
As CLI args overrule the ruleset, adding no-cache should already speed up the CS run.

# It must be removed before running the tests.
- name: Remove incompatible Composer packages
if: ${{ matrix.php < '7.2' }}
run: composer remove spatie/phpunit-watcher --dev --no-update
Copy link
Member

Choose a reason for hiding this comment

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

if this breaks in supported PHP versions, why not remove the dependency altogether? I'm worried about the disconnect between requiring this package and having this line in the workflow YML. best case scenario is that when this dependency is no longer required, we'll still be running this step, which is benign, but also is going to confuse someone why it's there.

is there a way to have composer tell us which packages are not compatible? or should we file a bug report with spatie/phpunit-watch to have that project list a minimum version if one is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if this breaks in supported PHP versions, why not remove the dependency altogether?

This is because spatie/phpunit-watcher is required by the npm run test:php:watch command.
Thus it cannot be simply removed.
I was going to create a new GB issue to discuss the possibility of replacing it with a similar package that supports PHP < 7.2 (if that substitute package exists).

is there a way to have composer tell us which packages are not compatible?

Yes, composer already does that. It knows that this package is not compatible with PHP < 7.2 and refuses to install it if the current PHP version is lower than 7.2. So it should be removed before installing other packages (otherwise composer install fails).

or should we file a bug report with spatie/phpunit-watch to have that project list a minimum version if one is missing?

No, it's not missing. https://github.com/spatie/phpunit-watcher/blob/master/composer.json#L19

Copy link
Member

@dmsnell dmsnell Dec 19, 2022

Choose a reason for hiding this comment

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

Yes, composer already does that. It knows that this package is not compatible with PHP < 7.2 and refuses to install it if the current PHP version is lower than 7.2. So it should be removed before installing other packages (otherwise composer install fails).

What I meant was that maybe we can avoid hard-coding a specific dependency as we've done here. It looks like if we spit out the tree format of composer show we can get that information, and then process it with a small script.

<?php

require 'vendor/autoload.php';

use Composer\Semver\Semver;

$PHP_VERSION = empty( getenv( 'PHP_VERSION' ) ) ? phpversion() : getenv( 'PHP_VERSION' );
$tree = json_decode( file_get_contents( 'php://stdin' ) );

function works_with_php_version( $version, $package ) {
	foreach ( $package->requires as $dep ) {
		if ( 'php' === $dep->name && ! Semver::satisfies( $version, $dep->version ) ) {
			//echo "Bailing on {$package->name} because of {$dep->version}" . PHP_EOL;
			return false;
		}

		if ( ! empty( $dep->requires ) && false === works_with_php_version( $version, $dep ) ) {
			return false;
		}
	}

	return true;
}

$unsupported = array();
foreach ( $tree->installed as $package ) {
	if ( ! works_with_php_version( $PHP_VERSION, $package ) ) {
		$unsupported[] = $package->name;
	}
}

echo implode( ',', $unsupported );

Invoked as composer show --tree --format=json | php php-supported.php this will spit out a list of packages that have dependencies which aren't supported on the running PHP version, or the version set in PHP_VERSION if such an ENV is set.

But it also includes another package not listed, and to the best of my ability to double-check it, it's right according to the listed minimum versions (when I set PHP_VERSION=5.6 and run it).

spatie/phpunit-watcher,yoast/phpunit-polyfills

While maybe someone registered the wrong minimum version, or we simply haven't hit the part that breaks yet, this is why I think it'd be good at least to explore determine this through inspecting the package definitions. The list will undoubtedly change more rapidly than we come around to update it.

Edit: I should have noted that Semver is also already pulled in to our composer deps.

Copy link
Contributor Author

@anton-vlasenko anton-vlasenko Dec 20, 2022

Choose a reason for hiding this comment

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

Thanks for sharing the script.

we can avoid hard-coding a specific dependency as we've done here

Out of all installed Composer packages, this is the only package that gives trouble.
I didn't see the need to write a script for detecting such packages when I was working on the CI job, as this was the only "problematic" package.

If someone adds a composer package that is not compatible with PHP 5.6 or another Core-supported PHP version, I'd prefer that the author of that PR would be able to see the error (i.e., composer install should fail) instead of removing or hiding such packages with the help of a script.
Gutenberg should support the same PHP versions as Core.

If we had proper CI jobs before, spatie/phpunit-watcher wouldn't be merged to the repo (that's my assumption).
Removing spatie/phpunit-watcher before running PHPUnit tests is a workaround until that package is removed or replaced with another package that supports PHP 5.6.

yoast/phpunit-polyfills - I'm not sure I understand why it isn't compatible with PHP 5.6.
Please see this Packagist page:
https://packagist.org/packages/yoast/phpunit-polyfills
Screenshot 2022-12-20 at 11 58 26

Copy link
Member

Choose a reason for hiding this comment

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

why it isn't compatible with PHP 5.6.

the dependencies of its dependencies state a minimum required version above 5.6. like I wrote above though, we may simply have not run into the places where it will break, or the package authors may have incorrectly listed their requirements.

if you run composer show --tree you will see where it comes in. ironically it's through phpunit so maybe we could safely eliminate that dependency chain as a given since we're already running.

If someone adds a composer package that is not compatible with PHP 5.6 or another Core-supported PHP version, I'd prefer that the author of that PR would be able to see the error (i.e., composer install should fail) instead of removing or hiding such packages with the help of a script.

I totally agree! that's why I asked about removing the package. do we know if anyone would even miss the npm run test:php:watch scripts? I wouldn't, because I don't use that due to the way it obscures the underlying test runner and won't let me do what I want to do with phpunit (and it doesn't even run when I try, immediately fails with an error).

it's not the worst thing to have this hard-coded exception in the code, but I'd love to do all we can to avoid it if possible. it makes me worry that this code will end up permanent in there and we'll lose our memory of why, and then when something is broken or needing maintenance it will make that work difficult, particularly if we end up removing the referenced package.

alternatively, the worst scenario I see which seems to be quite common is that we have all this special-casing hidden deep in our layers of build scripts and then something breaks and there's no linkage between the failure and the code in the build and testing scripts that leads someone to find the problem.

anyway that's more words than it warrants, but maybe we just ask if we can get rid of npm run test:php:watch and not have to deal with this.

Copy link
Member

Choose a reason for hiding this comment

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

@jrfnl thanks. I'm sure I'm wrong; I must be wrong. but I like being shown how and why I'm wrong, so if you think the script is wrong, well it's right there and you can point it out.

I'm clearly not an expert on this, but I am looking at the output of composer show --tree and for yoast/phpunit-polyfills it demonstrably lists dependencies for phpunit/phpunit which don't list 5.6 support.

as I noted above, it might make sense to special-case phpunit and omit checking its dependencies, given that we are already assuming the presence of phpunit, but what is wrong in the logic in the script?

I'm not just talking about the dependencies we currently have, but I'm wanting to make sure that when those dependencies change that we don't have to remember that this code exists, that it exists here, and remember to update it properly - not a good track record with relying that much on manual process.

yoast/phpunit-polyfills 1.0.4 Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests
├──php >=5.4
└──phpunit/phpunit ^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0
   ├──doctrine/instantiator ^1.3.1
   │  └──php ^7.1 || ^8.0
   ├──ext-dom *
   ├──ext-json *
   ├──ext-libxml *
   ├──ext-mbstring *
   │  └──php >=7.1
   ├──ext-xml *
   ├──ext-xmlwriter *
   ├──myclabs/deep-copy ^1.10.1
   │  └──php ^7.1 || ^8.0

here's the truncated part of composer show --tree showing some of the dependencies not listing PHP 5.6 support. Maybe I'm overlooking that something is optional, or that there's a way to know if these will be supported. I'm definitely relying on package maintainers to list the correct support on their packages.

Copy link
Member

Choose a reason for hiding this comment

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

I'm sure I'm wrong; I must be wrong. but I like being shown how and why I'm wrong, so if you think the script is wrong, well it's right there and you can point it out.

@dmsnell Sorry, I hadn't looked at the script before - I just responded as the author of the PHPUnit Polyfills.

Looking at the script now, IMO, it is pretty clear where the error is.

  1. The script will only work after a composer install has been run (as it needs vendor/autoload).
  2. It will then analyse based on the dependencies which have been installed, which is highly dependent on which PHP version was used to run composer install (as there is no composer.lock file exactly for that reason: to allow for installing the correct PHPUnit version for each PHP version).

So... say I run composer install on PHP 8.0, it will install PHPUnit 9.x with the associated dependencies. Neither PHPUnit 9.x, nor any of its dependencies will be compatible with PHP 5.6.

No surprise then that the Polyfills will be flagged as incompatible, but that's not a problem with the polyfills, but a problem with a logic fallacy on which the script is based....

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I hadn't looked at the script before - I just responded as the author of the PHPUnit Polyfills.

I definitely wish I were smart enough to not have to read the questions I respond to 🙃

No surprise then that the Polyfills will be flagged as incompatible, but that's not a problem with the polyfills, but a problem with a logic fallacy on which the script is based....

If I understand what you're saying though it seems to imply the script is correct, the logic in the script is correct, and I simply made the mistake of running it after installing packages with a newer version of PHP, something which wouldn't happen in the CI run.

So I think in a way by trying to show that the script is flawed you actually confirmed it's the right logic, because my goal is to determine programmatically what needs to be removed based on the running script in a way that lets us avoid depending on people manually doing all the right steps.

However…

highly dependent on which PHP version was used to run composer install…So... say I run composer install on PHP 8.0, it will install PHPUnit 9.x with the associated dependencies. Neither PHPUnit 9.x, nor any of its dependencies will be compatible with PHP 5.6.

When I tried doing this I actually got the same result with PHP 5.6 where the composer show --tree output still declares yoast/phpunit-polyfills as unsupported, with identical output as listed above.

What I did was:

  • clone the Gutenberg repo in a docker run php:5.6 environment
  • install Composer through their script
  • run rm composer.lock && rm -rf vendor && git reset --hard to make sure that nothing in vendor was stale
  • run ./composer.phar install
  • run ./composer.phar show --list
~$ php --version
PHP 5.6.40 (cli) (built: Jan 23 2019 00:04:26)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
~$ ./composer.phar --version
Composer version 2.2.18 2022-08-20 11:33:38

In this case though my script failed to run because of something in symphony/polyfill that depended on newer PHP versions. After manually removing spatie/phpunit-watcher it progressed further, but still failed to execute the autoloader due to an issue with unsupported strict_types inside the phpunit's Framework/Assets/Functions.php module.

Maybe my version of Composer is too new? To try and see if this could be the case I tried against with Composer 1.6 from the beginning of 2018 but its output is still the same, still showing phpunit/phpunit pulling in dependencies that rely on PHP 7.1 and newer.

So I guess the current state is that if we want to do this programmatically the script is telling us the information from the installed packages as it should, but we need to modify it to read the Semver dependencies directly instead of through the autoloader, since that fails on PHP 5.6, and also ensure that we're running it on the right set of installed packages.

require 'phar://composer.phar/vendor/composer/semver/src/Constraint/ConstraintInterface.php';
require 'phar://composer.phar/vendor/composer/semver/src/Constraint/MultiConstraint.php';
require 'phar://composer.phar/vendor/composer/semver/src/Constraint/Constraint.php';
require 'phar://composer.phar/vendor/composer/semver/src/Semver.php';
require 'phar://composer.phar/vendor/composer/semver/src/VersionParser.php';

use Composer\Semver\Semver;

$PHP_VERSION = empty( getenv( 'PHP_VERSION' ) ) ? phpversion() : getenv( 'PHP_VERSION' );
$tree = json_decode( file_get_contents( 'php://stdin' ) );

function works_with_php_version( $version, $package ) {
	foreach ( $package->requires as $dep ) {
		if ( 'php' === $dep->name && ! Semver::satisfies( $version, $dep->version ) ) {
			return false;
		}

		if ( ! empty( $dep->requires ) && false === works_with_php_version( $version, $dep ) ) {
			return false;
		}
	}

	return true;
}

$unsupported = array();
foreach ( $tree->installed as $package ) {
	if ( ! works_with_php_version( $PHP_VERSION, $package ) ) {
		$unsupported[] = $package->name;
	}
}

echo implode( ',', $unsupported );

I'd still like to better understand where I'm wrong here because I think I have tried doing what you told me I need to do but the results are the same as when I did it before.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand what you're saying though it seems to imply the script is correct, the logic in the script is correct, and I simply made the mistake of running it after installing packages with a newer version of PHP, something which wouldn't happen in the CI run.

No, as, as you yourself just proved above.

  • Your script is intended to find out which dependencies are incompatible so they can be removed before an install is run.
  • Your script requires a Composer install to have been run already, which would fail when there are incompatible dependencies.

Maybe my version of Composer is too new?

For an install on PHP 5.6, you can use the latest of the Composer LTS 2.2.x series.
Composer 2.3.0 and higher require PHP 7.2 (or higher).

In this case though my script failed to run because of something in symphony/polyfill that depended on newer PHP versions. After manually removing spatie/phpunit-watcher it progressed further, but still failed to execute the autoloader due to an issue with unsupported strict_types inside the phpunit's Framework/Assets/Functions.php module.

I haven't dug in any deeper now, but I suspect this may have something to do with the default PHP version on your system not being PHP 5.6 and something somewhere along the way starting a new PHP process and using the system default PHP version instead of the PHP version you want it to use. Could that be it ?

So I guess the current state is that if we want to do this programmatically the script is telling us the information from the installed packages as it should, but we need to modify it to read the Semver dependencies directly instead of through the autoloader, since that fails on PHP 5.6, and also ensure that we're running it on the right set of installed packages.

Possibly, and while I appreciate you are enjoying the intellectual exercise of trying to understand this. @anton-vlasenko 's two liner in the GHA script fixes this with a lot less effort and higher accuracy.

Copy link
Member

Choose a reason for hiding this comment

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

Your script is intended to find out which dependencies are incompatible so they can be removed before an install is run.

that's not the case, but that's how I interpreted your statement when you said "which is highly dependent on which PHP version was used to run composer install". if the running PHP version determines what packages composer will install then I took that to imply it wouldn't install packages that are listed as incompatible.

For an install on PHP 5.6, you can use the latest of the Composer LTS 2.2.x series.

thanks. as indicated in my previous comment I did attempt this on 2.2 and 1.6 versions.

system default PHP version instead of the PHP version you want it to use. Could that be it ?

No I don't think so, because as indicated in my previous comment, PHP 5.6 was the only version of PHP installed within the Docker container. It was both the system default and the only available version to run.

git --version
svn --version
composer --version
locale -a
Copy link
Member

Choose a reason for hiding this comment

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

Is all this necessary or mostly useful while developing this branch? Same question for the Docker debug info step below.

Copy link
Contributor Author

@anton-vlasenko anton-vlasenko Dec 19, 2022

Choose a reason for hiding this comment

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

It's not necessary, but it's worthwhile.
E.g., it helps to confirm which version of Composer and/or PHP are used when installing Composer packages and running PHPUnit.

Copy link
Member

Choose a reason for hiding this comment

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

I'm asking because we don't currently do this for our other workflows, and it's a fair amount of noise, and some duplication (e.g. PHP and composer versions are already available through the matrix and through the PHP install step).

It's not problematic, per se, just curious why it's here as it seems like a step (to remove this debug logging) that might have been overlooked before prepping for final merge into trunk.

Copy link
Contributor Author

@anton-vlasenko anton-vlasenko Dec 20, 2022

Choose a reason for hiding this comment

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

because we don't currently do this for our other workflows

We actually do this.

PHP and composer versions are already available through the matrix and through the PHP install step

Yes, they are through the matrix, but we cannot be sure that the CI jobs use these specific versions (until we log them).
Also, in the matrix, we only specify major and minor PHP versions (the same way it's implemented in Core).
The logging allows us to know the exact PHP version (including the point release) used when running particular CI jobs.

Copy link
Member

Choose a reason for hiding this comment

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

to know the exact PHP version (including the point release) used when running particular CI jobs.

That information is already available via the setup-php step.

Jonathan and me actually discussed removing a lot of this kind of debug noise from the WP Core workflows recently as the information is already available within the workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That information is already available via the setup-php step.

I've removed logging Composer and PHP versions.
cb3ee089ee66b68af28305833e5868f7d517454d
2dfb8452e972553650ac309e497cb0fee252be15

@anton-vlasenko anton-vlasenko changed the title Ensure PHP CI jobs run PHPUnit tests run on all PHP versions Ensure PHP CI jobs run PHPUnit tests on all PHP versions Dec 20, 2022
@anton-vlasenko anton-vlasenko changed the title Ensure PHP CI jobs run PHPUnit tests on all PHP versions PHP CI jobs must run PHPUnit tests on all Core-supported PHP versions Dec 20, 2022
@anton-vlasenko anton-vlasenko force-pushed the fix/parity-with-cores-php-ci-jobs branch from f11e08d to 1620c6f Compare December 20, 2022 20:34
@anton-vlasenko anton-vlasenko marked this pull request as ready for review December 20, 2022 21:41
@anton-vlasenko anton-vlasenko changed the title PHP CI jobs must run PHPUnit tests on all Core-supported PHP versions Run PHPUnit jobs across multiple PHP versions Dec 20, 2022
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Thanks for the ping @anton-vlasenko and for setting this up! Great step forward.

I've left a number of comments inline. Take from it what you will.

Other than that, I truly don't understand why NPM and Docker are needed. Seems like a lot of overkill and a roundabout way to do things, which can just be done using a PHP based workflow. Then again, I'm not intimately familiar with GB, so there may be good reasons for it, in which case, it might be a good idea to document those.

.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
.github/workflows/phpunit-tests.yml Outdated Show resolved Hide resolved
.github/workflows/phpunit-tests.yml Outdated Show resolved Hide resolved
Comment on lines 45 to 56
php:
[
'5.6',
'7.0',
'7.1',
'7.2',
'7.3',
'7.4',
'8.0',
'8.1',
'8.2',
]
Copy link
Member

Choose a reason for hiding this comment

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

Either specify it like so:

php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']

or like so:

php:
  - '5.6'
  - '7.0'
  - '7.1'
  - '7.2'
  - '7.3'
  - '7.4'
  - '8.0'
  - '8.1'
  - '8.2'  

This is Yaml, not PHP.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @jrfnl on this, but…

This is Yaml, not PHP.

I don't see the reason to add snark in this comment. The code as written parses as expected and is valid YAML. We don't have to claim that @anton-vlasenko was unaware of which language is being written or put anyone down when their style is different than your style or even when we find stylistic differences in a project and a code submission.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry if you interpreted my comment as snarky, definitely wasn't meant as such. It was just meant to convey that I understand where the inclination to write it like that comes from, nothing more.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see @jrfnl 's comment as snarky either.
I sincerely appreciate your expertise and your code review, @jrfnl.
Thank you!

.github/workflows/phpunit-tests.yml Outdated Show resolved Hide resolved
packages/env/lib/build-docker-compose-config.js Outdated Show resolved Hide resolved
@anton-vlasenko
Copy link
Contributor Author

Thanks for the review, @jrfnl.
I appreciate the improvements you proposed (especially those related to wrong PHPUnit versions and the phpcs cache).

Other than that, I truly don't understand why NPM and Docker are needed. Seems like a lot of overkill and a roundabout way to do things, which can just be done using a PHP based workflow. Then again, I'm not intimately familiar with GB, so there may be good reasons for it, in which case, it might be a good idea to document those.

I see your point.

My reasoning for using Docker and wp-env is the following:

  1. wp-env is simple to install and requires almost no configuration.
  2. Gutenberg community maintains the wp-env package, so the CI jobs will require less maintenance when the new versions of Gutenberg/WordPress get released.
  3. Running Gutenberg unit tests natively requires more hassle than running WordPress unit tests, as Gutenberg needs WordPress to be installed and configured. wp-env significantly simplifies this process.
  4. Docker runs much better on Linux compared to macOS and Windows. The overhead is very little, and the speed is native-like.
  5. Should the community need to use some other WordPress plugins or themes when running the unit tests, wp-env can quickly achieve that.

I have nothing against running the unit tests native. I just see more benefits in enabling testing on all PHP versions sooner than later to prevent merging incompatible/sub-optimal PHP code to the repo.

@jrfnl
Copy link
Member

jrfnl commented Dec 23, 2022

I have nothing against running the unit tests native. I just see more benefits in enabling testing on all PHP versions sooner than later to prevent merging incompatible/sub-optimal PHP code to the repo.

I fully agree with getting this merged sooner rather than later. This can always be iterated on at a future point in time. 👍🏻

Re: Docker - I have the same objections to WP Core running the tests via Docker.

  1. The Docker images are set up to be "ideal" environments, which is great for development, but not for testing.
  2. Ideal environments are not representative of the real world environments WP runs on.
  3. We need a much higher variation of test environments:
    • Testing with various PHP extensions disabled (like Sodium, Imagick, GD, but there are definitely more to look at).
    • Testing with different versions of PHP extensions, especially the PECL ones, like Imagick, which may not get updated alongside PHP.
    • Testing with a better range of PHP/MySQL combinations.
    • Testing with specific ini directives set to non-standard values (for those ini directives which are not runtime changable from within the tests).
    • And yes, we should also be testing against Windows server environments.
    • etc

There are currently tests in the WP Core test suite which are never run in CI due to the "ideal" Docker environment setup. This is not good.

Let's be realistic here: we are not building software which will only run in an environment over which we have full control, like in-company software.
We are building software which powers 40% of the internet and is run on an extremely wide range of system configurations, so our test setup should reflect that.

Note: For Core this is an ongoing discussion and something I would very much like to change (definitely outside the scope of this PR though).

For GB, as this is a new test workflow, you have the opportunity to do better than Core, but I fully respect it if you choose to start with this and iterate on it once this is changed in WP Core.

@anton-vlasenko
Copy link
Contributor Author

anton-vlasenko commented Jan 4, 2023

Thanks for listing all the issues with the current testing environment.
I wasn't aware of that.
I agree that the more testing environments there are, the better.

For GB, as this is a new test workflow, you have the opportunity to do better than Core, but I fully respect it if you choose to start with this and iterate on it once this is
changed in WP Core.

I cannot tell for sure that I will backport changes from Core to Gutenberg once the Core testing environment gets changed.
But I'm all for backporting the updated Core testing workflow to Gutenberg once it's merged.

I'd appreciate it if you could approve this PR, @jrfnl.
I've enabled the fail-fast option in the matrix job.

Props to @jrfnl for finding this bug.
Props to @jrfnl for identifying an issue with PHP 7.4 and 7.4.

# Conflicts:
#	packages/env/CHANGELOG.md
2. Don't put the OS version in the matrix.
2. Move the cache option to the phpcs.xml.dist
…ious)."

This reverts commit eaef3343f85faa8f50f7465eb70105cac961d0ca.
@anton-vlasenko anton-vlasenko force-pushed the fix/parity-with-cores-php-ci-jobs branch 2 times, most recently from 5d58954 to 4554441 Compare January 13, 2023 12:22
@anton-vlasenko
Copy link
Contributor Author

anton-vlasenko commented Jan 13, 2023

@anton-vlasenko Quick question: is there a Dependabot config in the repo to automatically update the predefined action runners ? If not, I'd strongly advise to double-check the used versions as quite a few look out of date to me.

  • actions/checkout uses version 3.1.0, while IIRC the latest release is 3.3.0.
  • shivammathur/setup-php uses version 2.22.0, while IIRC the latest release is 2.23.0.
  • actions/cache uses version 3.0.11, while IIRC the latest release is 3.2.3.
    ...etc...

@jrfnl Yes, there is a Dependabot config in the repo.
Hopefully it will take care of updating the versions.
https://github.com/WordPress/gutenberg/blob/trunk/.github/dependabot.yml

This is needed because:
1. unit-php job has to be preserved as it's set as required in the GH settings.
2. unit-php job now depends on the test-php job.
@anton-vlasenko anton-vlasenko force-pushed the fix/parity-with-cores-php-ci-jobs branch from 2ce991c to 2a371d8 Compare January 16, 2023 10:27
@anton-vlasenko anton-vlasenko merged commit 9ee17a7 into trunk Jan 16, 2023
@anton-vlasenko anton-vlasenko deleted the fix/parity-with-cores-php-ci-jobs branch January 16, 2023 12:49
@github-actions github-actions bot added this to the Gutenberg 15.1 milestone Jan 16, 2023
@juanmaguitar juanmaguitar added the [Type] Project Management Meta-issues related to project management of Gutenberg label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Project Management Meta-issues related to project management of Gutenberg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants