diff --git a/src/input-providers/artifact-provider.ts b/src/input-providers/artifact-provider.ts index 90e34f6..735595d 100644 --- a/src/input-providers/artifact-provider.ts +++ b/src/input-providers/artifact-provider.ts @@ -50,7 +50,7 @@ export class ArtifactProvider implements InputProvider { async load(): Promise { const result: ReportInput = { artifactFilePaths: [], - reports : {} + reports: {} } const resp = await this.octokit.rest.actions.listWorkflowRunArtifacts({ @@ -69,13 +69,15 @@ export class ArtifactProvider implements InputProvider { return result } - const versionArtifact = resp.data.artifacts.find(a => a.name == "version.txt"); + const versionArtifact = resp.data.artifacts.find(a => a.name === 'version.txt') - if(versionArtifact) { - await downloadArtifact(this.octokit, versionArtifact.id, "version.txt", this.token); - result.versionArtifactPath = "version.txt"; + if (versionArtifact) { + await downloadArtifact(this.octokit, versionArtifact.id, 'version.txt', this.token) + result.versionArtifactPath = 'version.txt' } else { - core.warning(`Could not find version.txt artifact among these artifacts: ${resp.data.artifacts.map(a => a.name).join(", ")}`); + core.warning( + `Could not find version.txt artifact among these artifacts: ${resp.data.artifacts.map(a => a.name).join(', ')}` + ) } for (const art of artifacts) { diff --git a/src/input-providers/input-provider.ts b/src/input-providers/input-provider.ts index 03c9a88..04e0f50 100644 --- a/src/input-providers/input-provider.ts +++ b/src/input-providers/input-provider.ts @@ -1,7 +1,7 @@ export interface ReportInput { - artifactFilePaths: string[], - versionArtifactPath?: string, - reports : { + artifactFilePaths: string[] + versionArtifactPath?: string + reports: { [reportName: string]: FileContent[] } } diff --git a/src/input-providers/local-file-provider.ts b/src/input-providers/local-file-provider.ts index f64c39b..3482160 100644 --- a/src/input-providers/local-file-provider.ts +++ b/src/input-providers/local-file-provider.ts @@ -19,9 +19,9 @@ export class LocalFileProvider implements InputProvider { } } - return { + return { artifactFilePaths: [], - reports : { + reports: { [this.name]: result } } diff --git a/src/main.ts b/src/main.ts index a7c88ac..37f5c91 100644 --- a/src/main.ts +++ b/src/main.ts @@ -90,14 +90,14 @@ class TestReporter { const inputProvider = this.artifact ? new ArtifactProvider( - this.octokit, - this.artifact, - this.name, - pattern, - this.context.sha, - this.context.runId, - this.token - ) + this.octokit, + this.artifact, + this.name, + pattern, + this.context.sha, + this.context.runId, + this.token + ) : new LocalFileProvider(this.name, pattern) const parseErrors = this.maxAnnotations > 0 @@ -118,14 +118,14 @@ class TestReporter { const results: TestRunResult[] = [] const input = await inputProvider.load() - let version: string | null = null; + let version: string | null = null if (input.versionArtifactPath) { const zip = new Zip(input.versionArtifactPath) const entry = zip.getEntry('version.txt') - version = zip.readAsText(entry); + version = zip.readAsText(entry) core.info(`Using EVA version ${version}, current directory: ${cwd()}`) } @@ -133,8 +133,11 @@ class TestReporter { const readStream = fs.createReadStream(a) try { - const post = bent(this.resultsEndpoint, 'POST', {}, 200); - const response = await post(`TestResults?Secret=${this.resultsEndpointSecret}${version ? "&EVAVersion=" + version : ''}`, readStream); + const post = bent(this.resultsEndpoint, 'POST', {}, 200) + await post( + `TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}`, + readStream + ) core.info(`Uploaded TRX files: ${a}`) } catch (ex) { core.warning(`Could not upload file ${a}: ${ex}`) @@ -142,7 +145,6 @@ class TestReporter { } for (const [reportName, files] of Object.entries(input.reports)) { - try { core.startGroup(`Creating test report ${reportName}`) const tr = await this.createReport(parser, reportName, files) @@ -207,9 +209,9 @@ class TestReporter { }) core.info('Creating report summary') - const { listSuites, listTests, onlySummary } = this + const {listSuites, listTests, onlySummary} = this const baseUrl = createResp.data.html_url || '' - const summary = getReport(results, { listSuites, listTests, baseUrl, onlySummary }) + const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary}) core.info('Creating annotations') const annotations = getAnnotations(results, this.maxAnnotations) @@ -265,8 +267,7 @@ class TestReporter { req.blocks.push({ type: 'section', - text: - { + text: { type: 'mrkdwn', text: `:red_circle: ${tr.failed} in <${resp.data.html_url}#r${runIndex}|${runName}>` }