-
Notifications
You must be signed in to change notification settings - Fork 5
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 scoper to namespace dependencies #237
Conversation
Further investigation I run into this bug humbug/php-scoper#298 - meaning that because of having guzzle in core, the
Now I run into:
Let's see why the exception functions are not properly scoped here Went on manually dealing with this to see how far I would get when ignoring the initial error |
Figured out the S3Exception part - the magic in https://github.com/aws/aws-sdk-php/blob/master/src/AwsClient.php#L295 causes trouble It can however be overridden when a client is created via: |
97db16f
to
76abe84
Compare
a035c3d
to
d0744a8
Compare
Unit test failures where resolved by copying over the |
bcac537
to
b9b5466
Compare
Remaining failures are related to trashbin tests
see: https://drone.owncloud.com/owncloud/files_primary_s3/1116/27/20 When looking inside the owncloud.log - the errors are
Not sure why the object storage returns a 404 here - this needs investigation |
the reason is that API tests are run instead of webUI tests see https://github.com/owncloud/files_primary_s3/pull/237/files#diff-3216dfff0ed3e301453e6799e8c367e2R268 the detailed reason: Line 234 in b9b5466
in combination with https://github.com/owncloud/core/blob/9505bffa2729a0232d89d7e03ef72f6b1dd41742/tests/acceptance/run.sh#L880 so running API tests in the webUI drone section messes it all up |
ebc2ed4
to
1052182
Compare
The failures on |
Signed-off-by: Patrick Jahns <[email protected]> allow the usage of dev dependencies in order to install latest scoper
The autoloader was correctly fixed by php-scoper - however doing the recommended dump after scoper was used, the fixes for the autoloader where no longer present. The logic here has been moved into a seperate script now
Signed-off-by: Patrick Jahns <[email protected]>
c1965ae
to
32dd3e0
Compare
Signed-off-by: Patrick Jahns <[email protected]>
Signed-off-by: Patrick Jahns <[email protected]>
…that can be installed for unit testing Signed-off-by: Patrick Jahns <[email protected]>
32dd3e0
to
c055ad7
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.
Hey @patrickjahns, thank you very much for your scoper-fix-autoloader.php
file, I've "borrowed" it to fix the clashing hashes when embedding the SDKs that use the composer autoloader in a WordPress plugin.
I did notice that it prefixed all but the last hash key in the processed array, so here's a slight tweak that fixes that.
Thanks again, very much appreciated!
$static_loader_path = $scoper_path.'/autoload_static.php'; | ||
echo "Fixing $static_loader_path \n"; | ||
$static_loader = file_get_contents($static_loader_path); | ||
$static_loader = \preg_replace('/\'([A-Za-z0-9]*?)\' => __DIR__ \. (.*?),/', '\'a$1\' => __DIR__ . $2,', $static_loader); |
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.
This doesn't catch the last element in the array that is followed by )
rather than ,
, so should be like the following instead as each element ends with .php'
...
$static_loader = \preg_replace('/\'([A-Za-z0-9]*?)\' => __DIR__ \. (.*?\.php\')/', '\'a$1\' => __DIR__ . $2', $static_loader);
$files_loader_path = $scoper_path.'/autoload_files.php'; | ||
echo "Fixing $files_loader_path \n"; | ||
$files_loader = file_get_contents($files_loader_path); | ||
$files_loader = \preg_replace('/\'(.*?)\' => (.*?),/', '\'a$1\' => $2,', $files_loader); |
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.
This doesn't catch the last element in the array that is followed by )
rather than ,
, so should be like the following instead as each element ends with .php'
...
$files_loader = \preg_replace('/\'(.*?)\' => (.*?\.php\')/', '\'a$1\' => $2', $files_loader);
This pullrequest tries to accomplish similar aspects as #142 - but utilizes humbug/scoper https://github.com/humbug/php-scoper
Currently scoping requires a 3 step process:
scoper-fix-autoloader.php
As this process touches composer and autoloading - the scoping can only happen in the build process of the artifact.
Thus the 3 steps have been included in the Makefile in two targets:
make dist
make dist-qa
For 🤖 - this also means, that now not the source code as it exists in the working space should/needs to be tested. This time we need to install the artifact and then perform our tests on top.
As the unit-tests are normally not included in an artifact - the
dist-qa
target was thus created.So bot acceptance and unit tests are performed on top of the scoped files.
The drone.yml has been adjusted to reflect this behaviour - with the migration to drone 1.0 and starlark this probably needs to be migrated to the new format.
For this app ( and any other app that might use scoped dependencies ) it is of key essence, to test the final artifact, as the source code and the vendor files are touched during the scoping process.
For development this should not make any difference.
Important things noticed
AWS SDK
The AWS Library had issue being fully scoped initially, and thus it was needed to write patchers for humbug
GUZZLE SDK
In order to correctly use guzzle with scoping - it was better to put the guzzle sdk to the vendor libraries and get them scoped, as all references in other required libraries would have otherwise been scoped or needed to be whitelisted. Additionally this now makes files_primary_s3 app independent from the core guzzle version used - as it has its own scoped version
In the guzzle SDK, there is a file called
functions.php
- loading these plain files in composer is based on a package+filename. These loaded files are registered globally and only loaded once for every package.As Scoper does not change the packagename, the
functions.php
from guzzle wouldn't be loaded - hence it was necessary to write a "fixer" for the dumped composer autoloader, to tell composer that thefunctions.php
referenced in this app is actually a different one compared to the one already loaded from any ohter app/coreBelow some of the quirks were described in single posts - and some of the solutions as well