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

[WIP] [BC] General project maintenance #236

Closed
wants to merge 37 commits into from
Closed

[WIP] [BC] General project maintenance #236

wants to merge 37 commits into from

Conversation

ryancco
Copy link

@ryancco ryancco commented Jun 6, 2019

I've reached out to @Minishlink hoping to be able to collaborate on a roadmap for the project and shoot some ideas that he may be willing to accept into the project but haven't heard back yet. Hopefully, this will come as a sign of good faith and jump-start that process.

Sourcing projects similar in function to fit a need in another project, I stumbled across this library as it seems to be the defacto standard for web push with PHP. I also noticed it has some great proposed contributions from some awesome contributors and decided that rather than building my own library, why not contribute back to the community.

For anyone interested, this pull request will be a WIP and any feedback on particular changes being added in or removed are entirely welcome.

Changes in this pull request

  • 7173909 - Removing dependency management from code
  • dae1c89 - Implementing PSR-2 and opinionated code cleanup
  • e7de87c - Implementing PSR-4 autoloading for development
  • e88ba23 - Adding tests around & cleaning up notices in \Minishlink\WebPush\Notification
  • ed52704 - Reducing public IP and cleaning up test suite of \Minishlink\WebPush\MessageSentReport [BC]
  • 0ee2485 - Separating unit and integration test suites (also snuck a fix in that encompasses the changes in Suppress HTTP error exceptions #234)
  • 8bf6f80 - Implementing abstraction of HTTP communications [BC]
  • 4bf92e9 - Implementing Options
  • 78bff65 - Continuation of abstraction of HTTP communications; decoupling from third party HTTP libraries [BC]
  • e7cc878 - Implement Auth, drop support for GCM in exchange for VAPID (SEE: validation) [BC]
  • afc2cc5 - Implement Headers object to make building, manipulating and iterating over header keys and values easier and cleaner [BC]
  • ea9646e -
    • Implement Payload to keep the string payload it's encryption components together [BC]
    • Implement Queue to handle queueing of notifications and promises
    • Implement Cache to handle caching vapid headers
    • Implement SubscriptionInterface and AuthorizationInterface to allow for easier integration of the library into consumer code
    • Removed factory methods on model objects for explicit factory classes [BC]

Additional pull requests to be considered for version 6

Questions

  • We're not currently running the integration tests in CI but our travis.yml is partially configured to run the entirety of our test suite, integration tests included - do we want to look into running our integration tests in CI, or clean up the otherwise unneeded configuration?

ryancco and others added 16 commits June 4, 2019 16:05
Standardization of PSR-2 as well as some basic, slightly opinionated cleanup for readability - more to come in later commits
Implementing PSR-4 autoloading for development
Adding tests to encompass \Minishlink\WebPush\Notification as well as resolving undefined index notices in Notification::getOptions()
Simplifying and hiding away implementation details of MessageSentReport as well as fixing two broken test cases which should have never passed. SEE: MessageSentReportTest::testJsonSerialize & generateReportsWithJson
fixing a few static analysis issues i've let slip through the cracks
Clear separation of unit and integration tests will allow for an easier on-boarding experience as well as CI interactions for developers as they no longer have to inspect each testcase individually to understand why so many are being skipped, failing, or otherwise
@Minishlink
Copy link
Member

Cool, great that you're motivated!

Do you have a tool like prettier setup? Because if you're going to edit the whole project syntax, please setup something like this first. Otherwise someone might end up editing the whole project with another syntax afterwards. Note that php-cs-fixer is already used.

@Minishlink
Copy link
Member

Please don't skip the integration tests. It's our guarantee that modifications are valid. If they're broken, find the reason why and fix that, but please don't skip them

@Minishlink
Copy link
Member

Can you do more atomic Pull requests ? For example I like your PR to separate unit and integration tests, but there are also edits that change the behaviour of the tests and things that are not related to this.

@ryancco
Copy link
Author

ryancco commented Jun 7, 2019

Please don't skip the integration tests. It's our guarantee that modifications are valid. If they're broken, find the reason why and fix that, but please don't skip them

Sure thing, jumping into #228 with the author it looks to be that part of the issue at least is the upstream web-push-testing-service is failing. I also had issues running it on more recent versions of node so decided to follow up on it in a later commit. Added that one to the to-do list.

Cool, great that you're motivated!

Do you have a tool like prettier setup? Because if you're going to edit the whole project syntax, please setup something like this first. Otherwise someone might end up editing the whole project with another syntax afterwards. Note that php-cs-fixer is already used.

Thanks! I've been looking at options for this and definitely plan on committing something within this PR.

Can you do more atomic Pull requests ? For example I like your PR to separate unit and integration tests, but there are also edits that change the behaviour of the tests and things that are not related to this.

Yes, definitely can!

@gauntface
Copy link

I'll explore moving the web-push-testing-service into web-push-libs to share wider maintanence of it.

@martijndwars
Copy link
Member

@gauntface is the WPTS able to work with multiple versions of ChromeDriver? IIRC, it's using chromedriver 2.46 which supports Chrome 71-73, but now we have:

  • chromedriver 73.0.3683.68: supports Chrome 73.
  • chromedriver 74.0.3729.6: supports Chrome 74.
  • chromedriver 75.0.3770.8: supports Chrome 75.

Sorry for hijacking this pull request -- we can split this off in a new issue if this needs further discussion.

@Spomky
Copy link
Contributor

Spomky commented Jun 15, 2019

Instead of a concrete http client, you should rely on the PSR18 and its interfaces package. It is way more efficient

@ryancco
Copy link
Author

ryancco commented Jun 15, 2019

Instead of a concrete http client, you should rely on the PSR18 and its interfaces package. It is way more efficient

Looking to move forward later w/ an implementation of PSR17,18 in conjunction w/ httplug's async http client interface if this PR is well received. This will give a nice happy path for refactoring from though so I don't have to vest too much time to potentially not have it accepted 😅

@ryancco
Copy link
Author

ryancco commented Jun 16, 2019

Moving forward I'm noticing a few inconsistencies in logic and test scenarios regarding VAPID + GCM which has me curious: considering the scope of this already warranting a major version change, what is the general consensus on dropping support for GCM?

/cc @Minishlink @Spomky (& anyone else using/contributing to this project)

ryancco and others added 3 commits June 17, 2019 13:51
Introducing `Minishlink\WebPush\Options` including removing `batchSize` as it does not apply to the notification options.
Decoupling the http client from any specific third party library
Updating MessageSentReport due to differences between guzzle promises and the implementation provided (based on promisesaplus specification)
* Implement Payload to keep the string payload it's encryption components together
* Implement Queue to handle queueing of notifications and promises
* Implement Cache to handle caching vapid headers
* Implement SubscriptionInterface and AuthorizationInterface to allow for easier integration of the library into consumer code
@ryancco
Copy link
Author

ryancco commented Jun 25, 2019

Outside of the failing integration test, which is dependent on the supporting NPM package, I feel confident and am happy with the changes so far. If anyone is willing to provide a review on the PR as a whole, or would like to see anything immediately change, I'm more than willing to work with any requests to make this PR happen.

There are some more things I'd still like to work with, but they're all internal and would not affect the (newly proposed) public facing API. For example, the usage of classes internal to third-party libraries within the Encryption logic.

/cc @Minishlink @Spomky @marcvdm

.travis.yml Outdated Show resolved Hide resolved
composer.json Show resolved Hide resolved
src/Authorization.php Show resolved Hide resolved
src/Cache.php Show resolved Hide resolved
src/CacheFactory.php Show resolved Hide resolved
src/HeadersBuilder.php Show resolved Hide resolved
src/Options.php Show resolved Hide resolved
src/Payload.php Show resolved Hide resolved
src/QueueFactory.php Show resolved Hide resolved
src/SubscriptionFactory.php Show resolved Hide resolved
@Spomky
Copy link
Contributor

Spomky commented Jun 25, 2019

That’s a lot of changes! The code look cleaner and should be easier to maintain.
I made some comments and I will be happy to discuss if you disagree with them or if I was not clear enough.

@ryancco
Copy link
Author

ryancco commented Jun 25, 2019

That’s a lot of changes! The code look cleaner and should be easier to maintain.
I made some comments and I will be happy to discuss if you disagree with them or if I was not clear enough.

Thanks! I really appreciate the feedback and help working through this PR as a whole! 😃

dependency.php Outdated Show resolved Hide resolved
src/Authorization.php Show resolved Hide resolved
ryancco and others added 5 commits June 26, 2019 09:06
Pulling in the web-push-testing-service locally, I was able to bump the dependencies and get *most* of the service's test cases to run - enough so to be able to run and refactor the PushService integration test. Also found a few bugs along the way
@ryancco
Copy link
Author

ryancco commented Jun 27, 2019

Integration tests are passing 🎉 ... locally... The web-push-testing-service's test suite seems to have a few issues - I'm thinking relative to the fact that GCM is deprecated, but didn't actually dig into it. However, bumping the geckodriver and chromedriver, I was able to get the PushServiceTest to run, pass, and cleaned up.

@ryancco
Copy link
Author

ryancco commented Jun 27, 2019

Now waiting on GoogleChromeLabs/web-push-testing-service#24 (or similar - if anyone is interested) and we'll be able to run those integration tests as part of CI.

@ryancco
Copy link
Author

ryancco commented Jun 28, 2019

Still just waiting on @gauntface to check out the above PR (GoogleChromeLabs/web-push-testing-service#24) before the integration tests can be run as part of CI. Also waiting to receive any input from @Minishlink. Hoping to get the traction necessary to push this forward as quickly as possible 🙂 .

@ryancco ryancco mentioned this pull request Jul 13, 2019
@ryancco
Copy link
Author

ryancco commented Jul 13, 2019

👋

@Minishlink
Copy link
Member

Minishlink commented Jul 17, 2019

You can force using your branch for web-push-testing-service in the Travis configuration file

EDIT: apparently the fix doesn't work https://travis-ci.org/web-push-libs/web-push-php/jobs/559862577

@ryancco
Copy link
Author

ryancco commented Jul 17, 2019

You can force using your branch for web-push-testing-service in the Travis configuration file

EDIT: apparently the fix doesn't work https://travis-ci.org/web-push-libs/web-push-php/jobs/559862577

It shouldn't be running against beta channels, those were removed due to required driver changes. Not sure how those are running though, let me take a look.

Edit: Ah those also look to be running against GCM which has been removed entirely now afaik. Ignore the beta comment, that was the "nightly" [and "old"?] channel I was thinking of.

2: It does look like Firefox beta channel is failing though (unable to get a subscription), going to dig into this.

3: Interesting... Firefox beta seems to pass in the web-push-testing-service test suite.

@ryancco
Copy link
Author

ryancco commented Jul 17, 2019

At a loss as to why only Firefox beta seems to fail to receive a subscription. However, it does seem to be something relative to the web-push-testing-service/geckodriver dependency - drawing that conclusion based purely off of where the failure is happening. There are some relative issues around the selenium/browser testing ecosystem but that doesn't explain why the same test passes within the web-push-testing-service suite.

What is even stranger is this failure was not happening at the time of the PR to googlechromelabs/web-push-testing-service.

Any thoughts or input would be greatly appreciated.

@ryancco ryancco closed this Jul 22, 2019
@chasebolt
Copy link

disappointing this was never merged in

@infoseckev
Copy link

Is there a separate project available with these changes?

@ryancco
Copy link
Author

ryancco commented Aug 19, 2019

Unfortunately, no, these changes no longer live anywhere - at least publicly that I know of. The process to get these changes merged in far exceeded my expectations and those put on me by my employer at the time which had allowed me to contribute to this library as part of a larger project.

My contributions to the googlechromelabs/web-push-testing-service also seem to still be pending so it’s probably best I didn’t hold my breath.

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.

8 participants