Skip to content

Commit 3889335

Browse files
chore: add lint workflow for PRs
Adds a Lint workflow that fans out via a new root `lint` script (mirroring the existing `test` script's foreach pattern) and fixes the existing no-explicit-any errors in the review-agent test files so the workflow lands green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 70b8c70 commit 3889335

6 files changed

Lines changed: 47 additions & 11 deletions

File tree

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: "true"
18+
- name: Use Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20.x'
22+
23+
- name: Install
24+
run: yarn install --frozen-lockfile
25+
26+
- name: Lint
27+
run: yarn lint

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"build": "cross-env SKIP_ENV_VALIDATION=1 yarn workspaces foreach --all --topological run build",
88
"test": "yarn workspaces foreach --all --topological run test",
9+
"lint": "yarn workspaces foreach --all --topological run lint",
910
"dev": "concurrently --kill-others --names \"zoekt,worker,web,schemas\" 'yarn dev:zoekt' 'yarn dev:backend' 'yarn dev:web' 'yarn watch:schemas'",
1011
"with-env": "cross-env PATH=\"$PWD/bin:$PATH\" dotenv -e .env.development -c --",
1112
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",

packages/web/src/features/agents/review-agent/nodes/githubPrParser.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test, vi, describe } from 'vitest';
2+
import { Octokit } from 'octokit';
23
import { githubPrParser } from './githubPrParser';
34
import { GitHubPullRequest } from '../types';
45

