-
Notifications
You must be signed in to change notification settings - Fork 197
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
Scope composer dependencies #6614
Conversation
"phpcompatibility/phpcompatibility-wp": "2.1.4", | ||
"sirbrillig/phpcs-no-get-current-user": "1.1.0", | ||
"sirbrillig/phpcs-variable-analysis": "2.11.9", | ||
"squizlabs/php_codesniffer": "3.7.1", | ||
"wp-coding-standards/wpcs": "2.3.0", | ||
"yoast/phpunit-polyfills": "1.0.4" | ||
}, | ||
"minimum-stability": "dev", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowering the minimum stability because php-scoper
has a dev-master
dependency.
Finder::create()->files()->in( 'vendor/pelago/emogrifier' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ), | ||
Finder::create()->files()->in( 'vendor/sabberworm/php-css-parser' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ), | ||
Finder::create()->files()->in( 'vendor/symfony/css-selector' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ), | ||
Finder::create()->files()->in( 'vendor/symfony/polyfill-php80' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use only the emogrifier
dependency but its dependencies should also be included.
.gitignore
Outdated
@@ -11,6 +11,7 @@ hookdocs | |||
node_modules/ | |||
tests/images/test-* | |||
vendor/ | |||
vendor_prefixed/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Folder name suggestions are welcome. 🙂
Maybe libs
, deps
, vendor_scoped
, third-party
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having "vendor" in the name is a bit confusing so I've updated the folder/namespace to third-party
/ Sensei\ThirdParty
.
@@ -7,14 +7,39 @@ | |||
"bamarni/composer-bin-plugin": "1.8.2", | |||
"dealerdirect/phpcodesniffer-composer-installer": "0.7.2", | |||
"dms/phpunit-arraysubset-asserts": "0.4.0", | |||
"humbug/php-scoper": "0.13.9", | |||
"pelago/emogrifier": "6.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pelago/emogrifier
dependency is intentionally moved to require-dev
because it shouldn't be loaded by the composer autoloader (vendor/autoload.php
). The third-party dependencies are now managed by the php-scoper
config and then autoloaded by vendor/autoload.php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't Emgorifier
used in Sensei\Internal\Emails\Email_Sender
?
I mean that usually considered as a production dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum. I think I understand the problem. We don't include vendor (as a source of dependencies) anywhere, so it doesn't make sense to use production dependencies at all. Basically, I think it is a bit confusing, but we probably "resolve" this confusing by documenting it properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I agree, it's a bit confusing. Another option was to have a separate composer file but I felt that is a bad idea. 🙂 Where do you think would be a good place to add docs for this? CONTRIBUTING.md
?
For posterity: the way I look at it is that the third-party
dependencies (other projects call them libs
) are not part of the composer production dependencies. Composer is there to only generate and autoload them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good place.
Maybe also add information about it here: https://github.com/Automattic/sensei/wiki/Setting-Up-Your-Development-Environment
Codecov Report
@@ Coverage Diff @@
## trunk #6614 +/- ##
============================================
+ Coverage 48.10% 48.15% +0.04%
- Complexity 9993 9999 +6
============================================
Files 502 502
Lines 35578 35602 +24
Branches 283 283
============================================
+ Hits 17115 17144 +29
+ Misses 18251 18246 -5
Partials 212 212
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
6cde5ec
to
554860b
Compare
b2cb014
to
b4aa3cb
Compare
4d0f944
to
fd8fb5f
Compare
fd8fb5f
to
95321ae
Compare
2a67c76
to
7e8848c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well both locally and on jurassic site 👍
As for the test for the Actions class, I don't see a straightforward solution here. We can consider a couple of workarounds. One is to add this class (or interface) to tests suite. Another is to remove type hinting and use "duck-typing" approach.
@@ -7,14 +7,39 @@ | |||
"bamarni/composer-bin-plugin": "1.8.2", | |||
"dealerdirect/phpcodesniffer-composer-installer": "0.7.2", | |||
"dms/phpunit-arraysubset-asserts": "0.4.0", | |||
"humbug/php-scoper": "0.13.9", | |||
"pelago/emogrifier": "6.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum. I think I understand the problem. We don't include vendor (as a source of dependencies) anywhere, so it doesn't make sense to use production dependencies at all. Basically, I think it is a bit confusing, but we probably "resolve" this confusing by documenting it properly.
Resolves #6574
Proposed Changes
php-scoper
to scope the composer dependencies by moving them to a new namespace (Sensei\ThirdParty
).third-party
).Testing Instructions
I was not able to add tests for the composer
Actions
class. The passed Event class is only loaded by composer so I can't mock it. Let me know if you have suggestions on how to test it.vendor
folder.composer install
.third-party
folder is created and not empty.composer install --no-dev
vendor
folder has only the composer autoloader related files and no dev dependencies.email_customization
feature flag.emogrifier
dependency is loaded and working.Pre-Merge Checklist