diff --git a/.eslintrc.json b/.eslintrc.json index adddab2..5e411b8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,6 +9,7 @@ }, "rules": { "no-var" : "off", + "github/array-foreach": "off", "i18n-text/no-en": "off", "eslint-comments/no-use": "off", "import/no-namespace": "off", diff --git a/dist/index.js b/dist/index.js index 0c18157..172d9d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -328,21 +328,16 @@ class TestReporter { } } function groupByPath(results) { - // Group by path and merge results - return Object.values(results.reduce((acc, result) => { - const existing = acc[result.path] || []; - acc[result.path] = [...existing, result]; - return acc; - }, {})).map(group => { - if (group.length === 1) - return group[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)); + const pathMap = new Map(); + for (const result of results) { + const existing = pathMap.get(result.path) || []; + pathMap.set(result.path, [...existing, result]); + } + const groupedResults = []; + pathMap.forEach((results, path) => { + groupedResults.push(new test_results_1.TestRunResult(path, results.flatMap(r => r.suites), results.reduce((sum, r) => sum + r.time, 0))); }); + return groupedResults; } results = groupByPath(results); core.info(`Creating check run ${name}`); @@ -570,8 +565,9 @@ class DotnetTrxParser { const suites = testClasses.map(testClass => { const tests = testClass.tests .map(test => { + var _a; 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 new test_results_1.TestCaseResult(test.name, test.result, test.duration, error); diff --git a/src/main.ts b/src/main.ts index 37013ed..5da08d4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,7 +5,7 @@ import {GitHub} from '@actions/github/lib/utils' import {LocalFileProvider} from './input-providers/local-file-provider' import {FileContent} from './input-providers/input-provider' 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 {getReport} from './report/get-report' @@ -213,36 +213,26 @@ class TestReporter { } function groupByPath(results: TestRunResult[]): TestRunResult[] { - // Group by path and merge results - return Object.values( - results.reduce( - (acc, result) => { - const existing = acc[result.path] || [] - acc[result.path] = [...existing, result] - return acc - }, - {} as Record - ) - ).map(group => { - if (group.length === 1) return group[0] + const pathMap = new Map() - // Just concatenate all suites and groups - const allSuites = group.flatMap(r => r.suites) - const allGroups = allSuites.flatMap(s => s.groups) + for (const result of results) { + const existing = pathMap.get(result.path) || [] + pathMap.set(result.path, [...existing, result]) + } - // Create a single suite with all groups - const mergedSuite = new TestSuiteResult( - allSuites[0].name, - allGroups, - allSuites.reduce((sum, s) => sum + s.time, 0) - ) + const groupedResults: TestRunResult[] = [] - return new TestRunResult( - group[0].path, - [mergedSuite], - group.reduce((sum, r) => sum + r.time, 0) + pathMap.forEach((results, path) => { + groupedResults.push( + new TestRunResult( + path, + results.flatMap(r => r.suites), + results.reduce((sum, r) => sum + r.time, 0) + ) ) }) + + return groupedResults } results = groupByPath(results) diff --git a/src/parsers/dotnet-trx/dotnet-trx-parser.ts b/src/parsers/dotnet-trx/dotnet-trx-parser.ts index a0eee9d..6968098 100644 --- a/src/parsers/dotnet-trx/dotnet-trx-parser.ts +++ b/src/parsers/dotnet-trx/dotnet-trx-parser.ts @@ -113,7 +113,7 @@ export class DotnetTrxParser implements TestParser { .map(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 }