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

feat(service): Add Web Push #441

Merged
merged 15 commits into from
Jun 7, 2023

Conversation

KaviiSuri
Copy link
Contributor

Description

This introduces the web push service as a notifier in the library. It uses webpush-go to handle the notifications.

This PR is still a draft!

Motivation and Context

This PR aims to close #112

How Has This Been Tested?

I need some advice on this as the webpush-go package does not provide a client struct that we can mock, rather it's a bunch of global functions.

Should the testing be done by creating such an abstraction (client struct)? Or, testing the logic to parse the options from context and payload should be enough?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@KaviiSuri
Copy link
Contributor Author

@nikoksr I've implemented the basic webpush notification service in this PR, but I need advice on the testing approach.
Would love some feedback from too!

@nikoksr
Copy link
Owner

nikoksr commented Nov 12, 2022

@KaviiSuri thank you so much for this! Looks very promising already. Please excuse the delay, we're both rather busy atm but will come back to this asap!

@nikoksr nikoksr changed the title Introducting Web Push Service : Closes #112 feat(service): Add Web Push Dec 19, 2022
@nikoksr
Copy link
Owner

nikoksr commented Dec 19, 2022

Hi @KaviiSuri, so sorry for the big delay. Your PR is next in line, I'll tackle it over the holidays! Once again, appreciate your efforts and patience.

@KaviiSuri
Copy link
Contributor Author

@nikoksr no problem at all! I completed understand.

I hope to contribute and learn more!

@nikoksr
Copy link
Owner

nikoksr commented Jan 15, 2023

@KaviiSuri going over this now! I'll hit you up with feedback asap. Appreciate your patience so much. Hope things are well with you.

@gedw99
Copy link

gedw99 commented Feb 14, 2023

@KaviiSuri

it’s blocked on static analysis ?

@KaviiSuri
Copy link
Contributor Author

Hey @gedw99
I just noticed it, it's asking for a package comment, will do it asap!

@gedw99
Copy link

gedw99 commented Feb 14, 2023

asap

ok thanks !

@KaviiSuri
Copy link
Contributor Author

Hey @gedw99, the codacy url shows 503 Service Temporarily Unavailable. Any idea on how to fix it?

@gedw99
Copy link

gedw99 commented Feb 16, 2023

Hey @gedw99, the codacy url shows 503 Service Temporarily Unavailable. Any idea on how to fix it?

No
I looked at the Workflows buy nothing stands out .

is their service down ?

…ush-notification-service

