Handles the checkout pull request command.
({configFile, list, name, commitSha}: WorkflowsParams)
| 46 | |
| 47 | /** Handles the checkout pull request command. */ |
| 48 | async function handler({configFile, list, name, commitSha}: WorkflowsParams) { |
| 49 | const workflows = await loadWorkflows(join(determineRepoBaseDirFromCwd(), configFile)); |
| 50 | |
| 51 | if (list) { |
| 52 | process.stdout.write(JSON.stringify(Object.keys(workflows))); |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | const results: {name: string; value: number}[] = []; |
| 57 | |
| 58 | if (name) { |
| 59 | const {value} = await measureWorkflow(workflows[name]); |
| 60 | results.push({value, name}); |
| 61 | } else { |
| 62 | for (const workflow of Object.values(workflows)) { |
| 63 | const {name, value} = await measureWorkflow(workflow); |
| 64 | results.push({value, name}); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | if (commitSha) { |
| 69 | const spinner = new Spinner('Uploading performance results to database'); |
| 70 | try { |
| 71 | for (let {value, name} of results) { |
| 72 | await addWorkflowPerformanceResult({ |
| 73 | name, |
| 74 | value, |
| 75 | commit_sha: commitSha, |
| 76 | }); |
| 77 | } |
| 78 | } finally { |
| 79 | spinner.success('Upload complete'); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** yargs command module for checking out a PR. */ |
| 85 | export const WorkflowsModule: CommandModule<{}, WorkflowsParams> = { |
nothing calls this directly
no test coverage detected