Surface GitHub check suites awaiting approval (#6717)
* Surface GitHub check suites awaiting approval to unblock merge - Query the check-suites API endpoint to find suites with an "action_required" conclusion, which are often workflows awaiting "Approve and run" and do not have any associated check runs. - Map the "action_required" status distinctly instead of treating it as a standard failure or omitting it entirely. - Update the UI to render these suites with a warning icon, a dedicated "Action required" label, and a localized hint explaining that manual approval is required on GitHub. - Count "action_required" checks as failed/blocking when deriving overall PR and task statuses so the UI does not report all checks passing. * Enhance visibility and handling of action-required PR check suites * Include check suite IDs in pending approval check names and URLs to allow navigating directly to the specific workflow run. * Add an "action required" count badge to PR dialog and page checks tabs. * Prioritize action-required checks in the checks preview summary. * Use correct check run state for the action-required fallback hint in the right sidebar details panel. * Add translations for the new status across all supported locales.
This commit is contained in:
@@ -92,19 +92,21 @@ describe('getPRChecks', () => {
|
||||
|
||||
it('queries check-runs by PR head SHA when GitHub remote metadata is available', async () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
|
||||
ghExecFileAsyncMock.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify({
|
||||
check_runs: [
|
||||
{
|
||||
name: 'build',
|
||||
status: 'completed',
|
||||
conclusion: 'success',
|
||||
html_url: 'https://github.com/acme/widgets/actions/runs/1',
|
||||
details_url: null
|
||||
}
|
||||
]
|
||||
ghExecFileAsyncMock
|
||||
.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify({
|
||||
check_runs: [
|
||||
{
|
||||
name: 'build',
|
||||
status: 'completed',
|
||||
conclusion: 'success',
|
||||
html_url: 'https://github.com/acme/widgets/actions/runs/1',
|
||||
details_url: null
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
})
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_suites: [] }) })
|
||||
|
||||
const checks = await getPRChecks('/repo-root', 42, 'head-oid')
|
||||
|
||||
@@ -123,10 +125,82 @@ describe('getPRChecks', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('falls back to gh pr checks when the head SHA has no check runs', async () => {
|
||||
it('surfaces an action_required check suite that has no check run', async () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
|
||||
ghExecFileAsyncMock
|
||||
.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify({
|
||||
check_runs: [
|
||||
{
|
||||
name: 'track-community-pr',
|
||||
status: 'completed',
|
||||
conclusion: 'success',
|
||||
html_url: 'https://github.com/acme/widgets/actions/runs/1',
|
||||
details_url: null
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify({
|
||||
check_suites: [
|
||||
{
|
||||
id: 1000,
|
||||
status: 'completed',
|
||||
conclusion: 'success',
|
||||
app: { name: 'GitHub Actions' }
|
||||
},
|
||||
{
|
||||
id: 1001,
|
||||
status: 'completed',
|
||||
conclusion: 'action_required',
|
||||
app: { name: 'GitHub Actions' }
|
||||
},
|
||||
{
|
||||
id: 1002,
|
||||
status: 'completed',
|
||||
conclusion: 'action_required',
|
||||
app: { name: 'GitHub Actions' }
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
const checks = await getPRChecks('/repo-root', 42, 'head-oid')
|
||||
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
['api', '--cache', '60s', 'repos/acme/widgets/commits/head-oid/check-suites?per_page=100'],
|
||||
{ cwd: '/repo-root' }
|
||||
)
|
||||
expect(checks).toEqual([
|
||||
{
|
||||
name: 'track-community-pr',
|
||||
status: 'completed',
|
||||
conclusion: 'success',
|
||||
url: 'https://github.com/acme/widgets/actions/runs/1',
|
||||
workflowRunId: 1
|
||||
},
|
||||
{
|
||||
name: 'GitHub Actions #1001',
|
||||
status: 'completed',
|
||||
conclusion: 'action_required',
|
||||
url: 'https://github.com/acme/widgets/commits/head-oid/checks#check-suite-1001'
|
||||
},
|
||||
{
|
||||
name: 'GitHub Actions #1002',
|
||||
status: 'completed',
|
||||
conclusion: 'action_required',
|
||||
url: 'https://github.com/acme/widgets/commits/head-oid/checks#check-suite-1002'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('falls back to gh pr checks when the head SHA has no check runs or suites', async () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
|
||||
ghExecFileAsyncMock
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_runs: [] }) })
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_suites: [] }) })
|
||||
.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify([
|
||||
{ name: 'verify', state: 'PENDING', link: 'https://example.com/verify' }
|
||||
@@ -136,7 +210,7 @@ describe('getPRChecks', () => {
|
||||
const checks = await getPRChecks('/repo-root', 42, 'head-oid')
|
||||
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
3,
|
||||
['pr', 'checks', '42', '--json', 'name,state,link', '--repo', 'acme/widgets'],
|
||||
{ cwd: '/repo-root' }
|
||||
)
|
||||
@@ -151,39 +225,76 @@ describe('getPRChecks', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('maps remaining completed GitHub conclusions to failure', async () => {
|
||||
it('maps stale and startup_failure conclusions to failure and action_required to its own state', 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
|
||||
}
|
||||
]
|
||||
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
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
})
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_suites: [] }) })
|
||||
|
||||
const checks = await getPRChecks('/repo-root', 42, 'head-oid')
|
||||
|
||||
expect(checks.map((check) => check.conclusion)).toEqual(['failure', 'failure', 'failure'])
|
||||
expect(checks.map((check) => check.conclusion)).toEqual([
|
||||
'action_required',
|
||||
'failure',
|
||||
'failure'
|
||||
])
|
||||
})
|
||||
|
||||
it('surfaces an action_required suite even when there are zero check runs', async () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
|
||||
ghExecFileAsyncMock
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_runs: [] }) })
|
||||
.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify({
|
||||
check_suites: [
|
||||
{
|
||||
id: 1001,
|
||||
status: 'completed',
|
||||
conclusion: 'action_required',
|
||||
app: { name: 'GitHub Actions' }
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
const checks = await getPRChecks('/repo-root', 42, 'head-oid')
|
||||
|
||||
// Why: must not fall through to `gh pr checks` — the suite is the only signal.
|
||||
expect(ghExecFileAsyncMock).toHaveBeenCalledTimes(2)
|
||||
expect(checks).toEqual([
|
||||
{
|
||||
name: 'GitHub Actions #1001',
|
||||
status: 'completed',
|
||||
conclusion: 'action_required',
|
||||
url: 'https://github.com/acme/widgets/commits/head-oid/checks#check-suite-1001'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('treats gh pr checks "no checks reported" as an empty check list', async () => {
|
||||
@@ -191,6 +302,7 @@ describe('getPRChecks', () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
|
||||
ghExecFileAsyncMock
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_runs: [] }) })
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_suites: [] }) })
|
||||
.mockRejectedValueOnce(
|
||||
Object.assign(new Error('Command failed: gh pr checks 42'), {
|
||||
stderr: "no checks reported on the 'codex/keybindings-toml' branch\n",
|
||||
@@ -210,6 +322,7 @@ describe('getPRChecks', () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
|
||||
ghExecFileAsyncMock
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_runs: [] }) })
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_suites: [] }) })
|
||||
.mockRejectedValueOnce(
|
||||
Object.assign(new Error('Command failed: gh pr checks 42'), {
|
||||
stderr: 'GraphQL: Could not resolve to a PullRequest',
|
||||
@@ -291,6 +404,7 @@ describe('getPRChecks', () => {
|
||||
]
|
||||
})
|
||||
})
|
||||
.mockResolvedValueOnce({ stdout: JSON.stringify({ check_suites: [] }) })
|
||||
.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user