novu icon indicating copy to clipboard operation
novu copied to clipboard

feat: Preview Environment for PRs - WiP PR

Open ShrutiC-git opened this issue 1 year ago • 7 comments

What change does this PR introduce?

This PR is adding support for preview environments for PR events (opened, sync'ed, reopened, etc) on MindsDB, powered by Uffizzi.

Why was this change needed?

The motivation behind this PR is to allow maintainers and contributors to approve contributions in half the time with live previews for every pull request. The idea behind preview environments by Uffizzi is to eliminate friction while testing and approving changes. Since Novu has multiple components and each component can be interacted with in various ways, these environments will prove extremely helpful in testing if changes in the UI/API are working as they are supposed to.

An in-depth study on preview environments can be found here. Here is another easy read on where can you use Uffizzi inside Novu's environment.

Closes https://github.com/novuhq/novu/issues/2299

Other information (Screenshots)

In order to test this, I have created a PR against the main branch of my personal fork of Novu. This triggered the workflow to create a new preview environment - here and this comment, posted on the PR, takes me to the preview environment.

Signup is enabled for the preview, so you should be able to signup into the dashboard.

This preview builds the following containers/services:

  • api
  • web
  • embed
  • ws
  • widget
  • mongodb
  • redis
  • nginx

The needed env-vars are also set in the docker-compose.uffizzi file, which is used to build the containers and deploy the preview. Uffizzi uses the two GHAs — uffizzi-build.yml and uffizzi-preview.yml to build the code from source and deploy/update previews respectively. You can read more about the 2-stage workflow here.

Looking forward to power previews for Novu! If there are any questions/comments/feedback or concerns, please let me know,

ShrutiC-git avatar Jan 09 '23 16:01 ShrutiC-git

hi @scopsy - tagging you in on this.

Also, because we are using Nginx as a proxy, there are some errors I'm seeing with the ws service and an error on attempting to send a POST req to /templates/api_url when trying to update the Notification Group for the template. Perhaps you could help point to what I might be missing - probably seeing these due to some misconfig in the nginx.conf file and related env-vars.

ShrutiC-git avatar Jan 09 '23 16:01 ShrutiC-git

hey @scopsy ~ thanks for committing those changes. Were you able to peep into the errors I was seeing, probably because of the proxy I believe? We could arrange a call and go over the changes and issues we're seeing. Do let me know whatever would work best!

ShrutiC-git avatar Jan 13 '23 10:01 ShrutiC-git

@ShrutiC-git not yet, will look soon.

Can you take a look at the failed actions result? Not sure what I've done good.

scopsy avatar Jan 13 '23 11:01 scopsy

I looked into the failed action, @scopsy — from the sequence, I could tell that one of the uffizzi-build.yml actions had passed. There were a couple that failed before that, due to dependency issues.

An action failed post that one passed action. This error is a GHA limitation, we have come across in the past, although rarely. This is the request that came into our BE: time="2023-01-13T10:36:43.701298549Z" level=error msg="client disconnected during blob PUT" contentLength=35711164 copied=7864320 error="unexpected EOF" go.version=go1.11.2 http.request.contenttype="application/octet-stream"

The client here is the GHA stream. This error is in the line of errors encountered due to buildx-build-push limitation and its implementation in GitHub actions. You can read more here. This error does not pop up often, but whenever it does, re-running the workflow resolves the issue.

I tried running the action on my branch after the changes you've made, and the actions seemed to pass successfully. How would you mind retrying the flow? Since this is a WiP PR, I can dive deeper into this with our team to figure out workarounds to circumvent seeing this error at the cost of stripping away buildx and changing caching strategies.

Do let me know what works best for the project, and we'll test/integrate those changes.

ShrutiC-git avatar Jan 14 '23 06:01 ShrutiC-git

I can see the actions have passed, @scopsy. Re-triggering the flow did resolve that error. I can try removing buildx and see if that error still pops. I won't be able to tell definitively until hitting the flow at least a couple of times, because the error is not common and shows up rather randomly.

ShrutiC-git avatar Jan 16 '23 14:01 ShrutiC-git

@ShrutiC-git shouldn't it create a pr preview for this pr aswell and post a comment here? Do I need. to configure something in uffizzi cloud?

scopsy avatar Jan 17 '23 15:01 scopsy

@scopsy, so we have two actions here — the uffizzi-build.yml (which is the one you're seeing triggered) and then the uffizzi-preview.yml, which is the action that handles deploying/updating previews.

The uffizzi-preview.yml action is a workflow_run type of action, which gets triggered once the previous uffizzi-build action is completed. These types of actions require that the workflow file is present on the default branch of the repo. Here you can find out more about the workflow_run action.

Once this PR is merged, every PR opened against this repo will also trigger the uffizzi-preview action and a comment with the preview will be posted on the PR.

For example, I have a PR opened with uffizzi as the head branch on my personal fork of Novu. The uffizzi branch is also set as the default branch on my fork and contains both the workflow files.

Every commit you make to the uffizzi branch, sync's the PR and this PR event triggers the uffizzi-build and subsequently the uffizzi preview action. This is the comment that I see on the PR. You could see that the comment was posted when the PR was opened and edited an hour or so ago when you had updated the PR with your commits.

ShrutiC-git avatar Jan 17 '23 16:01 ShrutiC-git

hey, @scopsy let me know how we can move forward with fixing some of those endpoints, and hopefully, the Novu community could start using Uffizzi previews!

ShrutiC-git avatar Jan 24 '23 07:01 ShrutiC-git

friendly ping, @scopsy - what are your thoughts on this PR and previews in total? Do you think you can give me an idea of where you and the community are at with this PR? and if we can try to move this forward with updating or making edits wherever required? let me know :)

ShrutiC-git avatar Feb 01 '23 13:02 ShrutiC-git

You have successfully added a new CodeQL configuration .github/workflows/codeql-analysis.yml:analyze/language:javascript. As part of the setup process, we have scanned this repository and found 2 existing alerts. Please check the repository Security tab to see all alerts.

You have successfully added a new CodeQL configuration .github/workflows/codeql-analysis.yml:analyze/language:typescript. As part of the setup process, we have scanned this repository and found 2 existing alerts. Please check the repository Security tab to see all alerts.

For now decided to postpone the work on Uffizzi 🙏

scopsy avatar Apr 30 '23 14:04 scopsy