* List check statuses for a PR, including diffs for checks with commits.
(prUrl: string)
| 144 | * List check statuses for a PR, including diffs for checks with commits. |
| 145 | */ |
| 146 | async function listChecks(prUrl: string): Promise<void> { |
| 147 | const response = await get<ChecksStatusResponse>( |
| 148 | `api/checks/status?pullRequestUrl=${encodeURIComponent(prUrl)}`, |
| 149 | ); |
| 150 | const { checks } = response.data; |
| 151 | |
| 152 | if (checks.length === 0) { |
| 153 | console.log(chalk.dim("No checks found for this PR.")); |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | console.log(chalk.bold(`\nChecks for ${chalk.cyan(prUrl)}\n`)); |
| 158 | |
| 159 | for (const check of checks) { |
| 160 | const icon = STATE_ICONS[check.state] || "?"; |
| 161 | console.log(`${icon} ${chalk.bold(check.name)}`); |
| 162 | console.log(` ${chalk.dim(check.description)}`); |
| 163 | |
| 164 | if (check.commitMessage) { |
| 165 | console.log(` Commit: ${check.commitMessage}`); |
| 166 | } |
| 167 | |
| 168 | if (check.suggestionStatus) { |
| 169 | const statusColor = |
| 170 | check.suggestionStatus === "pending" |
| 171 | ? chalk.yellow |
| 172 | : check.suggestionStatus === "accepted" |
| 173 | ? chalk.green |
| 174 | : chalk.red; |
| 175 | console.log(` Suggestion: ${statusColor(check.suggestionStatus)}`); |
| 176 | } |
| 177 | |
| 178 | if (check.commitMessage) { |
| 179 | await printCheckDiff(check); |
| 180 | } |
| 181 | |
| 182 | console.log(); |
| 183 | } |
| 184 | |
| 185 | // Summary line |
| 186 | const pending = checks.filter((c) => c.state === "pending").length; |
| 187 | const failures = checks.filter((c) => c.state === "failure").length; |
| 188 | const successes = checks.filter((c) => c.state === "success").length; |
| 189 | |
| 190 | const parts: string[] = []; |
| 191 | if (successes > 0) parts.push(chalk.green(`${successes} passed`)); |
| 192 | if (failures > 0) parts.push(chalk.red(`${failures} failing`)); |
| 193 | if (pending > 0) parts.push(chalk.yellow(`${pending} pending`)); |
| 194 | console.log(parts.join(", ")); |
| 195 | |
| 196 | // Exit code: 0=all pass, 1=any failure, 2=still pending |
| 197 | if (failures > 0) { |
| 198 | await gracefulExit(1); |
| 199 | } else if (pending > 0) { |
| 200 | await gracefulExit(2); |
| 201 | } |
| 202 | } |
| 203 |
no test coverage detected