CodiumAI is a coding assistant that developers can use to enhance their coding experience using the power of Artificial Intelligence.
It is a trending tool with features such as accurate code suggestions, explanation of the code, automatic test generation, and various language and IDE Support.
For this demo, we are going to use CodiumAI to make a Pull Request.
Installation
For the installation, we will need two things:
- OpenAI API Key
- GitHub Personal Access Token(Classic)
Now, let’s get the OpenAI API Key.
Getting OpenAI API Key
First, let’s go to the Codium AI GitHub repository and follow the installation instructions.
To get started with PR-Agent quickly, you first need to acquire an OpenAI key with access to GPT-4. Let’s do that.
Go to https://platform.openai.com/
You can then sign up
After signing up, log in to OpenAI.
This will lead you to the Welcome page.
When you hover over the left side bar menu, you will see an padlock icon called API keys.
Click on it.
We will then create an API key. I already created mine as you can see.
Click on the Create new secret
key button.
Give your secret key a name. In my case, I will name it For CodiumAI. You can give it any name you like.
You API key will be generated.
Make sure to copy it somewhere. We are going to use it.
With CodiumAI, you can use many Git platforms like GitHub, Gitlab and Bitbucket. In comparison to GitHub Copilot, you can only use it with GitHub.
Also, the Codium PR-Agent is available both on Git and IDE not just Git.
In our case, we will use the Git version using GitHub.
We will need to get a GitHub personal access token(classic) since it is one of the two requirements of using Codium.
Getting a GitHub Personal Access Token(Classic)
To get the GitHub Personal Access Token, lets head over to GitHub.
On the upper right corner, click on your profile picture then on Settings
.
In the left side bar, click on Developer settings
In the left side bar, under Personal Accecc Tokens, click on Tokens(classic).
Select generate new token
, then generate new token classic
In the Note
field, give your token a descriptive name.
To give your token an expiration, select Expiration
, then choose a default option or click Custom to enter a date.
Select the scopes you would like to grant this token.
Click the Generate token
button.
You can then copy the token somewhere for future reference.
Adding the secret to our repository
Before adding our secret, we need to have a repository.
Creating a new repository
So, let’s go to GitHub and create a repository.
First login to GitHub.
Then create a new repository
The name of our website will be bakery website
It is a public repository. Incase you want to fork it, here is the link to it: https://github.com/KarlGusta/bakery-website
Now to adding our Secrets
Go to the repository that you have just created.
Click on Settings
of the repository.
On the left side bar, click on Actions on the Secrets and Variables drop-down.
Click on New Repository Secret
button.
Here, we will add the Open AI key that we got from the OpenAI website.
For the name of the key, it is OPENAI_KEY
Make sure you name it exactly that way.
Click Add Secret
Cloning our repo to our local computer
We will then clone it to our local computer.
Let’s open it on VS Code.
We will create a simple index.html
to use it for the demo.
I have added a title and a little description of it.
Let’s see how it looks on the browser. I’m using a VS Code extension called Live Server
to view my page.
Here is the page.
Now, let’s push our changes to GitHub.
Adding GitHub Actions
We are going to use GitHub Actions.
To start lets create a .github/workflows/pr_agent.yml
file to add the action.
Created the folder .github
in VS Code by clicking the create folder icon.
Next, lets create the workflows folder inside .github
folder.
Now, lets create the file pr_agent.yml
inside the folder workflows
.
Inside the file, add this GitHub actions code.
on: pull_request: issue_comment:
jobs: pr_agent_job: runs-on: ubuntu-latest permissions: issues: write pull-requests: write contents: write name: Run pr agent on every pull request, respond to user comments steps: - name: PR Agent action step id: pragent uses: Codium-ai/pr-agent@main env: OPENAI_KEY: ${{ secrets.OPENAI_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Now lets push the changes to GitHub.
On the main branch, commit and push to GitHub.
Now, to testing the Codium PR Agent GitHub action.
Pushing changes to GitHub
The change has been pushed successfully as you can see.
Now, let’s a branch that we can use to test our Pull Requests.
Creating a branch to test Pull Requests
Call the branch new branch
and press ENTER.
Now, let’s make a few changes and publish it with the branch.
We now commit and push the new changes to GitHub. Notice we are on our new branch.
Click on Yes
.
Now back to our repository on GitHub.
Creating our first Pull Request
Let’s compare and make our Pull Request. Click the button Compare & Pull Request.
On the description, you can say write this Adding more content in the description
or anything.
Then click the button Create Pull Request
Click the merge button.
Now, lets test how Codium PR Agent works.
Testing how Codium PR Agent works
CodiumAI PR Agent supports many commands which we are going to look at today. For Codium, these include things like:
- Auto Description(/describe). This automatically generates the PR description. The title, type, summary, code walkthrough and labels.
- Auto Review(/review). Adjustable feedback about the PR main theme, type, relevant tests, security issues, score, and various suggestions for the PR content.
- Question Answering(/ask …). Answering free-text questions about the PR.
- Code Suggestions(/improve). Committable code suggestions for improving the PR.
- Update Changelog(/update_changelog). Automatically updating the CHANGELOG.md file with the PR changes.
- Find Similar Issue(/similar_issue). Automatically retrieves and presents similar issues.
- Add Documentation(/add_docs). Automatically adds documentation to un-documented functions/classes in the PR.
- Generate Custom Labels(/generate_labels). Automatically suggests custom labels based on the PR code changes.
Let us test the Auto Review(/review) command.
Testing the Auto Review command
After merging, under the comment section, write this command @CodiumAI-Agent /review
Then click the button comment.
Codium PR Agent will do a review for you. Here it is.
The review is very descriptive and easy to understand.
It analyses the PR giving you information about the main theme. In our case, it is to enhance website content.
It also gives you a PR Summary, Type of PR, if there are any tests added, estimated effort to review the PR, any security concerns and PR feedback.
When we try the Code suggestions, it shows us how we can improve our code.
You can test all the above commands to see how Codium can work to suit you best.
Happy Coding!
Karl