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

Use PHP-Scoper to prefix production dependencies in a third-party directory #696

Merged
merged 21 commits into from
Oct 24, 2019

Conversation

felixarntz
Copy link
Member

@felixarntz felixarntz commented Oct 23, 2019

Summary

Addresses issue #612

Note that after this is merged, we need to update the contributor guidelines on getting started to include composer global require humbug/php-scoper

Relevant technical choices

  • Use PHP-Scoper because it's more reliable and better maintained than alternatives such as Mozart.
  • Whitelist vendor content needed for production in scoper.inc.php configuration file.
  • Generate individual classmap autoloaders for both Site Kit's own files and for all prefixed dependencies.
  • Hack a bit regarding the non-class files that dependencies include. We can simply use the autoload_files.php file generated by the original autoloader and load them in a bit different way. This at least ensures we don't have to manually maintain that list of files.

Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 4.7 and PHP 5.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@aaemnnosttv
Copy link
Collaborator

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@felixarntz felixarntz marked this pull request as ready for review October 24, 2019 09:47
aaemnnosttv
aaemnnosttv previously approved these changes Oct 24, 2019
Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

This is great!

I left a few comments/questions/suggestions but nothing blocking.

.travis.yml Outdated
Comment on lines 53 to 57
- npm install || exit 1
- composer install
- docker run --rm -v "$PWD:/app" composer install
- |
if [[ "$PHP" == "1" ]] || [[ "$JS" == "1" ]] || [[ "$SNIFF" == "1" ]]; then
npm install -g gulp-cli
Copy link
Collaborator

Choose a reason for hiding this comment

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

These things should run in the install phase of the build rather than before_script I think

scoper.inc.php Outdated Show resolved Hide resolved
scoper.inc.php Outdated Show resolved Hide resolved
Finder::create()
->files()
->ignoreVCS( true )
->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/' )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/' )
->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.(json|lock)/' )

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this change should still be made.

Co-Authored-By: Evan Mattson <evan.mattson@10up.com>
tofumatt
tofumatt previously approved these changes Oct 24, 2019
Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

There is a tweak @aaemnnosttv proposed here I think should be made before merging, but aside from that looks good.

Since he said they weren't blocking I say this is good-to-go, but if you could see about his last suggested change (the composer.lock regex bit) that'd be great!

@felixarntz
Copy link
Member Author

@tofumatt I committed that change already, not sure why it still shows up, but it's done :)

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

Ah, cool. All good then! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants