Skip to content

Commit da1d9c8

Browse files
committed
fixup! feat(github-actions): create a github action to run a code review on incoming PRs
1 parent 14e1207 commit da1d9c8

5 files changed

Lines changed: 16 additions & 19 deletions

File tree

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ github-actions/post-approval-changes/main.js
1414
github-actions/previews/pack-and-upload-artifact/inject-artifact-metadata.js
1515
github-actions/previews/upload-artifacts-to-firebase/extract-artifact-metadata.js
1616
github-actions/previews/upload-artifacts-to-firebase/fetch-workflow-artifact.js
17+
github-actions/review-bot/main.js
1718
github-actions/saucelabs/set-saucelabs-env.js
1819
github-actions/labeling/issue/main.js
1920
github-actions/slash-commands/main.js

github-actions/review-bot/lib/gemini.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {GoogleGenAI, Type} from '@google/genai';
22
import {Octokit} from '@octokit/rest';
33
import * as core from '@actions/core';
4-
import { CodeReview } from './github';
4+
import {CodeReview} from './github';
55

66
const LLM_MODEL = 'gemini-2.5-pro';
77

@@ -15,8 +15,7 @@ export async function performCodeReview(
1515
repo: string,
1616
ref: string,
1717
): Promise<CodeReview | null> {
18-
const ai = new GoogleGenAI({apiKey});
19-
18+
const ai = new GoogleGenAI({apiKey});
2019

2120
// Create a function declaration for our GitHub search tool
2221
const searchCodebaseTool = {

github-actions/review-bot/lib/github.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import {context} from '@actions/github'
1+
import {context} from '@actions/github';
22
import {Octokit} from '@octokit/rest';
33

4-
54
export interface CodeReview {
65
body: string;
76
comments: {
87
path: string;
98
line: number;
10-
body: string
9+
body: string;
1110
}[];
1211
}
1312

@@ -32,7 +31,6 @@ export async function getPullRequestDiff(octokit: Octokit): Promise<string> {
3231
* Gets the full contents of all files that were modified in the pull request.
3332
*/
3433
export async function getModifiedFilesContext(octokit: Octokit, ref: string) {
35-
3634
// Get list of files changed in the PR
3735
const filesResponse = await octokit.rest.pulls.listFiles({
3836
owner: context.repo.owner,
@@ -78,8 +76,10 @@ export async function getModifiedFilesContext(octokit: Octokit, ref: string) {
7876
/**
7977
* Gets the text of any failed check runs for the commit, which may contain lint errors or test failures.
8078
*/
81-
export async function getFailedChecks(octokit: Octokit, ref: string): Promise<{name: string; output: string | null}[]> {
82-
79+
export async function getFailedChecks(
80+
octokit: Octokit,
81+
ref: string,
82+
): Promise<{name: string; output: string | null}[]> {
8383
// Keep the query broad because our action runs, so some checks might still be 'in_progress' or 'queued'. We want 'completed' -> 'failure'
8484
const checksResponse = await octokit.rest.checks.listForRef({
8585
owner: context.repo.owner,
@@ -113,7 +113,10 @@ export async function getFailedChecks(octokit: Octokit, ref: string): Promise<{n
113113
/**
114114
* Posts the review comment to the pull request.
115115
*/
116-
export async function postReviewComment(octokit: Octokit, {body, comments}: CodeReview): Promise<void> {
116+
export async function postReviewComment(
117+
octokit: Octokit,
118+
{body, comments}: CodeReview,
119+
): Promise<void> {
117120
await octokit.rest.pulls.createReview({
118121
owner: context.repo.owner,
119122
repo: context.repo.repo,

github-actions/review-bot/lib/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ async function run(): Promise<void> {
5656

5757
if (reviewResult) {
5858
core.info('Posting Gemini review comment to PR...');
59-
await postReviewComment(
60-
octokit,
61-
reviewResult
62-
);
59+
await postReviewComment(octokit, reviewResult);
6360
core.info('Review comment posted successfully.');
6461
} else {
6562
core.info('Gemini did not return a review comment.');

github-actions/review-bot/main.js

Lines changed: 2 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)