(options: UploadOptions)
| 13 | * Uploads collected audits to the portal |
| 14 | */ |
| 15 | export async function upload(options: UploadOptions) { |
| 16 | await logger.task('Uploading report to Portal', async () => { |
| 17 | const portalClient = await loadPortalClient(); |
| 18 | const { uploadReportToPortal } = portalClient; |
| 19 | const { apiKey, server, organization, project, timeout } = options.upload; |
| 20 | const report: Report = await loadReport({ |
| 21 | ...options.persist, |
| 22 | format: 'json', |
| 23 | }); |
| 24 | if (!report.commit) { |
| 25 | throw new Error('Commit must be linked in order to upload report'); |
| 26 | } |
| 27 | |
| 28 | const data: SaveReportMutationVariables = { |
| 29 | organization, |
| 30 | project, |
| 31 | commit: report.commit.hash, |
| 32 | ...reportToGQL(report), |
| 33 | }; |
| 34 | |
| 35 | const { url } = await uploadReportToPortal({ |
| 36 | apiKey, |
| 37 | server, |
| 38 | data, |
| 39 | timeout, |
| 40 | }); |
| 41 | logger.info(formatAsciiLink(url)); |
| 42 | |
| 43 | return `Uploaded report to Portal`; |
| 44 | }); |
| 45 | } |
no test coverage detected