Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

korbit-ai/korbit-mentor-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Korbit AI mentor action

The Korbit AI mentor for Software Engineering: Unlimited AI code reviews and mentoring across your team, 24/7.

In order to use this Github action, you must already have an account on mentor.korbit.ai and generated your secret id/key.

This Github action will allow you to integrate within your pipeline a Korbit AI mentor scan automatically.

Analysis in progress (1/1)
├── another_subfolder
│ ├── afile.py ⏳
│ └── afile.js ✅
└── subfolder
    ├── afile.py ✅
    └── afile.js ✅
Analyzing files (4)... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75% -:--:--
Analysis completed successfully! Report generation in progress...
Category: Potential Unwanted Behaviors
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Error Description                                  ┃ File Path   ┃ Confidence ┃ Priority ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ The return statement is not followed by any        │ subfolfolder│ 10         │ 10       │
│ expression, so the function will always return     │ /afile.js   │            │          │
│ undefined. The multiplication operation 'a \*      │             │            │          │
│ power' is unreachable and will never be executed.  │             │            │          │
└────────────────────────────────────────────────────┴─────────────┴────────────┴──────────┘

Final report contains 1 issues We ignored 2/3.
We found some issue in the code, see final report .korbit/4150_2023-08-30T16:41:18.131624_report.html
korbit scan command failed with exit code: 91

Secrets id/key

Once you have created your secret id/keys, you will need to add them into Github Action secrets.

  • KORBIT_SECRET_ID
  • KORBIT_SECRET_KEY

To know how to set those secrets for your repository on Github you can follow section of Github official documentation.

Now you should be able to continue and setup your github action workflow.

Inputs

name required type default description
path yes string . The path to the local file or folder to be scan.
threshold_priority false integer 0 Issues found must be above this priority score to be presented (on a scale of 0-10).
threshold_confidence false integer 0 Issues found must be above this confidence score to be presented (on a scale of 0-10).
headless false boolean true Will trigger an exit code if issues have been found on the given path (interrupting the pipeline).
headless_show_report false boolean false By default when the headless variable is set to true, nothing will be shown in the output logs. Setting headless_show_report variable to true will show Korbit scan report in the logs, in realtime.
secret_id true string The given secret id generated on mentor.korbit.ai/profile
secret_key true string The given secret key generated on mentor.korbit.ai/profile

Outputs

The action will print the final report, including any issues detected that meet your thresholds, in the github action summary tab.

Headless

As mention in the inputs, if you are using the headless option, the scan could exit with a 91 code. If your pipeline returns this code, it means that the pipeline will be stopped.

Examples usage

The following are two examples of using Korbit AI mentor in your CI/CD.

  1. First the scan will be run on every push you make to your repository.
  2. Secondly on demand, korbit will generate a scan on a specified file or folder. This is triggered manually from Github Action tab of your repository.

On push

To create the relevant github action triggered on push, create a new workflow file .github/workflows/korbit_mentor_check_on_push.yaml.

name: On push repository scan
on: [push]

jobs:
  check_files:
    runs-on: ubuntu-latest
    name: An example of using the Korbit AI mentor github action
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Check file using local github action
        uses: korbit-ai/korbit-mentor-action@v1
        id: check
        with:
          path: "." # Change this to the folder you want to scan
          threshold_confidence: 9 # Set your own threshold (0-10)
          threshold_priority: 9 # Set your own threshold (0-10)
          headless_show_report: true
          headless: true
          secret_id: ${{ secrets.KORBIT_SECRET_ID }}
          secret_key: ${{ secrets.KORBIT_SECRET_KEY }}

Note: You can setup .korbitignore to ignore specific files/folders from being scans, see documentation.

On workflow dispatch

To create the relevant github action that you can triggered manually, create a new workflow file .github/workflows/korbit_mentor_check_on_demand.yaml.

name: Korbit mentor manual scan request

on:
  workflow_dispatch:
    inputs:
      path:
        description: "Path to scan"
        default: "."
        required: true
jobs:
  scan-code:
    name: An example of using the Korbit AI mentor github action
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Scan path
        uses: korbit-ai/korbit-mentor-action@v1
        id: check
        with:
          path: ${{ github.event.inputs.path }}
          threshold_confidence: 10 # Set your own threshold (0-10)
          threshold_priority: 10 # Set your own threshold (0-10)
          headless: false
          secret_id: ${{ secrets.KORBIT_SECRET_ID }}
          secret_key: ${{ secrets.KORBIT_SECRET_KEY }}

Troubleshooting

When setting up the Korbit AI mentor Github action, you might encounter some problems. If you see that the workflow, return a certain exit code here is the explanation of what they means:

exit code description
0 Success! Korbit ran a scan, code met thresholds and pipeline completed.
90 Something went wrong and we don't know why, please contact [email protected].
91 You have set your action to run using the headless option, and Korbit AI mentor found issues in your code that are above the thresholds you set.
92 Something went wrong while we were analyzing your file(s), please contact [email protected].
93 The login credentials aren't set properly. Refer to "Secrets id/key" section or in our documentation.