From 66227ff87171acbb1a8e5bd604943c4e3d70a9d1 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 2 Dec 2026 12:30:15 -0500 Subject: [PATCH] feat(python-cli-parity): publish GitLab merge request notes --- .gitignore | 3 + docs/commands/ci.md | 18 ++ src/commands/ci/handle-ci.mts | 41 ++++ src/commands/ci/publish-gitlab-mr-notes.mts | 105 ++++++++ .../ci/publish-gitlab-mr-notes.test.mts | 228 ++++++++++++++++++ src/commands/ci/publish-pr-comments.mts | 54 +++-- src/utils/api.mts | 5 + src/utils/gitlab.mts | 102 ++++++++ test/release-history.test.mts | 2 + 9 files changed, 541 insertions(+), 17 deletions(-) create mode 100644 src/commands/ci/publish-gitlab-mr-notes.mts create mode 100644 src/commands/ci/publish-gitlab-mr-notes.test.mts create mode 100644 src/utils/gitlab.mts diff --git a/.gitignore b/.gitignore index 282f2d317..24e24c49d 100644 --- a/.gitignore +++ b/.gitignore @@ -879,6 +879,9 @@ !/src/utils/github-errors.mts !/src/utils/github-errors.test.mts !/src/utils/github.mts +!/src/utils/gitlab.mts +!/src/commands/ci/publish-gitlab-mr-notes.mts +!/src/commands/ci/publish-gitlab-mr-notes.test.mts !/src/commands/ci/publish-pr-comments.mts !/src/commands/ci/publish-pr-comments.test.mts !/src/utils/glob-content-dedup.test.mts diff --git a/docs/commands/ci.md b/docs/commands/ci.md index f059809e3..e34aff45c 100644 --- a/docs/commands/ci.md +++ b/docs/commands/ci.md @@ -20,3 +20,21 @@ and `diff-scans:list` for the diff and its comments. Set `SOCKET_CLI_DISABLE_OVERVIEW_COMMENT=true` or `SOCKET_CLI_DISABLE_SECURITY_COMMENT=true` to skip either comment. + +GitLab merge request notes are opt-in. Set +`SOCKET_CLI_ENABLE_GITLAB_MR_NOTES=true` in a GitLab merge request pipeline to +let `socket ci` publish and update the same overview and security notes. This +opt-in avoids duplicate notes when a managed Socket integration already posts +them. The pipeline needs `CI_SERVER_URL`, `CI_API_V4_URL`, +`CI_MERGE_REQUEST_IID`, `CI_MERGE_REQUEST_PROJECT_ID`, and +`CI_MERGE_REQUEST_PROJECT_URL`. Notes are written to the target project, +including for merge requests from forks. + +For a personal or project access token, set `SOCKET_CLI_GITLAB_TOKEN` (or +`GITLAB_TOKEN`) to a token with the `api` scope and at least Developer access +to the target project. `CI_JOB_TOKEN` cannot create merge request notes through +GitLab's [Notes API](https://docs.gitlab.com/api/notes/) (job-token access is +limited to selected endpoints), so it is not sufficient for publishing. Do not +expose a long-lived access token to untrusted fork pipelines. +The Socket API token still needs `full-scans:list`, `diff-scans:create`, and +`diff-scans:list` to fetch the diff and rendered comments. diff --git a/src/commands/ci/handle-ci.mts b/src/commands/ci/handle-ci.mts index f5a9434b8..5bd7cb32b 100644 --- a/src/commands/ci/handle-ci.mts +++ b/src/commands/ci/handle-ci.mts @@ -1,11 +1,13 @@ import { detectCiPullRequestContext } from './detect-ci-pull-request-context.mts' import { getDefaultOrgSlug } from './fetch-default-org-slug.mts' +import { publishGitLabMergeRequestNotes } from './publish-gitlab-mr-notes.mts' import { publishPullRequestComments } from './publish-pr-comments.mts' import { selectBaselineScan } from './select-baseline-scan.mts' import constants from '../../constants.mts' import { setCiExitCode } from '../../utils/ci-exit-code.mts' import { debugDir, debugFn } from '../../utils/debug.mts' import { envAsBoolean } from '../../utils/env.mts' +import { errorMessage } from '../../utils/errors.mts' import { detectDefaultBranch, getRepoName, @@ -76,6 +78,45 @@ export async function handleCi(autoManifest: boolean): Promise { pullRequest, baselineScanId, onDiffReport: async diffScanId => { + if ( + pullRequestContext.provider === 'gitlab' && + envAsBoolean(process.env['SOCKET_CLI_ENABLE_GITLAB_MR_NOTES']) + ) { + // GitLab publication is opt-in because a managed Socket integration may + // already own these notes. Use GitLab's target project ID for fork MRs. + const projectId = process.env['CI_MERGE_REQUEST_PROJECT_ID'] + const projectUrl = process.env['CI_MERGE_REQUEST_PROJECT_URL'] + const serverUrl = process.env['CI_SERVER_URL'] + if (!projectId || !projectUrl || !serverUrl) { + console.error( + 'Socket could not publish GitLab merge request notes: missing target project metadata. Check CI_MERGE_REQUEST_PROJECT_ID, CI_MERGE_REQUEST_PROJECT_URL, and CI_SERVER_URL.', + ) + return + } + try { + await publishGitLabMergeRequestNotes({ + diffScanId, + disableOverview: envAsBoolean( + process.env['SOCKET_CLI_DISABLE_OVERVIEW_COMMENT'], + ), + disableSecurity: envAsBoolean( + process.env['SOCKET_CLI_DISABLE_SECURITY_COMMENT'], + ), + orgSlug, + mergeRequestIid: pullRequest, + projectId, + projectUrl, + serverUrl, + }) + } catch (error) { + debugFn('warn', 'Could not publish GitLab merge request notes', error) + console.error( + 'Socket could not publish GitLab merge request notes:', + errorMessage(error), + ) + } + return + } if ( pullRequestContext.provider !== 'github' || !owner || diff --git a/src/commands/ci/publish-gitlab-mr-notes.mts b/src/commands/ci/publish-gitlab-mr-notes.mts new file mode 100644 index 000000000..a2c10e51c --- /dev/null +++ b/src/commands/ci/publish-gitlab-mr-notes.mts @@ -0,0 +1,105 @@ +import { fetchRenderedPullRequestComments } from './publish-pr-comments.mts' +import { getGitLabServerUrl, gitLabApiRequest } from '../../utils/gitlab.mts' + +export const GITLAB_OVERVIEW_NOTE_MARKER = + '' +export const GITLAB_SECURITY_NOTE_MARKER = + '' + +type GitLabNote = { id: number; body: string; author: { id: number } } +type GitLabUser = { id: number } + +async function findNotes(path: string): Promise { + const notes: GitLabNote[] = [] + let page = '1' + do { + const query = new URLSearchParams({ per_page: '100', page }) + // Pagination uses the response header from the current page. + // eslint-disable-next-line no-await-in-loop + const result = await gitLabApiRequest({ + path: `${path}?${query}`, + }) + notes.push(...result.data) + page = result.nextPage || '' + } while (page) + return notes +} + +export async function publishGitLabMergeRequestNotes({ + diffScanId, + disableOverview, + disableSecurity, + mergeRequestIid, + orgSlug, + projectId, + projectUrl, + serverUrl, +}: { + diffScanId: string + disableOverview: boolean + disableSecurity: boolean + orgSlug: string + mergeRequestIid: number + projectId: string + projectUrl: string + serverUrl: string +}): Promise { + if (disableOverview && disableSecurity) { + return + } + const gitLabServerUrl = getGitLabServerUrl() + const configuredServerUrl = new URL(serverUrl) + if (configuredServerUrl.origin !== gitLabServerUrl.origin) { + throw new Error( + 'GitLab merge request URL must use the same origin as CI_SERVER_URL', + ) + } + const targetProjectUrl = new URL(projectUrl) + if ( + targetProjectUrl.origin !== gitLabServerUrl.origin || + targetProjectUrl.username || + targetProjectUrl.password || + targetProjectUrl.search || + targetProjectUrl.hash + ) { + throw new Error( + 'GitLab merge request URL must use the same origin as CI_SERVER_URL', + ) + } + const mergeRequestUrl = new URL( + `-/merge_requests/${mergeRequestIid}`, + `${targetProjectUrl.href.replace(/\/$/u, '')}/`, + ) + const { data: actor } = await gitLabApiRequest({ path: 'user' }) + const comments = await fetchRenderedPullRequestComments({ + diffScanId, + orgSlug, + platform: 'gitlab', + pullRequestUrl: mergeRequestUrl.href, + }) + const notesPath = `projects/${encodeURIComponent(projectId)}/merge_requests/${mergeRequestIid}/notes` + const notes = await findNotes(notesPath) + async function upsertNote(marker: string, content: string): Promise { + const existing = notes.find( + note => note.author?.id === actor.id && note.body.startsWith(marker), + ) + if (!content.trim() && !existing) { + return + } + const body = content.trim() ? `${marker}\n${content}` : marker + if (existing?.body === body) { + return + } + await gitLabApiRequest({ + path: existing ? `${notesPath}/${existing.id}` : notesPath, + method: existing ? 'PUT' : 'POST', + body: { body }, + }) + } + + await Promise.all([ + disableOverview || + upsertNote(GITLAB_OVERVIEW_NOTE_MARKER, comments.overview), + disableSecurity || upsertNote(GITLAB_SECURITY_NOTE_MARKER, comments.alerts), + ]) +} diff --git a/src/commands/ci/publish-gitlab-mr-notes.test.mts b/src/commands/ci/publish-gitlab-mr-notes.test.mts new file mode 100644 index 000000000..33d439140 --- /dev/null +++ b/src/commands/ci/publish-gitlab-mr-notes.test.mts @@ -0,0 +1,228 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' + +import { + GITLAB_OVERVIEW_NOTE_MARKER, + GITLAB_SECURITY_NOTE_MARKER, + publishGitLabMergeRequestNotes, +} from './publish-gitlab-mr-notes.mts' +import { fetchRenderedPullRequestComments } from './publish-pr-comments.mts' +import { apiFetch } from '../../utils/api.mts' + +vi.mock('../../utils/api.mts', () => ({ + apiFetch: vi.fn(), +})) + +vi.mock('./publish-pr-comments.mts', () => ({ + fetchRenderedPullRequestComments: vi.fn(), +})) + +const options = { + diffScanId: 'diff-id', + disableOverview: false, + disableSecurity: false, + orgSlug: 'example', + mergeRequestIid: 42, + projectId: 'target/42', + projectUrl: 'https://gitlab.example.test/target/project', + serverUrl: 'https://gitlab.example.test', +} + +function response(data: unknown, nextPage?: string): Response { + return { + ok: true, + status: 200, + headers: new Headers(nextPage ? { 'x-next-page': nextPage } : {}), + json: async () => data, + text: async () => '', + } as Response +} + +describe('publishGitLabMergeRequestNotes', () => { + beforeEach(() => { + vi.resetAllMocks() + vi.stubEnv('CI_SERVER_URL', options.serverUrl) + vi.stubEnv('CI_API_V4_URL', `${options.serverUrl}/api/v4`) + vi.stubEnv('SOCKET_CLI_GITLAB_TOKEN', 'glpat-example') + vi.stubEnv('GITLAB_TOKEN', '') + vi.stubEnv('CI_JOB_TOKEN', '') + vi.mocked(fetchRenderedPullRequestComments).mockResolvedValue({ + overview: 'Overview', + alerts: 'Findings', + }) + vi.mocked(apiFetch) + .mockResolvedValueOnce(response({ id: 5 })) + .mockResolvedValueOnce(response([])) + .mockResolvedValueOnce(response([])) + .mockResolvedValueOnce(response([])) + .mockResolvedValueOnce(response([])) + }) + + it('fetches GitLab rendered comments and creates two notes in the target project', async () => { + await publishGitLabMergeRequestNotes(options) + expect(fetchRenderedPullRequestComments).toHaveBeenCalledWith({ + diffScanId: 'diff-id', + orgSlug: 'example', + platform: 'gitlab', + pullRequestUrl: + 'https://gitlab.example.test/target/project/-/merge_requests/42', + }) + expect(apiFetch).toHaveBeenCalledTimes(4) + const firstListUrl = new URL(vi.mocked(apiFetch).mock.calls[1]![0]) + expect(firstListUrl.pathname).toBe( + '/api/v4/projects/target%2F42/merge_requests/42/notes', + ) + expect(vi.mocked(apiFetch).mock.calls[0]![1]?.headers).toMatchObject({ + 'PRIVATE-TOKEN': 'glpat-example', + }) + expect(vi.mocked(apiFetch).mock.calls[0]![1]).toMatchObject({ + rejectRedirects: true, + }) + expect(vi.mocked(apiFetch).mock.calls[2]![1]).toMatchObject({ + method: 'POST', + body: JSON.stringify({ + body: `${GITLAB_OVERVIEW_NOTE_MARKER}\nOverview`, + }), + }) + expect(vi.mocked(apiFetch).mock.calls[3]![1]).toMatchObject({ + method: 'POST', + body: JSON.stringify({ + body: `${GITLAB_SECURITY_NOTE_MARKER}\nFindings`, + }), + }) + }) + + it('updates matching notes and clears notes when rendered output is empty', async () => { + vi.mocked(fetchRenderedPullRequestComments).mockResolvedValue({ + overview: '', + alerts: '', + }) + vi.mocked(apiFetch) + .mockReset() + .mockResolvedValueOnce(response({ id: 5 })) + .mockResolvedValueOnce( + response([ + { + id: 7, + body: `${GITLAB_OVERVIEW_NOTE_MARKER}\nOld`, + author: { id: 5 }, + }, + { + id: 8, + body: `${GITLAB_SECURITY_NOTE_MARKER}\nOld`, + author: { id: 5 }, + }, + ]), + ) + .mockResolvedValueOnce(response(undefined)) + .mockResolvedValueOnce(response(undefined)) + await publishGitLabMergeRequestNotes(options) + expect(new URL(vi.mocked(apiFetch).mock.calls[2]![0]).pathname).toMatch( + /notes\/7$/u, + ) + expect(vi.mocked(apiFetch).mock.calls[2]![1]).toMatchObject({ + method: 'PUT', + body: JSON.stringify({ body: GITLAB_OVERVIEW_NOTE_MARKER }), + }) + expect(new URL(vi.mocked(apiFetch).mock.calls[3]![0]).pathname).toMatch( + /notes\/8$/u, + ) + expect(vi.mocked(apiFetch).mock.calls[3]![1]).toMatchObject({ + method: 'PUT', + body: JSON.stringify({ body: GITLAB_SECURITY_NOTE_MARKER }), + }) + }) + + it('does not create empty notes when no previous notes exist', async () => { + vi.mocked(fetchRenderedPullRequestComments).mockResolvedValue({ + overview: '', + alerts: '', + }) + await publishGitLabMergeRequestNotes(options) + expect( + vi + .mocked(apiFetch) + .mock.calls.every(([, init]) => init?.method === 'GET'), + ).toBe(true) + }) + + it('rejects CI job tokens because GitLab does not allow them to write merge request notes', async () => { + vi.stubEnv('SOCKET_CLI_GITLAB_TOKEN', '') + vi.stubEnv('CI_JOB_TOKEN', 'job-token') + await expect(publishGitLabMergeRequestNotes(options)).rejects.toThrow( + 'CI_JOB_TOKEN cannot write merge request notes', + ) + expect(apiFetch).not.toHaveBeenCalled() + }) + + it('suppresses either note independently and skips all work when both are disabled', async () => { + await publishGitLabMergeRequestNotes({ ...options, disableOverview: true }) + expect(apiFetch).toHaveBeenCalledTimes(3) + vi.mocked(apiFetch).mockClear() + vi.mocked(fetchRenderedPullRequestComments).mockClear() + await publishGitLabMergeRequestNotes({ + ...options, + disableOverview: true, + disableSecurity: true, + }) + expect(apiFetch).not.toHaveBeenCalled() + expect(fetchRenderedPullRequestComments).not.toHaveBeenCalled() + }) + + it('rejects an API origin that differs from the GitLab server', async () => { + vi.stubEnv('CI_API_V4_URL', 'https://other.example/api/v4') + await expect(publishGitLabMergeRequestNotes(options)).rejects.toThrow( + 'GitLab API URL must use the same origin as CI_SERVER_URL', + ) + }) + + it('reports permission errors with actionable guidance without including response bodies', async () => { + const forbidden = response({ message: 'sensitive server detail' }) + Object.assign(forbidden, { ok: false, status: 403 }) + vi.mocked(apiFetch).mockReset().mockResolvedValueOnce(forbidden) + const error = await publishGitLabMergeRequestNotes(options).then( + () => undefined, + reason => reason as Error, + ) + expect(error?.message).toContain( + 'Use a project access token with api scope and Developer access', + ) + expect(error?.message).not.toContain('sensitive server detail') + }) + + it('does not update a matching marker authored by a different GitLab user', async () => { + vi.mocked(apiFetch) + .mockReset() + .mockResolvedValueOnce(response({ id: 5 })) + .mockResolvedValueOnce( + response([ + { + id: 7, + body: `${GITLAB_OVERVIEW_NOTE_MARKER}\nOld`, + author: { id: 2 }, + }, + ]), + ) + .mockResolvedValueOnce(response([])) + .mockResolvedValueOnce(response([])) + await publishGitLabMergeRequestNotes({ ...options, disableSecurity: true }) + expect(vi.mocked(apiFetch).mock.calls[2]![1]).toMatchObject({ + method: 'POST', + }) + }) + + it('follows notes pagination before creating a note', async () => { + vi.mocked(apiFetch) + .mockReset() + .mockResolvedValueOnce(response({ id: 5 })) + .mockResolvedValueOnce(response([], '2')) + .mockResolvedValueOnce(response([])) + .mockResolvedValueOnce(response([])) + await publishGitLabMergeRequestNotes({ ...options, disableSecurity: true }) + expect( + new URL(vi.mocked(apiFetch).mock.calls[2]![0]).searchParams.get('page'), + ).toBe('2') + expect(vi.mocked(apiFetch).mock.calls[3]![1]).toMatchObject({ + method: 'POST', + }) + }) +}) diff --git a/src/commands/ci/publish-pr-comments.mts b/src/commands/ci/publish-pr-comments.mts index 0f24d83ce..b9c7dc0e2 100644 --- a/src/commands/ci/publish-pr-comments.mts +++ b/src/commands/ci/publish-pr-comments.mts @@ -6,6 +6,39 @@ export const PR_OVERVIEW_COMMENT_MARKER = export const PR_SECURITY_COMMENT_MARKER = '' +export async function fetchRenderedPullRequestComments({ + diffScanId, + orgSlug, + platform, + pullRequestUrl, +}: { + diffScanId: string + orgSlug: string + platform: 'github' | 'gitlab' + pullRequestUrl: string +}): Promise<{ overview: string; alerts: string }> { + const query = new URLSearchParams({ + platform, + pull_request_url: pullRequestUrl, + bot_commands: 'false', + }) + // SDK 4.3.0 does not expose this operation yet. + const result = await queryApiSafeJson<{ + diff_scan?: { comments: { overview: string; alerts: string } } + }>( + `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}/comments?${query}`, + 'pull request comments', + ) + if (!result.ok) { + throw new Error(result.cause || result.message) + } + const comments = result.data.diff_scan?.comments + if (!comments) { + throw new Error('Socket did not return rendered pull request comments') + } + return comments +} + export async function publishPullRequestComments({ diffScanId, disableOverview, @@ -32,25 +65,12 @@ export async function publishPullRequestComments({ `/${owner}/${repo}/pull/${pullRequest}`, serverUrl, ) - const query = new URLSearchParams({ + const comments = await fetchRenderedPullRequestComments({ + diffScanId, + orgSlug, platform: 'github', - pull_request_url: pullRequestUrl.href, - bot_commands: 'false', + pullRequestUrl: pullRequestUrl.href, }) - // SDK 4.3.0 does not expose this operation yet. - const result = await queryApiSafeJson<{ - diff_scan?: { comments: { overview: string; alerts: string } } - }>( - `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}/comments?${query}`, - 'pull request comments', - ) - if (!result.ok) { - throw new Error(result.cause || result.message) - } - const comments = result.data.diff_scan?.comments - if (!comments) { - throw new Error('Socket did not return rendered pull request comments') - } if (!disableOverview && comments.overview.trim()) { await upsertPullRequestComment({ diff --git a/src/utils/api.mts b/src/utils/api.mts index 8c169a250..d4cdae541 100644 --- a/src/utils/api.mts +++ b/src/utils/api.mts @@ -120,6 +120,7 @@ export type ApiFetchInit = { body?: string | undefined headers?: Record | undefined method?: string | undefined + rejectRedirects?: boolean | undefined timeout?: number | undefined } @@ -162,6 +163,10 @@ function _httpsRequestFetch( ) { // Consume the response body to free up memory. res.resume() + if (init.rejectRedirects) { + reject(new Error('Redirects are not allowed for this request')) + return + } if (redirectCount >= MAX_REDIRECTS) { reject(new Error('Maximum redirect limit reached')) return diff --git a/src/utils/gitlab.mts b/src/utils/gitlab.mts new file mode 100644 index 000000000..c2a67bce1 --- /dev/null +++ b/src/utils/gitlab.mts @@ -0,0 +1,102 @@ +import { apiFetch } from './api.mts' + +export type GitLabApiResponse = { + data: T + nextPage?: string +} + +function getGitLabAuth(): { header: string; value: string } { + const token = + process.env['SOCKET_CLI_GITLAB_TOKEN'] || process.env['GITLAB_TOKEN'] + if (token) { + return { header: 'PRIVATE-TOKEN', value: token } + } + if (process.env['CI_JOB_TOKEN']) { + throw new Error( + 'GitLab CI_JOB_TOKEN cannot write merge request notes. Set SOCKET_CLI_GITLAB_TOKEN to a project access token with api scope and Developer access.', + ) + } + throw new Error( + 'Set SOCKET_CLI_GITLAB_TOKEN to a project access token with api scope and Developer access.', + ) +} + +export function getGitLabServerUrl(): URL { + const serverUrl = new URL(process.env['CI_SERVER_URL'] || '') + if (serverUrl.protocol !== 'https:') { + throw new Error('GitLab server URL must use HTTPS') + } + if ( + serverUrl.username || + serverUrl.password || + serverUrl.search || + serverUrl.hash + ) { + throw new Error( + 'GitLab server URL must not contain credentials, query, or fragment data', + ) + } + return serverUrl +} + +function getGitLabApiUrl(serverUrl = getGitLabServerUrl()): URL { + const apiUrl = new URL( + process.env['CI_API_V4_URL'] || + `${serverUrl.href.replace(/\/$/u, '')}/api/v4`, + ) + if (apiUrl.protocol !== 'https:') { + throw new Error('GitLab API URL must use HTTPS') + } + if (apiUrl.username || apiUrl.password || apiUrl.search || apiUrl.hash) { + throw new Error( + 'GitLab API URL must not contain credentials, query, or fragment data', + ) + } + if (apiUrl.origin !== serverUrl.origin) { + throw new Error('GitLab API URL must use the same origin as CI_SERVER_URL') + } + return apiUrl +} + +/** Make an authenticated GitLab API call using the CI instance's own origin. */ +export async function gitLabApiRequest({ + body, + method = 'GET', + path, +}: { + body?: unknown + method?: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT' + path: string +}): Promise> { + const apiUrl = getGitLabApiUrl() + const token = getGitLabAuth() + const safePath = path.replace(/^\/+/, '') + const url = new URL(safePath, `${apiUrl.href.replace(/\/$/u, '')}/`) + if ( + url.origin !== apiUrl.origin || + !url.pathname.startsWith(`${apiUrl.pathname.replace(/\/$/u, '')}/`) + ) { + throw new Error('GitLab API path must remain under CI_API_V4_URL') + } + const response = await apiFetch(url.href, { + method, + headers: { + accept: 'application/json', + [token.header]: token.value, + ...(body === undefined ? {} : { 'content-type': 'application/json' }), + }, + rejectRedirects: true, + ...(body === undefined ? {} : { body: JSON.stringify(body) }), + }) + if (!response.ok) { + if (response.status === 401 || response.status === 403) { + throw new Error( + `GitLab could not authorize API access (HTTP ${response.status}). Use a project access token with api scope and Developer access to the target project.`, + ) + } + throw new Error(`GitLab API request failed (HTTP ${response.status})`) + } + const data = response.status === 204 ? undefined : await response.json() + const nextPage = response.headers.get('x-next-page') || undefined + return { data: data as T, ...(nextPage ? { nextPage } : {}) } +} diff --git a/test/release-history.test.mts b/test/release-history.test.mts index b63325fd0..6bde1491c 100644 --- a/test/release-history.test.mts +++ b/test/release-history.test.mts @@ -400,6 +400,8 @@ describe('selecting a publish lane from merged release history', () => { commits[expectedCommit as keyof typeof commits], ) }, + // Each lane builds a five-commit Git history and runs the publish checkout in Bash. + 30_000, ) it('allows an independent publish from a paired preparation', () => {