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] AAUser, when I have a pull request on github, my github app reviews my code #280

Open
8 tasks done
lizacullis opened this issue Sep 14, 2023 · 2 comments
Open
8 tasks done
Assignees

Comments

@lizacullis
Copy link
Collaborator

lizacullis commented Sep 14, 2023

Description:

We currently have a broken review-lambda. We need to edit the routing lambda so that it can send the review lambda the correct information in the correct format!

We need the review lambda to take data from the event detail we got in the eventBridge event (which will just be the full webhook event). We then need to use the github API to get the relevant data for all the changes that were made to build up the Review File objects. { fileName, fileContents, changesLines }. And then get a review from teh model and then comment the review on the pr.

type ReviewBody = {
  args: ReviewArgs;
  files: ReviewFile[];
};

Note: There is already a testing repo that you can use to test the installed app on. In OrionTools called github-app-webhook-test.

Validation:

  • When you have Github app installed, and put up a PR, you get review comments on your PR.
    • Screenshot of comments on PR
    • Screenshot of app being installed

Tech Steps:

  • In the routing lambda use the x-github-event header to determine the request type so that we can route the webhook requests to the correct lambdas.
  • In the review lambda send a request to the github installation access token api. You will need to create a jwy token and add it as a auth header. This will give us a installation access token. This is what authorises our application to access the users repo (for things like getting commits etc).
  • Then send a request to the github api to compare 2 commits (the base and head commits). This will give us all the info we need to do a review on the pull request. You will need some info to make this request, use the webhook request to extract the base branch name, head branch name, ownerName and repoName to use in the compareCommits request.
  • In the compareCommits response, we will get a list of all files that were changed. In this we can find the filename, the raw_url (which give us the file contents), and the patch which (with some stolen logic from the npm package) will give us the chnaged lines.
  • Proccess each of the files, and construct a ReviewFile object for each and compile them all into a list. This is to prep the data to be used my the review function.
  • Now create a Args object that has the required defaults.
  • Now we need to retrieve the OpenAiApiKey. We have our own one in paramStore at the moment which we will use for now. [But future work will be to get the user's own APIKey from dynamoDB if they have set one.]
  • Once we have called the review function, we want to use the githubAPI again to comment the review on the pull request!
@lizacullis lizacullis self-assigned this Sep 14, 2023
@lizacullis
Copy link
Collaborator Author

lizacullis commented Sep 18, 2023

Validation:

Commeted on PR via app.
Image

App installed on repo
Image

@lizacullis
Copy link
Collaborator Author

TODO:

Get the user's own API key from dynamodb if they have set one up.

  • User signs up
  • User adds the app ( probably will have a link to add the app on the website)
  • They configure the app in github - ie give access to specific repos etc.
  • If they try to use the app without having set a openAIApiKey on their profile, we should propably pop a message on the repo or something to let them knnow.
  • If they have set it, we will need to retrieve that API key via dynamoDB
    • We will need to look at how to query this since I don't think we get their userId that is used as the primary key in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

1 participant