Fixed issues around the Azure OpenAI API in the code reviewer

This commit is contained in:
Jimmy Royer 2024-09-04 17:14:09 -04:00
parent cb0db573b8
commit ea35bd1354
15 changed files with 5705 additions and 348 deletions

3
act/codereview.vars Normal file
View file

@ -0,0 +1,3 @@
OPENAI_BASE_URL=https://cds-snc.openai.azure.com/openai/deployments/gpt-4o/
OPENAI_API_MODEL=gpt-4o
OPENAI_API_VERSION=2024-02-15-preview

10
act/event.json Normal file
View file

@ -0,0 +1,10 @@
{
"action": "opened",
"repository": {
"owner": {
"login": "cds-snc"
},
"name": "cds-ai-codereviewer"
},
"number": 3
}

28
act/fixtures/action.yml Normal file
View file

@ -0,0 +1,28 @@
name: "CDS AI Code Review Action (act fixture)"
description: "Perform code reviews and comment on diffs using OpenAI API."
inputs:
GITHUB_TOKEN:
description: "GitHub token to interact with the repository."
required: true
OPENAI_API_KEY:
description: "OpenAI API key for GPT."
required: true
OPENAI_API_MODEL:
description: "OpenAI API model."
required: true
OPENAI_API_VERSION:
description: "OpenAI API version."
required: true
OPENAI_BASE_URL:
description: "Base URL to the OpenAI API model (OpenAI or Azure)."
required: true
exclude:
description: "Glob patterns to exclude files from the diff analysis"
required: false
default: ""
runs:
using: "node16"
main: "dist/index.js"
branding:
icon: "aperture"
color: "green"

View file

@ -0,0 +1,25 @@
name: CDS Code Review with OpenAI
on:
pull_request:
types:
- opened
- synchronize
permissions: write-all
jobs:
code_review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
path: ./
- name: Code Review
uses: ./act/fixtures/
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_MODEL: ${{ vars.OPENAI_API_MODEL }}
OPENAI_API_VERSION: ${{ vars.OPENAI_API_VERSION }}
OPENAI_BASE_URL: ${{ vars.OPENAI_BASE_URL }}
exclude: "yarn.lock,dist/**"