()
| 279 | } |
| 280 | |
| 281 | async function runTestsIfNeeded() { |
| 282 | if (!skipTests) { |
| 283 | step('Checking CI status for HEAD...') |
| 284 | let isCIPassed = await getCIResult() |
| 285 | skipTests ||= isCIPassed |
| 286 | |
| 287 | if (isCIPassed) { |
| 288 | if (!skipPrompts) { |
| 289 | /** @type {{ yes: boolean }} */ |
| 290 | const { yes: promptSkipTests } = await prompt({ |
| 291 | type: 'confirm', |
| 292 | name: 'yes', |
| 293 | message: `CI for this commit passed. Skip local tests?`, |
| 294 | }) |
| 295 | skipTests = promptSkipTests |
| 296 | } else { |
| 297 | skipTests = true |
| 298 | } |
| 299 | } else if (skipPrompts) { |
| 300 | throw new Error( |
| 301 | 'CI for the latest commit has not passed yet. ' + |
| 302 | 'Only run the release workflow after the CI has passed.', |
| 303 | ) |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if (!skipTests) { |
| 308 | step('\nRunning tests...') |
| 309 | if (!isDryRun) { |
| 310 | await run('pnpm', ['run', 'test', '--run']) |
| 311 | } else { |
| 312 | console.log(`Skipped (dry run)`) |
| 313 | } |
| 314 | } else { |
| 315 | step('Tests skipped.') |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | async function getCIResult() { |
| 320 | try { |
no test coverage detected