@@ -50,7 +51,7 @@ function makePullRequest(overrides: Partial<{
5051
function makeMockOctokit(diffText: string) {
5152
return {
5253
request: vi.fn().mockResolvedValue({ data: diffText }),
53-
} as any;
54+
} as unknown as Octokit;
5455
}
5556

5657
describe('githubPrParser', () => {
@@ -80,7 +81,7 @@ describe('githubPrParser', () => {
8081

8182
test('fetches diff using the pull request diff_url', async () => {
8283
const mockRequest = vi.fn().mockResolvedValue({ data: '' });
83-
const octokit = { request: mockRequest } as any;
84+
const octokit = { request: mockRequest } as unknown as Octokit;
8485
const pr = makePullRequest({ diff_url: 'https://github.com/my-org/my-repo/pull/7.diff' });
8586

8687
await githubPrParser(octokit, pr);
@@ -184,7 +185,7 @@ describe('githubPrParser', () => {
184185
test('throws when the diff request fails', async () => {
185186
const octokit = {
186187
request: vi.fn().mockRejectedValue(new Error('Network error')),
187-
} as any;
188+
} as unknown as Octokit;
188189
const pr = makePullRequest();
189190

190191
await expect(githubPrParser(octokit, pr)).rejects.toThrow('Network error');

packages/web/src/features/agents/review-agent/nodes/githubPushPrReviews.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test, vi, describe } from 'vitest';
2+
import { Octokit } from 'octokit';
23
import { githubPushPrReviews } from './githubPushPrReviews';
34
import { sourcebot_pr_payload, sourcebot_file_diff_review } from '../types';
45

@@ -38,7 +39,7 @@ function makeMockOctokit(createReviewCommentResult: 'resolve' | 'reject' = 'reso
3839
: vi.fn().mockRejectedValue(new Error('Unprocessable Entity')),
3940
},
4041
},
41-
} as any;
42+
} as unknown as Octokit;
4243
}
4344

4445
describe('githubPushPrReviews', () => {
@@ -123,7 +124,7 @@ describe('githubPushPrReviews', () => {
123124
const mockCreate = vi.fn()
124125
.mockRejectedValueOnce(new Error('422'))
125126
.mockResolvedValueOnce({});
126-
const octokit = { rest: { pulls: { createReviewComment: mockCreate } } } as any;
127+
const octokit = { rest: { pulls: { createReviewComment: mockCreate } } } as unknown as Octokit;
127128

128129
await githubPushPrReviews(octokit, MOCK_PAYLOAD, twoReviews);
129130

packages/web/src/features/agents/review-agent/nodes/gitlabMrParser.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { expect, test, vi, describe } from 'vitest';
2+
import { Gitlab } from '@gitbeaker/rest';
23
import { gitlabMrParser } from './gitlabMrParser';
34
import { GitLabMergeRequestPayload } from '../types';
45

6+
type GitlabClient = InstanceType<typeof Gitlab>;
7+
58
vi.mock('@sourcebot/shared', () => ({
69
createLogger: () => ({
710
debug: vi.fn(),
@@ -51,7 +54,7 @@ function makeMockGitlabClient(allDiffsResult: unknown, mrOverrides: Partial<type
5154
show: vi.fn().mockResolvedValue({ ...MOCK_MR_API_RESPONSE, ...mrOverrides }),
5255
allDiffs: vi.fn().mockResolvedValue(allDiffsResult),
5356
},
54-
} as any;
57+
} as unknown as GitlabClient;
5558
}
5659

5760
describe('gitlabMrParser', () => {
@@ -100,7 +103,7 @@ describe('gitlabMrParser', () => {
100103
test('calls show and allDiffs with the correct project id and MR iid', async () => {
101104
const mockShow = vi.fn().mockResolvedValue(MOCK_MR_API_RESPONSE);
102105
const mockAllDiffs = vi.fn().mockResolvedValue([]);
103-
const client = { MergeRequests: { show: mockShow, allDiffs: mockAllDiffs } } as any;
106+
const client = { MergeRequests: { show: mockShow, allDiffs: mockAllDiffs } } as unknown as GitlabClient;
104107

105108
await gitlabMrParser(client, MOCK_MR_PAYLOAD, 'gitlab.com');
106109

@@ -244,7 +247,7 @@ describe('gitlabMrParser', () => {
244247
show: vi.fn().mockResolvedValue(MOCK_MR_API_RESPONSE),
245248
allDiffs: vi.fn().mockRejectedValue(new Error('Network error')),
246249
},
247-
} as any;
250+
} as unknown as GitlabClient;
248251

249252
await expect(gitlabMrParser(client, MOCK_MR_PAYLOAD, 'gitlab.com')).rejects.toThrow('Network error');
250253
});

packages/web/src/features/agents/review-agent/nodes/gitlabPushMrReviews.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { expect, test, vi, describe } from 'vitest';
2+
import { Gitlab } from '@gitbeaker/rest';
23
import { gitlabPushMrReviews } from './gitlabPushMrReviews';
34
import { sourcebot_pr_payload, sourcebot_file_diff_review } from '../types';
45

6+
type GitlabClient = InstanceType<typeof Gitlab>;
7+
58
vi.mock('@sourcebot/shared', () => ({
69
createLogger: () => ({
710
debug: vi.fn(),
@@ -44,7 +47,7 @@ function makeMockClient(discussionResult: 'resolve' | 'reject' = 'resolve') {
4447
MergeRequestNotes: {
4548
create: vi.fn().mockResolvedValue({}),
4649
},
47-
} as any;
50+
} as unknown as GitlabClient;
4851
}
4952

5053
describe('gitlabPushMrReviews', () => {
@@ -165,7 +168,7 @@ describe('gitlabPushMrReviews', () => {
165168
const client = {
166169
MergeRequestDiscussions: { create: mockCreate },
167170
MergeRequestNotes: { create: vi.fn().mockResolvedValue({}) },
168-
} as any;
171+
} as unknown as GitlabClient;
169172

170173
await gitlabPushMrReviews(client, 101, MOCK_PAYLOAD, twoReviews);
171174

@@ -178,7 +181,7 @@ describe('gitlabPushMrReviews', () => {
178181
const client = {
179182
MergeRequestDiscussions: { create: vi.fn().mockRejectedValue(new Error('500')) },
180183
MergeRequestNotes: { create: vi.fn().mockRejectedValue(new Error('500')) },
181-
} as any;
184+
} as unknown as GitlabClient;
182185

183186
await expect(
184187
gitlabPushMrReviews(client, 101, MOCK_PAYLOAD, SINGLE_REVIEW),

0 commit comments

Comments
 (0)