Skip to content

Update cli.py

Update cli.py #8

Workflow file for this run

# Running tests with tox for releasing new version
name: Pull requests fosslight_source_scanner
on:
pull_request:
branches:
- '*'
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
- name: Install GoogleGenerativeAI
run: |
npm install @google/generative-ai
- name: Get git diff
run: |
git fetch origin "${{ github.event.pull_request.base.ref }}"
git fetch origin "${{ github.event.pull_request.head.ref }}"
git diff --unified=0 "origin/${{ github.event.pull_request.base.ref }}" > "diff.txt"
- name: Run Gemini-1.5-flash
uses: actions/github-script@v7
with:
script: |
const fs = require("fs");
const diff_output = fs.readFileSync("diff.txt",'utf8');
const { GoogleGenerativeAI } = require("@google/generative-ai");
const genAI = new GoogleGenerativeAI("${{ secrets.GEMINI_API_KEY }}");
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash"});
const prompt = `You are a senior software engineer and need to perform a code review based on the results of a given git diff. Review the changed code from different perspectives and let us know if there are any changes that need to be made. If you see any code that needs to be fixed in the result of the git diff, you need to calculate the exact line number by referring to the “@@ -0,0 +0,0 @@” part. The output format is \[{“path”:“{ filepath }”, “line”: { line }, “text”: { review comment }, “side”: “RIGHT"}\] format must be respected.\n<git diff>${diff_output}</git diff>`;
const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
fs.writeFileSync('res.txt',text);
console.log('Save Results!')
- name: output
id: store
run: |
COMMENT=$(sed '/^```/d' res.txt | jq -c .)
echo "comment=$COMMENT" >> $GITHUB_OUTPUT
- name: Add Pull Request Review Comment
uses: nbaztec/[email protected]
with:
comments: ${{ steps.store.outputs.comment }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
allow-repeats: false # This is the default
check-commit-message:
uses: fosslight/.github/.github/workflows/base-check-commit-message.yml@main
secrets:
envPAT: ${{ secrets.GITHUB_TOKEN }}
build:
strategy:
matrix:
python-version: [3.8, 3.11]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run Tox
run: |
tox -e release
reuse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1