Add createCheck to display test results in GitHub UI
parent
c838b9cba9
commit
94d2fc0be4
File diff suppressed because one or more lines are too long
|
|
@ -15,6 +15,7 @@ class ReportConverter {
|
|||
meta.duration = Number(run._attributes.duration);
|
||||
|
||||
meta.addTests(ReportConverter.convertSuite(run['test-suite']));
|
||||
core.info(`meta length ${meta.suites.length}`);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
|
@ -40,6 +41,7 @@ class ReportConverter {
|
|||
result.push(...ReportConverter.convertTests(suites._attributes.fullname, tests));
|
||||
}
|
||||
|
||||
core.info(`result length ${result.length}`);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@ class ResultsCheck {
|
|||
|
||||
// Prepare run summary
|
||||
const runSummary = new RunMeta('Test Results');
|
||||
runs.forEach(suite => {
|
||||
runSummary.total += suite.total;
|
||||
runSummary.passed += suite.passed;
|
||||
runSummary.skipped += suite.skipped;
|
||||
runSummary.failed += suite.failed;
|
||||
runSummary.duration += suite.duration;
|
||||
core.info(suite.suites.length);
|
||||
suite.suites.forEach(s => {
|
||||
runSummary.addTests(s.tests);
|
||||
runs.forEach(run => {
|
||||
runSummary.total += run.total;
|
||||
runSummary.passed += run.passed;
|
||||
runSummary.skipped += run.skipped;
|
||||
runSummary.failed += run.failed;
|
||||
runSummary.duration += run.duration;
|
||||
core.info(`Run suites length ${run.suites.length}`);
|
||||
run.suites.forEach(suite => {
|
||||
runSummary.addTests(suite.tests);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,118 +1,118 @@
|
|||
import {components} from '@octokit/openapi-types/generated/types';
|
||||
import { components } from '@octokit/openapi-types/generated/types';
|
||||
|
||||
export function timeHelper(seconds: number): string {
|
||||
return `${seconds.toFixed(3)}s`;
|
||||
}
|
||||
|
||||
export abstract class Meta {
|
||||
title: string;
|
||||
duration = 0;
|
||||
title: string;
|
||||
duration = 0;
|
||||
|
||||
constructor(title: string) {
|
||||
this.title = title;
|
||||
}
|
||||
constructor(title: string) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
abstract get summary(): string;
|
||||
abstract get summary(): string;
|
||||
|
||||
abstract get mark(): string;
|
||||
abstract get mark(): string;
|
||||
}
|
||||
|
||||
export class RunMeta extends Meta {
|
||||
total = 0;
|
||||
passed = 0;
|
||||
skipped = 0;
|
||||
failed = 0;
|
||||
total = 0;
|
||||
passed = 0;
|
||||
skipped = 0;
|
||||
failed = 0;
|
||||
|
||||
tests: TestMeta[] = [];
|
||||
suites: RunMeta[] = [];
|
||||
tests: TestMeta[] = [];
|
||||
suites: RunMeta[] = [];
|
||||
|
||||
extractAnnotations(): Annotation[] {
|
||||
const result = [] as Annotation[];
|
||||
for (const suite of this.suites) {
|
||||
result.push(...suite.extractAnnotations());
|
||||
}
|
||||
for (const test of this.tests) {
|
||||
if (test.annotation !== undefined) {
|
||||
result.push(test.annotation);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
extractAnnotations(): Annotation[] {
|
||||
const result = [] as Annotation[];
|
||||
for (const suite of this.suites) {
|
||||
result.push(...suite.extractAnnotations());
|
||||
}
|
||||
for (const test of this.tests) {
|
||||
if (test.annotation !== undefined) {
|
||||
result.push(test.annotation);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
addTests(testsToAdd: TestMeta[]): void {
|
||||
testsToAdd.forEach(test => {
|
||||
this.addTest(test);
|
||||
});
|
||||
}
|
||||
|
||||
addTest(test: TestMeta): void {
|
||||
if (test.suite === undefined) {
|
||||
return;
|
||||
}
|
||||
if (test.suite === this.title) {
|
||||
this.total++;
|
||||
this.duration += test.duration;
|
||||
this.tests.push(test);
|
||||
if (test.result === 'Passed') this.passed++;
|
||||
else if (test.result === 'Failed') this.failed++;
|
||||
else this.skipped++;
|
||||
return;
|
||||
}
|
||||
|
||||
addTests(children: TestMeta[]): void {
|
||||
for (const child of children) {
|
||||
this.addTest(child);
|
||||
}
|
||||
let target = this.suites.find(s => s.title === test.suite);
|
||||
if (target === undefined) {
|
||||
target = new RunMeta(test.suite);
|
||||
this.suites.push(target);
|
||||
}
|
||||
|
||||
addTest(test: TestMeta): void {
|
||||
if (test.suite === undefined) {
|
||||
return;
|
||||
}
|
||||
if (test.suite === this.title) {
|
||||
this.total++;
|
||||
this.duration += test.duration;
|
||||
this.tests.push(test);
|
||||
if (test.result === 'Passed') this.passed++;
|
||||
else if (test.result === 'Failed') this.failed++;
|
||||
else this.skipped++;
|
||||
return;
|
||||
}
|
||||
target.addTest(test);
|
||||
}
|
||||
|
||||
let target = this.suites.find(s => s.title === test.suite);
|
||||
if (target === undefined) {
|
||||
target = new RunMeta(test.suite);
|
||||
this.suites.push(target);
|
||||
}
|
||||
get summary(): string {
|
||||
const result = this.failed > 0 ? 'Failed' : 'Passed';
|
||||
const sPart = this.skipped > 0 ? `, skipped: ${this.skipped}` : '';
|
||||
const fPart = this.failed > 0 ? `, failed: ${this.failed}` : '';
|
||||
const dPart = ` in ${timeHelper(this.duration)}`;
|
||||
return `${this.mark} ${this.title} - ${this.passed}/${this.total}${sPart}${fPart} - ${result}${dPart}`;
|
||||
}
|
||||
|
||||
target.addTest(test);
|
||||
}
|
||||
|
||||
get summary(): string {
|
||||
const result = this.failed > 0 ? 'Failed' : 'Passed';
|
||||
const sPart = this.skipped > 0 ? `, skipped: ${this.skipped}` : '';
|
||||
const fPart = this.failed > 0 ? `, failed: ${this.failed}` : '';
|
||||
const dPart = ` in ${timeHelper(this.duration)}`;
|
||||
return `${this.mark} ${this.title} - ${this.passed}/${this.total}${sPart}${fPart} - ${result}${dPart}`;
|
||||
}
|
||||
|
||||
get mark(): string {
|
||||
if (this.failed > 0) return '❌️';
|
||||
else if (this.skipped === 0) return '✔️';
|
||||
return '⚠️';
|
||||
}
|
||||
get mark(): string {
|
||||
if (this.failed > 0) return '❌️';
|
||||
else if (this.skipped === 0) return '✔️';
|
||||
return '⚠️';
|
||||
}
|
||||
}
|
||||
|
||||
export class TestMeta extends Meta {
|
||||
suite: string;
|
||||
result: string | undefined;
|
||||
annotation: Annotation | undefined;
|
||||
suite: string;
|
||||
result: string | undefined;
|
||||
annotation: Annotation | undefined;
|
||||
|
||||
constructor(suite: string, title: string) {
|
||||
super(title);
|
||||
this.suite = suite;
|
||||
}
|
||||
constructor(suite: string, title: string) {
|
||||
super(title);
|
||||
this.suite = suite;
|
||||
}
|
||||
|
||||
isSkipped(): boolean {
|
||||
return this.result === 'Skipped';
|
||||
}
|
||||
isSkipped(): boolean {
|
||||
return this.result === 'Skipped';
|
||||
}
|
||||
|
||||
isFailed(): boolean {
|
||||
return this.result === 'Failed';
|
||||
}
|
||||
isFailed(): boolean {
|
||||
return this.result === 'Failed';
|
||||
}
|
||||
|
||||
get summary(): string {
|
||||
const dPart = this.isSkipped()
|
||||
? ''
|
||||
: ` in ${timeHelper(this.duration)}`;
|
||||
return `${this.mark} **${this.title}** - ${this.result}${dPart}`;
|
||||
}
|
||||
get summary(): string {
|
||||
const dPart = this.isSkipped()
|
||||
? ''
|
||||
: ` in ${timeHelper(this.duration)}`;
|
||||
return `${this.mark} **${this.title}** - ${this.result}${dPart}`;
|
||||
}
|
||||
|
||||
get mark(): string {
|
||||
if (this.isFailed()) return '❌️';
|
||||
else if (this.isSkipped()) return '⚠️';
|
||||
return '✔️';
|
||||
}
|
||||
get mark(): string {
|
||||
if (this.isFailed()) return '❌️';
|
||||
else if (this.isSkipped()) return '⚠️';
|
||||
return '✔️';
|
||||
}
|
||||
}
|
||||
|
||||
export type Annotation = components['schemas']['check-annotation'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue