Skip to content

The AI Code Review extension enables Azure DevOps teams to seamlessly integrate Azure Open AI into their Azure DevOps pull requests, providing automated code analysis to enhance the code review process

License

Notifications You must be signed in to change notification settings

tlaukkanen/azure-devops-ai-code-review

 
 

Repository files navigation

AI Code Review DevOps Extension

Buy Me A Coffee

Supercharge Your Code Reviews with Azure Open AI Services

Use your own Azure OpenAI service endpoints to provide pull request code reviews while keeping your code private.

  • AI Powered Insights: Optimized for latest LLM models like GPT-4o-mini, which provides optimal high performance with small cost.
  • Security and Privacy: Use your own Azure OpenAI model deployment for reviews
  • Automated Summaries: Let AI summarise your pull request so it's easier for humans to follow. AI will also provide feedback for all changes related to bugs, performance, best practices etc.
  • Easy to install: A simple one-click installation from the Azure DevOps Marketplace gets you up and running instantly. Configure to your pipeline as shown below.
  • Faster Reviews: Reduce the time spent on code reviews. Let Open AI handle the routine, allowing your team to focus on impactful work.
  • Configurable and Customizable: Tailor the extension to your needs with customizable settings. Specify the Open AI model, define file exclusions, and more.

Sample review

Click for larger version:

sample review

What does it cost?

The extension itself is free. The reviews will utilize your own Azure OpenAI services so it will depend on the model that you deploy. As of today October 2024 the GPT-4o-mini seems to be optimal for this purpose and is cheap to use - today price for input prompt was $0.15 per 1M tokens, output was $0.60 per 1M tokens. While completing many pull requests the price per code review ranges from ~$0.0002 to ~$0.002 per review - so if you have 1000 PRs per month it's a price of coffee 😉

You can set the token pricing on the task parameters and then you can see from your logs how much each of the reviews cost:

Prerequisites

Getting started

  1. Install the AI Code Review DevOps Extension from the Azure DevOps Marketplace.
  2. Add Open AI Code Review Task to Your Pipeline:
trigger:
  branches:
    exclude:
      - '*'

pr:
  branches:
    include:
      - '*'

jobs:
- job: CodeReview
  pool:
    vmImage: 'ubuntu-latest'
  steps:
  - task: AICodeReview@1
    inputs:
      azureOpenAiDeploymentEndpointUrl: $(AzureOpenAiDeploymentEndpoint)
      azureOpenAiApiKey: $(AzureOpenAiDeploymentKey)
      azureOpenAiApiVersion: "2024-07-01-preview"
      promptTokensPricePerMillionTokens: "0.15"
      completionTokensPricePerMillionTokens: "0.6"
      addCostToComments: true
      reviewBugs: true
      reviewPerformance: true
      reviewBestPractices: true
      reviewWholeDiffAtOnce: true
      maxTokens: 16384
      fileExtensions: '.js,.ts,.css,.html,.py,.tf'
      fileExcludes: 'file1.js,file2.py,secret.txt'
      additionalPrompts: |
        Fix variable naming, Ensure consistent indentation, Review error handling approach, Check for OWASP best practices
  1. If you do not already have Build Validation configured for your branch already add Build validation to your branch policy to trigger the code review when a Pull Request is created

FAQ

Q: What agent job settings are required?

A: Ensure that "Allow scripts to access OAuth token" is enabled as part of the agent job. Follow the documentation for more details.

Q: What permissions are required for Build Administrators?

A: Build Administrators must be given "Contribute to pull requests" access. Check this Stack Overflow answer for guidance on setting up permissions.

Bug Reports

If you find a bug or unexpected behavior, please open a bug report.

Feature Requests

If you have ideas for new features or enhancements, please submit a feature request.

License

This project is licensed under the MIT License.

If you would like to contribute to the development of this extension, please follow our contribution guidelines.

Project was originally forked from a1dancole/OpenAI-Code-Review.

About

The AI Code Review extension enables Azure DevOps teams to seamlessly integrate Azure Open AI into their Azure DevOps pull requests, providing automated code analysis to enhance the code review process

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%