Skip to content

Commit

Permalink
docs: fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaitos committed Jul 15, 2024
1 parent ceca9bd commit 7489ebc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 110 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/ci.yml

This file was deleted.

99 changes: 53 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,65 @@
This action has been created to use OpenAI API to performs some custom analysis on pull request.
The bot will create and try to update (if existing) a comment with OpenAI result.

## Usage
## Example usage

> [!WARNING] A GitHub token with at least `read:user, repo` scopes is needed.
> [!WARNING]
> A personal GitHub token with at least `read:user, repo` scopes is needed.
1. Detect if your SQL migration will lock your database :
1. Detect if your Pull Request SQL migration will lock your database :

```yaml
review-sql-migration:
timeout-minutes: 5
name: Review SQL migrations
runs-on: ubuntu-latest
steps:
jobs:
review-sql-migrations:
name: Review SQL migrations
timeout-minutes: 3
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: Generate prompt
uses: actions/checkout@v4
- name: Generate prompt
run: |
echo -e "For each distinct SQL query (separated with a line starting by a + sign) at the end of my prompt, knowing that they will be executed into a single transaction, answer in the following format with suggestions and recommendations for how to avoid it, please precise if this locks will prevents other transactions from reading or writing to the table :

## Query 1:
\`\`\`sql
<SQL Query>
\`\`\`
Locking Analysis:
- <start with a warning emoji if this lock the database, then detailed analysis with bold result of the locking result>

Suggestions/Alternatives:
- <Detailed suggestions>

## Query 2:
\`\`\`sql
<SQL Query>
\`\`\`
Locking Analysis:
- <start with a warning emoji if this lock the database, then detailed analysis with bold result of the locking result>

Suggestions/Alternatives:
- <Detailed suggestions>" >> prompt.txt

echo OPENAI_PROMPT=$(cat prompt.txt) >> $GITHUB_ENV
echo OPENAI_SYSTEM_MESSAGE="You are a SQL expert and knowledgeable about large datasets in Postgres version $POSTGRES_VERSION."
env:
POSTGRES_VERSION: 15
- name: SQL Migration review
uses: appchoose/ai-pr-review@feat/v1
with:
prompt: ${{ env.OPENAI_PROMPT }}
openai_system_message: ${{ env.OPENAI_SYSTEM_MESSAGE }}
files_path: "path/to/your/migrations/"
github_token: ${{ secrets.AI_PR_REVIEW_GITHUB_TOKEN }}
github_pr_id: ${{ github.event.pull_request.number }}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
echo -e "Given a large dataset Postgres database version $POSTGRES_VERSION, for each distinct SQL query at the end of my prompt, knowing that they will be executed into a single transaction.
Please precise if each query will locks the table, which type of postgres lock it will uses and if it will prevents other transactions from reading or writing to the table.
Answer with suggestions and recommendations for how to avoid it (do not include NOWAIT option). Include indexes suggestions if you think he can speed up any query.
Your answer should follow the following format :
## Query 1:
\`\`\`sql
<SQL Query>
\`\`\`
Locking Analysis:
- <start with a warning emoji if this lock the database, then detailed analysis with bold result of the locking result>

Suggestions/Alternatives:
- <Detailed suggestions>

## Query 2:
\`\`\`sql
<SQL Query>
\`\`\`
Locking Analysis:
- <start with a warning emoji if this lock the database, then detailed analysis with bold result of the locking result>

Suggestions/Alternatives:
- <Detailed suggestions>" >> prompt.txt

echo OPENAI_PROMPT=$(cat prompt.txt) >> $GITHUB_ENV
echo OPENAI_SYSTEM_MESSAGE="You are a SQL expert and knowledgeable about large datasets in Postgres version $POSTGRES_VERSION."
env:
POSTGRES_VERSION: 15
- name: SQL Migration review
uses: appchoose/[email protected]
with:
prompt: ${{ env.OPENAI_PROMPT }}
openai_system_message: ${{ env.OPENAI_SYSTEM_MESSAGE }}
openai_model: "gpt-4"
openai_temperature: 0.1
files_path: "path/to/your/migrations/folders"
github_token: ${{ secrets.AI_PR_REVIEW_GITHUB_TOKEN }}
github_pr_id: ${{ github.event.pull_request.number }}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
```
This will comment your pull request like this :
Expand Down

0 comments on commit 7489ebc

Please sign in to comment.