Harden failed check details links (#6661)

* fix: harden failed check details links

* chore: remove tracked node_modules symlink
This commit is contained in:
Jinjing
2026-06-28 16:17:32 -07:00
committed by GitHub
parent 3d3453c216
commit cea920a3e4
12 changed files with 226 additions and 43 deletions
@@ -166,10 +166,10 @@ describe('getPRCheckDetails', () => {
id: 8801,
name: 'verify',
status: 'completed',
conclusion: 'failure',
conclusion: 'startup_failure',
completed_at: '2026-05-18T19:02:00Z',
html_url: actionUrl,
steps: [{ name: 'Run tests', status: 'completed', conclusion: 'failure' }]
steps: [{ name: 'Run tests', status: 'completed', conclusion: 'startup_failure' }]
},
{
id: 8802,
@@ -190,7 +190,7 @@ describe('getPRCheckDetails', () => {
expect(details?.jobs[0]).toMatchObject({
id: 8801,
name: 'verify',
conclusion: 'failure'
conclusion: 'startup_failure'
})
expect(details?.jobs[0].logTail).toContain('line 209')
expect(details?.jobs[0].logTail).not.toContain('line 0')
+35
View File
@@ -151,6 +151,41 @@ describe('getPRChecks', () => {
])
})
it('maps remaining completed GitHub conclusions to failure', async () => {
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
ghExecFileAsyncMock.mockResolvedValueOnce({
stdout: JSON.stringify({
check_runs: [
{
name: 'needs-approval',
status: 'completed',
conclusion: 'action_required',
html_url: 'https://github.com/acme/widgets/actions/runs/1',
details_url: null
},
{
name: 'old-run',
status: 'completed',
conclusion: 'stale',
html_url: 'https://github.com/acme/widgets/actions/runs/2',
details_url: null
},
{
name: 'boot',
status: 'completed',
conclusion: 'startup_failure',
html_url: 'https://github.com/acme/widgets/actions/runs/3',
details_url: null
}
]
})
})
const checks = await getPRChecks('/repo-root', 42, 'head-oid')
expect(checks.map((check) => check.conclusion)).toEqual(['failure', 'failure', 'failure'])
})
it('treats gh pr checks "no checks reported" as an empty check list', async () => {
const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
+9 -1
View File
@@ -3144,7 +3144,15 @@ function mapWorkflowJobs(raw: unknown, checkName?: string): PRCheckRunDetails['j
}
function isCheckJobFailureState(state: string | null | undefined): boolean {
return state === 'failure' || state === 'failed' || state === 'cancelled' || state === 'timed_out'
return (
state === 'failure' ||
state === 'failed' ||
state === 'action_required' ||
state === 'cancelled' ||
state === 'stale' ||
state === 'startup_failure' ||
state === 'timed_out'
)
}
function sliceCheckLogTail(logText: string): string {
+6 -1
View File
@@ -22,7 +22,9 @@ const conclusionMap: Record<string, PRCheckDetail['conclusion']> = {
timed_out: 'timed_out',
skipped: 'skipped',
neutral: 'neutral',
action_required: 'failure'
action_required: 'failure',
stale: 'failure',
startup_failure: 'failure'
}
export function mapCheckRunRESTConclusion(
@@ -59,6 +61,9 @@ export function mapCheckConclusion(state: string): PRCheckDetail['conclusion'] {
if (s === 'FAILURE' || s === 'FAIL') {
return 'failure'
}
if (s === 'ACTION_REQUIRED' || s === 'STALE' || s === 'STARTUP_FAILURE') {
return 'failure'
}
if (s === 'CANCELLED') {
return 'cancelled'
}