This commit is contained in:
JulianRooze 2025-03-28 17:52:33 +01:00
parent aecaf2df91
commit 698d30fbd2
4 changed files with 29 additions and 42 deletions

View file

@ -9,6 +9,7 @@
}, },
"rules": { "rules": {
"no-var" : "off", "no-var" : "off",
"github/array-foreach": "off",
"i18n-text/no-en": "off", "i18n-text/no-en": "off",
"eslint-comments/no-use": "off", "eslint-comments/no-use": "off",
"import/no-namespace": "off", "import/no-namespace": "off",

26
dist/index.js generated vendored
View file

@ -328,21 +328,16 @@ class TestReporter {
} }
} }
function groupByPath(results) { function groupByPath(results) {
// Group by path and merge results const pathMap = new Map();
return Object.values(results.reduce((acc, result) => { for (const result of results) {
const existing = acc[result.path] || []; const existing = pathMap.get(result.path) || [];
acc[result.path] = [...existing, result]; pathMap.set(result.path, [...existing, result]);
return acc; }
}, {})).map(group => { const groupedResults = [];
if (group.length === 1) pathMap.forEach((results, path) => {
return group[0]; groupedResults.push(new test_results_1.TestRunResult(path, results.flatMap(r => r.suites), results.reduce((sum, r) => sum + r.time, 0)));
// Just concatenate all suites and groups
const allSuites = group.flatMap(r => r.suites);
const allGroups = allSuites.flatMap(s => s.groups);
// Create a single suite with all groups
const mergedSuite = new test_results_1.TestSuiteResult(allSuites[0].name, allGroups, allSuites.reduce((sum, s) => sum + s.time, 0));
return new test_results_1.TestRunResult(group[0].path, [mergedSuite], group.reduce((sum, r) => sum + r.time, 0));
}); });
return groupedResults;
} }
results = groupByPath(results); results = groupByPath(results);
core.info(`Creating check run ${name}`); core.info(`Creating check run ${name}`);
@ -570,8 +565,9 @@ class DotnetTrxParser {
const suites = testClasses.map(testClass => { const suites = testClasses.map(testClass => {
const tests = testClass.tests const tests = testClass.tests
.map(test => { .map(test => {
var _a;
const error = this.getError(test); const error = this.getError(test);
if ((error === null || error === void 0 ? void 0 : error.message) === 'Skipping test: it does not belong to this partition.') { if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.trim().match(/it does not belong to this partition/)) {
return null; return null;
} }
return new test_results_1.TestCaseResult(test.name, test.result, test.duration, error); return new test_results_1.TestCaseResult(test.name, test.result, test.duration, error);

View file

@ -5,7 +5,7 @@ import {GitHub} from '@actions/github/lib/utils'
import {LocalFileProvider} from './input-providers/local-file-provider' import {LocalFileProvider} from './input-providers/local-file-provider'
import {FileContent} from './input-providers/input-provider' import {FileContent} from './input-providers/input-provider'
import {ParseOptions, TestParser} from './test-parser' import {ParseOptions, TestParser} from './test-parser'
import {TestRunResult, TestRunResultWithUrl, TestSuiteResult} from './test-results' import {TestRunResult, TestRunResultWithUrl} from './test-results'
import {getAnnotations} from './report/get-annotations' import {getAnnotations} from './report/get-annotations'
import {getReport} from './report/get-report' import {getReport} from './report/get-report'
@ -213,36 +213,26 @@ class TestReporter {
} }
function groupByPath(results: TestRunResult[]): TestRunResult[] { function groupByPath(results: TestRunResult[]): TestRunResult[] {
// Group by path and merge results const pathMap = new Map<string, TestRunResult[]>()
return Object.values(
results.reduce(
(acc, result) => {
const existing = acc[result.path] || []
acc[result.path] = [...existing, result]
return acc
},
{} as Record<string, TestRunResult[]>
)
).map(group => {
if (group.length === 1) return group[0]
// Just concatenate all suites and groups for (const result of results) {
const allSuites = group.flatMap(r => r.suites) const existing = pathMap.get(result.path) || []
const allGroups = allSuites.flatMap(s => s.groups) pathMap.set(result.path, [...existing, result])
}
// Create a single suite with all groups const groupedResults: TestRunResult[] = []
const mergedSuite = new TestSuiteResult(
allSuites[0].name,
allGroups,
allSuites.reduce((sum, s) => sum + s.time, 0)
)
return new TestRunResult( pathMap.forEach((results, path) => {
group[0].path, groupedResults.push(
[mergedSuite], new TestRunResult(
group.reduce((sum, r) => sum + r.time, 0) path,
results.flatMap(r => r.suites),
results.reduce((sum, r) => sum + r.time, 0)
)
) )
}) })
return groupedResults
} }
results = groupByPath(results) results = groupByPath(results)

View file

@ -113,7 +113,7 @@ export class DotnetTrxParser implements TestParser {
.map(test => { .map(test => {
const error = this.getError(test) const error = this.getError(test)
if (error?.message === 'Skipping test: it does not belong to this partition.') { if (error?.message?.trim().match(/it does not belong to this partition/)) {
return null return null
} }