Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
sturdy-dev

GitHub Action

Codeball AI Code Review

v2.1.0

Codeball AI Code Review

sturdy-dev

Codeball AI Code Review

AI Code Review – Codeball approves Pull Requests that a human would have approved. Wait less for review, save time and money

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Codeball AI Code Review

uses: sturdy-dev/[email protected]

Learn more about this action in sturdy-dev/codeball-action

Choose a version

Codeball

CODEBALL — AI CODE REVIEW 🔮

Codeball is a code review AI which approves Pull Requests that a human would have approved. Spend less time waiting, save time and money.

The AI identifies and approves safe contributions, so that you get to focus your energy on the tricky ones.

GitHub Action

The Codeball GitHub Action runs Codeball on all new Pull Requests, and approves the Pull Request (example) if the model classifies it as safe.

Quick Start

  1. Create a new file called .github/workflows/codeball.yml with the following content:
name: Codeball
on: [pull_request]

jobs:
  codeball_job:
    runs-on: ubuntu-latest
    name: Codeball
    steps:
      - name: Codeball
        uses: sturdy-dev/codeball-action@v2
        with:
          approvePullRequests: "true"
          labelPullRequestsWhenApproved: "true"
          labelPullRequestsWhenReviewNeeded: "false"
          failJobsWhenReviewNeeded: "false"
  1. 🎉 That's it! Codeball will now run on new Pull Requests, and will approve the PR if it's a good one!

Customizations

Codeball Actions are built on multiple smaller building-blocks, that are heavily configurable through GitHub Actions. Here's a few examples:

If you're using Codeball in another way, please let us know in an issue!

Example: "Dry-run" mode, labels all PRs with the Codeball Result

▶️ codeball-dry-run.yml
name: Codeball
on: [pull_request]

jobs:
  codeball_job:
    runs-on: ubuntu-latest
    name: Codeball
    steps:
      - name: Codeball
        uses: sturdy-dev/codeball-action@v2
        with:
          approvePullRequests: "false"
          labelPullRequestsWhenApproved: "true"
          labelPullRequestsWhenReviewNeeded: "true"
          failJobsWhenReviewNeeded: "false"

Example: Approve only (no labels)

▶️ codeball-approve.yml
name: Codeball
on: [pull_request]

jobs:
  codeball_job:
    runs-on: ubuntu-latest
    name: Codeball
    steps:
      - name: Codeball
        uses: sturdy-dev/codeball-action@v2
        with:
          approvePullRequests: "true"
          labelPullRequestsWhenApproved: "false"
          labelPullRequestsWhenReviewNeeded: "false"
          failJobsWhenReviewNeeded: "false"

Example: Filter files (run only for PRs modifying a single service)

▶️ codeball-filter-files.yml
name: Codeball
on:
  pull_request:
    # Run Codeball only if files under "/web/" has been modified (and no other files)
    # See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-paths
    paths:
      - '!**'
      - '/web/**'

jobs:
  codeball_job:
    runs-on: ubuntu-latest
    name: Codeball
    steps:
      - name: Codeball
        uses: sturdy-dev/codeball-action@v2
        with:
          approvePullRequests: "true"
          labelPullRequestsWhenApproved: "true"
          labelPullRequestsWhenReviewNeeded: "false"
          failJobsWhenReviewNeeded: "false"

Example: Fail the Codeball Action (❌) if Codeball does not approve the contribution

▶️ codeball-fail-not-approved.yml
name: Codeball
on: [pull_request]

jobs:
  codeball_job:
    runs-on: ubuntu-latest
    name: Codeball
    steps:
      - name: Codeball
        uses: sturdy-dev/codeball-action@v2
        with:
          approvePullRequests: "true"
          labelPullRequestsWhenApproved: "true"
          labelPullRequestsWhenReviewNeeded: "false"
          failJobsWhenReviewNeeded: "true"

Building Blocks

The Codeball sub-actions are:

How Codeball works

Codeball uses a deep learning model that has been trained on over 1 million Pull Requests. For each contribution it considers in hundreds of inputs, including:

  • The code diffs (perceptual hashes)
  • The author's recent experience with the affected files
  • The change frequency of the affected files
  • Past code reversals / fix-ups

Codeball is optimized for precision, which means it only approves contributions that it's really confident in.

Troubleshooting

Permissions

Codeball works out of the box with GitHub Actions.

If you're using non-default permissions, or want to use a custom access token. Make sure that you're running Codeball with the following permissions:

permissions:
  contents: read
  issues: write
  pull-requests: write

Forks and private repositories

By default, pull requests from a fork does not have "write" permissions when running in GitHub Actions, and those Pull Requests can not be approved or labeled.

If you're using forks from a private repository, and want to use Codeball on Pull Requests created from a fork. Enable "Send write tokens to workflows from fork pull requests" on the repository (docs).