AI-native design editor. Open-source Figma alternative.
fix(ci): install the review guidance tool's dependencies (#891)
Danila Poyarkov244757a6684a
diff --git a/.github/workflows/pr-review-guidance.yml b/.github/workflows/pr-review-guidance.ymlindex 846e6be52..27a006e7a 100644--- a/.github/workflows/pr-review-guidance.yml+++ b/.github/workflows/pr-review-guidance.yml@@ -25,17 +25,13 @@ jobs:ref: ${{ github.event.repository.default_branch }}persist-credentials: false- - name: Set up Node.js- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020+ # Dependencies come from the default branch's lockfile, like the script itself.+ - uses: ./.github/actions/setup-bunwith:- node-version: 24+ install-args: --frozen-lockfile --filter @open-pencil/pr-review-guidance-tools+ cache-scope: pr-review-guidance- name: Record CodeRabbit review guidanceenv:GITHUB_TOKEN: ${{ github.token }}- run: |- if [ ! -f tools/ci/pr-review-guidance/src/index.ts ]; then- echo "Trusted PR review guidance helper is not present on the default branch yet."- exit 0- fi- node --experimental-strip-types tools/ci/pr-review-guidance/src/index.ts+ run: bun tools/ci/pr-review-guidance/src/index.tsdiff --git a/bun.lock b/bun.lockindex 4867f46d6..8f73cd3be 100644--- a/bun.lock+++ b/bun.lock@@ -511,6 +511,9 @@},"tools/ci/pr-review-guidance": {"name": "@open-pencil/pr-review-guidance-tools",+ "dependencies": {+ "valibot": "^1.5.0",+ },},"tools/dev/dev-server": {"name": "@open-pencil/dev-server-tools",diff --git a/tools/ci/pr-review-guidance/package.json b/tools/ci/pr-review-guidance/package.jsonindex 5fe00d275..8a8f2fbe5 100644--- a/tools/ci/pr-review-guidance/package.json+++ b/tools/ci/pr-review-guidance/package.json@@ -4,5 +4,8 @@"type": "module","scripts": {"test": "bun test tests"+ },+ "dependencies": {+ "valibot": "^1.5.0"}}diff --git a/tools/ci/pr-review-guidance/src/index.ts b/tools/ci/pr-review-guidance/src/index.tsindex 1203312bf..e1b5b50e5 100644--- a/tools/ci/pr-review-guidance/src/index.ts+++ b/tools/ci/pr-review-guidance/src/index.ts@@ -6,17 +6,18 @@ import * as v from 'valibot'const CODE_RABBIT_AUTHORS = new Set(['coderabbitai[bot]', 'coderabbitai'])const REVIEW_GUIDANCE_PREFIXES = ['pr hygiene', 'pr readability', 'pr description']+// Webhook payloads send `null` for absent fields, such as the body of a review left without one.const GitHubEventJSON = v.pipe(v.string(),v.parseJson(),v.object({- sender: v.optional(v.object({ login: v.optional(v.string()) })),- review: v.optional(v.object({ state: v.optional(v.string()), body: v.optional(v.string()) })),- pull_request: v.optional(v.object({ number: v.optional(v.number()) })),- issue: v.optional(- v.object({ number: v.optional(v.number()), pull_request: v.optional(v.unknown()) })+ sender: v.nullish(v.object({ login: v.nullish(v.string()) })),+ review: v.nullish(v.object({ state: v.nullish(v.string()), body: v.nullish(v.string()) })),+ pull_request: v.nullish(v.object({ number: v.nullish(v.number()) })),+ issue: v.nullish(+ v.object({ number: v.nullish(v.number()), pull_request: v.nullish(v.unknown()) })),- comment: v.optional(v.object({ body: v.optional(v.string()) }))+ comment: v.nullish(v.object({ body: v.nullish(v.string()) }))}))@@ -37,7 +38,7 @@ const PullRequestSummarySchema: v.GenericSchema<unknown, PullRequestSummary> = v})interface EventContext {- issueNumber?: number+ issueNumber?: number | nullshouldInspect: booleantext: string}diff --git a/tools/ci/pr-review-guidance/tests/index.test.ts b/tools/ci/pr-review-guidance/tests/index.test.tsindex 8a6525a7a..4ad22361f 100644--- a/tools/ci/pr-review-guidance/tests/index.test.ts+++ b/tools/ci/pr-review-guidance/tests/index.test.ts@@ -113,6 +113,31 @@ describe('monitorPRReviewGuidance', () => {expect(messages.join('\n')).toContain('No automatic label, comment, or close was applied')})+ test('accepts the null fields GitHub sends for absent values', async () => {+ const eventPath = await writeEvent({+ sender: { login: 'coderabbitai[bot]' },+ review: { state: 'commented', body: null },+ pull_request: { number: 294 },+ issue: null,+ comment: null+ })+ const messages: string[] = []++ await monitorPRReviewGuidance({+ env: {+ GITHUB_API_URL: 'https://example.test',+ GITHUB_EVENT_PATH: eventPath,+ GITHUB_REPOSITORY: 'open-pencil/open-pencil',+ GITHUB_REPOSITORY_OWNER: 'open-pencil',+ GITHUB_TOKEN: 'token'+ },+ fetchImpl: async () => response({}),+ log: (message) => messages.push(message)+ })++ expect(messages).toEqual(['No PR review guidance signal found.'])+ })+test('ignores non-CodeRabbit comments', async () => {const eventPath = await writeEvent({sender: { login: 'contributor' },