mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 14:57:09 +01:00
wip
This commit is contained in:
parent
a3b45a8dbd
commit
297c6fe504
4 changed files with 34 additions and 15 deletions
|
|
@ -49,7 +49,8 @@ export class ArtifactProvider implements InputProvider {
|
|||
|
||||
async load(): Promise<ReportInput> {
|
||||
const result: ReportInput = {
|
||||
artifactFilePaths: []
|
||||
artifactFilePaths: [],
|
||||
reports : {}
|
||||
}
|
||||
|
||||
const resp = await this.octokit.rest.actions.listWorkflowRunArtifacts({
|
||||
|
|
@ -68,6 +69,15 @@ export class ArtifactProvider implements InputProvider {
|
|||
return result
|
||||
}
|
||||
|
||||
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";
|
||||
} else {
|
||||
core.warning(`Could not find version.txt artifact among these artifacts: ${resp.data.artifacts.map(a => a.name).join(", ")}`);
|
||||
}
|
||||
|
||||
for (const art of artifacts) {
|
||||
const fileName = `${art.name}.zip`
|
||||
result.artifactFilePaths.push(fileName)
|
||||
|
|
@ -92,10 +102,10 @@ export class ArtifactProvider implements InputProvider {
|
|||
files.push({file, content})
|
||||
core.info(`Read ${file}: ${content.length} chars`)
|
||||
}
|
||||
if (result[reportName]) {
|
||||
result[reportName].push(...files)
|
||||
if (result.reports[reportName]) {
|
||||
result.reports[reportName].push(...files)
|
||||
} else {
|
||||
result[reportName] = files
|
||||
result.reports[reportName] = files
|
||||
}
|
||||
} finally {
|
||||
core.endGroup()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
export interface ReportInput {
|
||||
artifactFilePaths: string[]
|
||||
[reportName: string]: any[]
|
||||
artifactFilePaths: string[],
|
||||
versionArtifactPath?: string,
|
||||
reports : {
|
||||
[reportName: string]: FileContent[]
|
||||
}
|
||||
}
|
||||
|
||||
export interface FileContent {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,12 @@ export class LocalFileProvider implements InputProvider {
|
|||
}
|
||||
}
|
||||
|
||||
return {[this.name]: result, artifactFilePaths: []}
|
||||
return {
|
||||
artifactFilePaths: [],
|
||||
reports : {
|
||||
[this.name]: result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async listTrackedFiles(): Promise<string[]> {
|
||||
|
|
|
|||
17
src/main.ts
17
src/main.ts
|
|
@ -116,25 +116,26 @@ class TestReporter {
|
|||
const results: TestRunResult[] = []
|
||||
const input = await inputProvider.load()
|
||||
|
||||
let version : string | null = null;
|
||||
|
||||
if(input.versionArtifactPath) {
|
||||
version = fs.readFileSync(input.versionArtifactPath).toString();
|
||||
core.info(`Using EVA version ${version}`)
|
||||
}
|
||||
|
||||
for (const a of input.artifactFilePaths) {
|
||||
const stats = fs.statSync(a)
|
||||
const fileSizeInBytes = stats.size
|
||||
const readStream = fs.createReadStream(a)
|
||||
|
||||
try {
|
||||
const post = bent(this.resultsEndpoint, 'POST', {}, 200);
|
||||
await post(`TestResults?Secret=${this.resultsEndpointSecret}`, readStream);
|
||||
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}`)
|
||||
}
|
||||
}
|
||||
|
||||
for (const [reportName, files] of Object.entries(input)) {
|
||||
|
||||
if(reportName === 'artifactFilePaths') {
|
||||
continue;
|
||||
}
|
||||
for (const [reportName, files] of Object.entries(input.reports)) {
|
||||
|
||||
try {
|
||||
core.startGroup(`Creating test report ${reportName}`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue