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

Github app to provide blast radius or test plan #28

Open
dhirenmathur opened this issue Jul 4, 2024 · 5 comments
Open

Github app to provide blast radius or test plan #28

dhirenmathur opened this issue Jul 4, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@dhirenmathur
Copy link
Collaborator

Description

Develop a new GitHub app that listens to webhooks on PR creation, PR updates, and PR comments that mention the bot with a command. The bot should integrate with the Momentum app, and users who install the bot need to be signed up for the Momentum app.

Workflow

User signs up to momentum and installs app on their repo.
There should be a user preference page on UI that has a toggle to turn on or turn off PR integration on Github. (not part of this task)
Receive webhook: Handle webhooks differently for PR update, PR create, comment with mention, and comment without mention.
PR update:
Parse the webhook body for the branch name, repo name, and base branch name.
Retrieve the project ID using the repo name, branch name, ( in case of multiple, choose the oldest one)
Fetch the blast radius for the project using project id and base branch name.
Comment on the PR with the blast radius information in a table format.
PR create:
Parse the webhook body for the branch name, repo name, and base branch name.
Since we need the user id against which we need to create the project, retrieve the user id from project table by querying using repo name, in the case that multiple users have linked the same repo on momentum, choose the oldest user
Create a project for the branch and repo
Fetch the blast radius for the project and base branch name.
Comment on the PR with the blast radius information in a table format.
Comment with mention:
Listen for a /plan {identifier} command in the comment that mentions the bot.
Parse the webhook body for the repo name and branch name.
Retrieve the project ID using the repo name and branch name.
Fetch the test plan for the specified identifier.
Comment on the PR with the test plan information and the project ID.
Comment without mention:
Ignore the comment.

Relevant documentation:

@dhirenmathur dhirenmathur added the enhancement New feature or request label Jul 4, 2024
@parthfloyd
Copy link
Contributor

Thanks @dhirenmathur for a detailed description! I'd like to work on this!

@dhirenmathur
Copy link
Collaborator Author

@parthfloyd awesome, I've assigned you the issue, let me know if you need any more context!

@parthfloyd
Copy link
Contributor

parthfloyd commented Jul 7, 2024

@dhirenmathur I'm looking forward to incorporate the following changes:

  • Create request_handler function which delegates function call based on Github events on webhook.
  • create & integrate function to post comment on Github PR.
  • create & integrate function to parse comment body.
  • update documentation.

Please feel free to add any feedback on this.

@dhirenmathur
Copy link
Collaborator Author

dhirenmathur commented Jul 7, 2024

Sounds good overall, can you provide more detail around the flow of the request handler. @parthfloyd

@parthfloyd
Copy link
Contributor

parthfloyd commented Jul 7, 2024

Yes @dhirenmathur
Firstly I'll fetch the event type (installation_repositories, issue_comment, pull_request) using the header: X-Github-Event & then checking its action & calling the required function (ideally as a coroutine object)

For example: for a new PR, event: pull_request, action: opened.
fetching blast radius for the branch & commenting on the PR in a table format.

parthfloyd added a commit to parthfloyd/momentum-core that referenced this issue Jul 8, 2024
-supports PR create, PR update & comment with bot mention on github
dhirenmathur added a commit that referenced this issue Jul 22, 2024
* Added 2 query for fetching project & user_id:
- Get First project from database by repository name & branch name
- Get first user id from project repository name

* (fix) minor import error in flow.py

* integrated comment on pr method

* #28 (feat) init request handler for webhook
-supports PR create, PR update & comment with bot mention on github

* removed unused parameter from fetch_pr

* integrated fix for user_id

* fix momentum interaction with bot

* sonar-lint refactoring

* (refactor) added case to handle new pr on existing branch

* (fix) handled windows file path for extracting file name.

* (fix) refactored handle_open_pr

* refactored generate testplan for webhook

* minor update to bot comments for blast radius & test plan.

* minor fix to filename in blast radius comment.

* minor update to blast radius comment.

---------

Co-authored-by: Dhiren Mathur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants