Skip to content

Automate PR reviews in Azure DevOps using OpenAI. This bot analyzes code changes, offers suggestions, detects potential bugs, and ensures adherence to coding standards. Streamline code reviews with customizable criteria and natural language feedback, improving code quality and reducing review time.

License

Notifications You must be signed in to change notification settings

ewellnitz/pr-inspection-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pull Request Inspection Assistant (PRIA) - OpenAI PR Review Bot for Azure DevOps

Automate pull request (PR) reviews in Azure DevOps using the PR Inspection Assistant (PRIA) and OpenAI. This bot analyzes code changes, offers suggestions, detects potential bugs, and ensures adherence to coding standards. Streamline code reviews with customizable criteria and natural language feedback, improving code quality and reducing review time.

Key Features

  • Automated PR Reviews: Leverage OpenAI to analyze code changes in pull requests.
  • Supports Azure OpenAI: Isolate your reviews using your own internal model deployments in Azure AI Foundry.
  • Code Quality Suggestions: Detect potential issues and ensure best practices are followed.
  • Customizable Review Criteria: Tailor the bot to specific code quality metrics.
  • Azure DevOps Integration: Seamlessly integrates with existing DevOps pipelines.
  • Natural Language Feedback: Provides human-readable, actionable feedback.

Use Cases

  • Automate Routine PR Tasks: Speed up the code review process by automating common review tasks.
  • Improve Code Quality: Receive consistent, detailed feedback to enhance code quality.
  • Early Bug Detection: Help developers understand best practices and identify bugs early in the development cycle.

Process

Prerequisites

If Using Azure OpenAI

  • A generated API key for you OpenAI service
  • Your service endpoint URL e.g., https://my-resource.azure.openai.com/
  • A deployed model
    • By default the task will try to use a deployment called 'o1-mini'
    • Valid options are:
      • 'o1-mini'
      • 'o1-preview'
      • 'gpt-4o'
      • 'gpt-4'
      • 'gpt-3.5-turbo'
  • A designated API version. Defaults to '2024-10-21'

Learn more about Azure AI Foundry

Getting Started

1. Install the PRIA DevOps Extension

Install the PRIA DevOps extension from the Azure DevOps Marketplace.

2. Create a PRIA Code Review Pipeline

Create an Azure DevOps Pipeline using the following YAML snippet to set up the PRIA code review task:

OpenAI API

trigger: none

jobs:
  - job: CodeReview
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - checkout: self
        persistCredentials: true
      - task: PRIA@2
        inputs:
          api_key: '$(OpenAI_ApiKey)'

Azure OpenAI

trigger: none

jobs:
  - job: CodeReview
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - checkout: self
        persistCredentials: true
      - task: PRIA@2
        inputs:
          api_key: '$(OpenAI_ApiKey)'
          api_version: '2024-10-21'
          api_endpoint: 'https://my-foundry-project.openai.azure.com/'
          ai_model: 'gpt-4o'

3. Optional Task Inputs

Additional input options can be set to tailor how the code is reviewed.

Input Type Default Description
bugs Boolean false Specify whether to enable bug checking during the code review process.
performance Boolean false Specify whether to include performance checks during the code review process.
best_practices Boolean false Specify whether to include checks for missed best practices during the code review process.
modified_lines_only Boolean true Specify whether to check modified lines only.
file_extensions String null Specify a comma-separated list of file extensions for which you want to perform a code review.
file_excludes String null Specify a comma-separated list of file names that should be excluded from code reviews.
additional_prompts String null Specify additional OpenAI prompts as a comma-separated list to enhance the code review.

4. Configure your Main Branch for Build Validation

Note that pr triggers do not work in Azure repos.

Cofigure Azure DevOps branch policies to use the PRIA Code Review Pipeline created above as a build validation pipeline.

Build & Publish

  1. Install Prequisites
  2. Run npm install -g typescript to install TypeScript
  3. Run npm install -g tfx-cli to install tfx
  4. Install dependencies and build extension
# Navigate to src and install
$ cd pr-inspection-assistant/src
$ npm install

# Build typescript and package .vsix file
$ npm run package

Resources

About

Automate PR reviews in Azure DevOps using OpenAI. This bot analyzes code changes, offers suggestions, detects potential bugs, and ensures adherence to coding standards. Streamline code reviews with customizable criteria and natural language feedback, improving code quality and reducing review time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •