This commit is contained in:
Aart Jan Kaptijn 2022-04-28 15:35:03 +02:00 committed by A. J. Kaptijn
parent 3c394dc8e9
commit ce3c56dc16
4 changed files with 31 additions and 28 deletions

View file

@ -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";
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) {

View file

@ -1,6 +1,6 @@
export interface ReportInput {
artifactFilePaths: string[],
versionArtifactPath?: string,
artifactFilePaths: string[]
versionArtifactPath?: string
reports: {
[reportName: string]: FileContent[]
}

View file

@ -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)
@ -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}>`
}