* 'main' of https://github.com/nikoksr/notify: (65 commits)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/config to v1.18.13 (nikoksr#529)
  fix(deps): update module github.com/plivo/plivo-go/v7 to v7.19.0 (nikoksr#528)
  fix(deps): update module google.golang.org/api to v0.110.0 (nikoksr#527)
  fix(deps): update module github.com/bwmarrin/discordgo to v0.27.0 (nikoksr#509)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/service/sns to v1.20.2 (nikoksr#526)
  fix(deps): update module github.com/mailgun/mailgun-go/v4 to v4.8.2 (nikoksr#525)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/service/sns to v1.20.1 (nikoksr#524)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/service/ses to v1.15.1 (nikoksr#523)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/config to v1.18.12 (nikoksr#522)
  fix(deps): update module github.com/aws/aws-sdk-go-v2 to v1.17.4 (nikoksr#521)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/service/sns to v1.20.0 (nikoksr#520)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/config to v1.18.11 (nikoksr#519)
  fix(deps): update module google.golang.org/api to v0.109.0 (nikoksr#518)
  fix(deps): update module github.com/plivo/plivo-go/v7 to v7.18.0 (nikoksr#517)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/config to v1.18.10 (nikoksr#515)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/service/sns to v1.19.1 (nikoksr#514)
  fix(deps): update module github.com/aws/aws-sdk-go-v2/config to v1.18.9 (nikoksr#512)
  fix(deps): update module google.golang.org/api to v0.108.0 (nikoksr#511)
  feat(service): Add Google Chat Service (nikoksr#501)
  fix(deps): update module github.com/plivo/plivo-go/v7 to v7.17.1 (nikoksr#510)
  ...
@KaviiSuri
Copy link
Contributor Author

is their service down?
It was, not anymore apparently

@nikoksr
Copy link
Owner

nikoksr commented Mar 14, 2023

@KaviiSuri finally got to give this my full attention.. so sorry for the huge delay. To compensate you for your patience, you don't need to do any refactoring work, it's all done.

Your struggles with this PR are absolultely understandable to me. And I agree with you, it's not our obligation to test the webpush library in it's fullness. We just have to make sure that whatever data we touch, manipulate and forward to the library is well tested. I've utilized the httptest.Server for this, similar as with our internal HTTP service. I'm curious for your feedback on this!

Also, I made some changes to your implementation that generalize its usage a bit, but overall it was a joy working with your code. Great job, we appreciate it a ton! I'll go ahead fix the remaining linter issues and we'll be ready to merge right after. Hope you're doing well and sorry again for the delay.

Edit: Oh, and before I forget, please check if the end-to-end test still works! I may have very well broken your working implementation haha

@codecov-commenter
Copy link

codecov-commenter commented Mar 14, 2023

Codecov Report

Patch coverage: 76.82% and project coverage change: +0.09 🎉

Comparison is base (3f4d10d) 75.07% compared to head (8171fd0) 75.17%.

❗ Current head 8171fd0 differs from pull request most recent head e387801. Consider uploading reports for the commit e387801 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #441      +/-   ##
==========================================
+ Coverage   75.07%   75.17%   +0.09%     
==========================================
  Files          41       42       +1     
  Lines        1376     1458      +82     
==========================================
+ Hits         1033     1096      +63     
- Misses        251      268      +17     
- Partials       92       94       +2     
Impacted Files Coverage Δ
service/webpush/webpush.go 76.82% <76.82%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@KaviiSuri
Copy link
Contributor Author

@nikoksr thanks for making the improvements! So happy to contribute to the project, would love to do more work here moving forward!

@gedw99
Copy link

gedw99 commented Mar 15, 2023

MIght be useful to add the following to README

https://caniuse.com/notifications

IOS needs A2HS. Like ths golang pwa does: https://go-app.dev/

@nikoksr
Copy link
Owner

nikoksr commented Mar 16, 2023

@KaviiSuri @gedw99 does any of you happen to know an easy way for us to test this solution end-to-end? It's pretty safe to assume that SherClockHolmes/webpush-go does its job well and just works, but I don't like the idea of just releasing the solution without checking its behavior once.

@gedw99 great idea, we'll definitely include this!

@gedw99
Copy link

gedw99 commented Mar 16, 2023

@KaviiSuri @gedw99 does any of you happen to know an easy way for us to test this solution end-to-end? It's pretty safe to assume that SherClockHolmes/webpush-go does its job well and just works, but I don't like the idea of just releasing the solution without checking its behavior once.

@gedw99 great idea, we'll definitely include this!

I test E2E locally using Caddy, MkCert for the Server. Gives you a https locally with custom domain name.
https://github.com/FiloSottile/mkcert

For the Wasm services worker i use go.app: https://github.com/maxence-charriere/go-app

I think it would be a good idea to make a little demo in this repo one day when there is time.

In CI, I can run caddy and mkcert, using a makefile as part of github workflows.
It's the exact same makefile used on your laptop, just called as part of CI.
I like this because i get full control and don't need any docker containers in CI so its fast.

For CI of the GUI, thats hard. I use screen shots and Goldens. Its brutal but works. I don't have a framework yet i can recommend because i use GIO which has build in screen shotting. It runs on web, desktop and mobile. SO its makes cross devcie testing easier. BUT gio is not used by others.

But the idea is to deploy the web app as a github page as part of CI, then you can tell it to screenshot and then you can test you got the right screen shot against your golden screenshot.

Because the makefiles are 100% OS independent you can test for all Desktops and their browsers.

Again i tres that CI browser testing is HARD and these are only suggestions.

I would be happy to work on this with someone.

@nikoksr
Copy link
Owner

nikoksr commented Mar 16, 2023

@KaviiSuri @gedw99 does any of you happen to know an easy way for us to test this solution end-to-end? It's pretty safe to assume that SherClockHolmes/webpush-go does its job well and just works, but I don't like the idea of just releasing the solution without checking its behavior once.
@gedw99 great idea, we'll definitely include this!

I test E2E locally using Caddy, MkCert for the Server. Gives you a https locally with custom domain name. FiloSottile/mkcert

For the Wasm services worker i use go.app: maxence-charriere/go-app

I think it would be a good idea to make a little demo in this repo one day when there is time.

In CI, I can run caddy and mkcert, using a makefile as part of github workflows. It's the exact same makefile used on your laptop, just called as part of CI. I like this because i get full control and don't need any docker containers in CI so its fast.

For CI of the GUI, thats hard. I use screen shots and Goldens. Its brutal but works. I don't have a framework yet i can recommend because i use GIO which has build in screen shotting. It runs on web, desktop and mobile. SO its makes cross devcie testing easier. BUT gio is not used by others.

But the idea is to deploy the web app as a github page as part of CI, then you can tell it to screenshot and then you can test you got the right screen shot against your golden screenshot.

Because the makefiles are 100% OS independent you can test for all Desktops and their browsers.

Again i tres that CI browser testing is HARD and these are only suggestions.

I would be happy to work on this with someone.

Wow, fascinating! Thanks for sharing all that knowledge with us. I wasn't aware of screenshot based browser testing and thus neither of golden.

I wonder how or if we could reduce the complexity of this. Here's something I found with a quick Google search.

@gedw99
Copy link

gedw99 commented Mar 16, 2023

@KaviiSuri @gedw99 does any of you happen to know an easy way for us to test this solution end-to-end? It's pretty safe to assume that SherClockHolmes/webpush-go does its job well and just works, but I don't like the idea of just releasing the solution without checking its behavior once.
@gedw99 great idea, we'll definitely include this!

I test E2E locally using Caddy, MkCert for the Server. Gives you a https locally with custom domain name. FiloSottile/mkcert
For the Wasm services worker i use go.app: maxence-charriere/go-app
I think it would be a good idea to make a little demo in this repo one day when there is time.
In CI, I can run caddy and mkcert, using a makefile as part of github workflows. It's the exact same makefile used on your laptop, just called as part of CI. I like this because i get full control and don't need any docker containers in CI so its fast.
For CI of the GUI, thats hard. I use screen shots and Goldens. Its brutal but works. I don't have a framework yet i can recommend because i use GIO which has build in screen shotting. It runs on web, desktop and mobile. SO its makes cross devcie testing easier. BUT gio is not used by others.
But the idea is to deploy the web app as a github page as part of CI, then you can tell it to screenshot and then you can test you got the right screen shot against your golden screenshot.
Because the makefiles are 100% OS independent you can test for all Desktops and their browsers.
Again i tres that CI browser testing is HARD and these are only suggestions.
I would be happy to work on this with someone.

Wow, fascinating! Thanks for sharing all that knowledge with us. I wasn't aware of screenshot based browser testing and thus neither of golden.

I wonder how or if we could reduce the complexity of this. Here's something I found with a quick Google search.

@nikoksr

Looks pretty old and hacky.

I have used this:

https://saucelabs.com/resources/blog/how-to-test-push-notifications-on-android-and-ios-in-real-device-cloud

@nikoksr
Copy link
Owner

nikoksr commented Mar 16, 2023

@KaviiSuri @gedw99 does any of you happen to know an easy way for us to test this solution end-to-end? It's pretty safe to assume that SherClockHolmes/webpush-go does its job well and just works, but I don't like the idea of just releasing the solution without checking its behavior once.
@gedw99 great idea, we'll definitely include this!

I test E2E locally using Caddy, MkCert for the Server. Gives you a https locally with custom domain name. FiloSottile/mkcert
For the Wasm services worker i use go.app: maxence-charriere/go-app
I think it would be a good idea to make a little demo in this repo one day when there is time.
In CI, I can run caddy and mkcert, using a makefile as part of github workflows. It's the exact same makefile used on your laptop, just called as part of CI. I like this because i get full control and don't need any docker containers in CI so its fast.
For CI of the GUI, thats hard. I use screen shots and Goldens. Its brutal but works. I don't have a framework yet i can recommend because i use GIO which has build in screen shotting. It runs on web, desktop and mobile. SO its makes cross devcie testing easier. BUT gio is not used by others.
But the idea is to deploy the web app as a github page as part of CI, then you can tell it to screenshot and then you can test you got the right screen shot against your golden screenshot.
Because the makefiles are 100% OS independent you can test for all Desktops and their browsers.
Again i tres that CI browser testing is HARD and these are only suggestions.
I would be happy to work on this with someone.

Wow, fascinating! Thanks for sharing all that knowledge with us. I wasn't aware of screenshot based browser testing and thus neither of golden.
I wonder how or if we could reduce the complexity of this. Here's something I found with a quick Google search.

@nikoksr

Looks pretty old and hacky.

I have used this:

saucelabs.com/resources/blog/how-to-test-push-notifications-on-android-and-ios-in-real-device-cloud

Oh, definitely! My thought process was rather about taking this as a starting point and building a suitable solution on it, but Saucelabs already seems to be doing all that.

I would definitely welcome E2E tests for protocol centric services in the future and since we're slowly moving more and more services away from a third-party dependency based implementation towards http service based implementations E2E testing might become more viable even for platform centric services too.

@gedw99
Copy link

gedw99 commented Mar 16, 2023

Lets start a New Issue or Discussion about this ?

@nikoksr
Copy link
Owner

nikoksr commented Mar 16, 2023

Sure! Would you like to open it?

@nikoksr
Copy link
Owner

nikoksr commented Mar 23, 2023

@KaviiSuri will merge as soon as you mark this as ready (marked as draft atm)!

@KaviiSuri KaviiSuri marked this pull request as ready for review March 23, 2023 11:46
The way depguard is being utilized and configured seems to have changed.
Removing it for now as it's blocking the build pipeline until the problem is well understood.
@nikoksr nikoksr merged commit 5e9ddeb into nikoksr:main Jun 7, 2023
5 checks passed
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.

feat(service): Add Web Push service
4 participants