( rootDir: string = getProjectRoot(), )
| 115 | } |
| 116 | |
| 117 | export async function listWorkflowRuns( |
| 118 | rootDir: string = getProjectRoot(), |
| 119 | ): Promise<WorkflowRunRecord[]> { |
| 120 | let files: string[] |
| 121 | try { |
| 122 | files = await readdir(join(rootDir, WORKFLOW_RUNS_REL)) |
| 123 | } catch { |
| 124 | return [] |
| 125 | } |
| 126 | const jsonFiles = files.filter(file => file.endsWith('.json')) |
| 127 | const runs = await Promise.all( |
| 128 | jsonFiles |
| 129 | .slice(0, MAX_WORKFLOW_RUNS) |
| 130 | .map(file => readWorkflowRun(rootDir, file.slice(0, -'.json'.length))), |
| 131 | ) |
| 132 | return runs |
| 133 | .filter((run): run is WorkflowRunRecord => run !== null) |
| 134 | .sort((a, b) => b.updatedAt - a.updatedAt) |
| 135 | } |
| 136 | |
| 137 | export function formatWorkflowRunsStatus(runs: WorkflowRunRecord[]): string { |
| 138 | if (runs.length === 0) { |
no test coverage detected