mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
hop
This commit is contained in:
parent
3c394dc8e9
commit
ce3c56dc16
4 changed files with 31 additions and 28 deletions
|
|
@ -50,7 +50,7 @@ export class ArtifactProvider implements InputProvider {
|
||||||
async load(): Promise<ReportInput> {
|
async load(): Promise<ReportInput> {
|
||||||
const result: ReportInput = {
|
const result: ReportInput = {
|
||||||
artifactFilePaths: [],
|
artifactFilePaths: [],
|
||||||
reports : {}
|
reports: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const resp = await this.octokit.rest.actions.listWorkflowRunArtifacts({
|
const resp = await this.octokit.rest.actions.listWorkflowRunArtifacts({
|
||||||
|
|
@ -69,13 +69,15 @@ export class ArtifactProvider implements InputProvider {
|
||||||
return result
|
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) {
|
if (versionArtifact) {
|
||||||
await downloadArtifact(this.octokit, versionArtifact.id, "version.txt", this.token);
|
await downloadArtifact(this.octokit, versionArtifact.id, 'version.txt', this.token)
|
||||||
result.versionArtifactPath = "version.txt";
|
result.versionArtifactPath = 'version.txt'
|
||||||
} else {
|
} 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) {
|
for (const art of artifacts) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
export interface ReportInput {
|
export interface ReportInput {
|
||||||
artifactFilePaths: string[],
|
artifactFilePaths: string[]
|
||||||
versionArtifactPath?: string,
|
versionArtifactPath?: string
|
||||||
reports : {
|
reports: {
|
||||||
[reportName: string]: FileContent[]
|
[reportName: string]: FileContent[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ export class LocalFileProvider implements InputProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
artifactFilePaths: [],
|
artifactFilePaths: [],
|
||||||
reports : {
|
reports: {
|
||||||
[this.name]: result
|
[this.name]: result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
src/main.ts
35
src/main.ts
|
|
@ -90,14 +90,14 @@ class TestReporter {
|
||||||
|
|
||||||
const inputProvider = this.artifact
|
const inputProvider = this.artifact
|
||||||
? new ArtifactProvider(
|
? new ArtifactProvider(
|
||||||
this.octokit,
|
this.octokit,
|
||||||
this.artifact,
|
this.artifact,
|
||||||
this.name,
|
this.name,
|
||||||
pattern,
|
pattern,
|
||||||
this.context.sha,
|
this.context.sha,
|
||||||
this.context.runId,
|
this.context.runId,
|
||||||
this.token
|
this.token
|
||||||
)
|
)
|
||||||
: new LocalFileProvider(this.name, pattern)
|
: new LocalFileProvider(this.name, pattern)
|
||||||
|
|
||||||
const parseErrors = this.maxAnnotations > 0
|
const parseErrors = this.maxAnnotations > 0
|
||||||
|
|
@ -118,14 +118,14 @@ class TestReporter {
|
||||||
const results: TestRunResult[] = []
|
const results: TestRunResult[] = []
|
||||||
const input = await inputProvider.load()
|
const input = await inputProvider.load()
|
||||||
|
|
||||||
let version: string | null = null;
|
let version: string | null = null
|
||||||
|
|
||||||
if (input.versionArtifactPath) {
|
if (input.versionArtifactPath) {
|
||||||
const zip = new Zip(input.versionArtifactPath)
|
const zip = new Zip(input.versionArtifactPath)
|
||||||
|
|
||||||
const entry = zip.getEntry('version.txt')
|
const entry = zip.getEntry('version.txt')
|
||||||
|
|
||||||
version = zip.readAsText(entry);
|
version = zip.readAsText(entry)
|
||||||
core.info(`Using EVA version ${version}, current directory: ${cwd()}`)
|
core.info(`Using EVA version ${version}, current directory: ${cwd()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,8 +133,11 @@ class TestReporter {
|
||||||
const readStream = fs.createReadStream(a)
|
const readStream = fs.createReadStream(a)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const post = bent(this.resultsEndpoint, 'POST', {}, 200);
|
const post = bent(this.resultsEndpoint, 'POST', {}, 200)
|
||||||
const response = await post(`TestResults?Secret=${this.resultsEndpointSecret}${version ? "&EVAVersion=" + version : ''}`, readStream);
|
await post(
|
||||||
|
`TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}`,
|
||||||
|
readStream
|
||||||
|
)
|
||||||
core.info(`Uploaded TRX files: ${a}`)
|
core.info(`Uploaded TRX files: ${a}`)
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
core.warning(`Could not upload file ${a}: ${ex}`)
|
core.warning(`Could not upload file ${a}: ${ex}`)
|
||||||
|
|
@ -142,7 +145,6 @@ class TestReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [reportName, files] of Object.entries(input.reports)) {
|
for (const [reportName, files] of Object.entries(input.reports)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
core.startGroup(`Creating test report ${reportName}`)
|
core.startGroup(`Creating test report ${reportName}`)
|
||||||
const tr = await this.createReport(parser, reportName, files)
|
const tr = await this.createReport(parser, reportName, files)
|
||||||
|
|
@ -207,9 +209,9 @@ class TestReporter {
|
||||||
})
|
})
|
||||||
|
|
||||||
core.info('Creating report summary')
|
core.info('Creating report summary')
|
||||||
const { listSuites, listTests, onlySummary } = this
|
const {listSuites, listTests, onlySummary} = this
|
||||||
const baseUrl = createResp.data.html_url || ''
|
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')
|
core.info('Creating annotations')
|
||||||
const annotations = getAnnotations(results, this.maxAnnotations)
|
const annotations = getAnnotations(results, this.maxAnnotations)
|
||||||
|
|
@ -265,8 +267,7 @@ class TestReporter {
|
||||||
|
|
||||||
req.blocks.push({
|
req.blocks.push({
|
||||||
type: 'section',
|
type: 'section',
|
||||||
text:
|
text: {
|
||||||
{
|
|
||||||
type: 'mrkdwn',
|
type: 'mrkdwn',
|
||||||
text: `:red_circle: ${tr.failed} in <${resp.data.html_url}#r${runIndex}|${runName}>`
|
text: `:red_circle: ${tr.failed} in <${resp.data.html_url}#r${runIndex}|${runName}>`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue