From 8bcfbdee31b1cc2cc5382a072b87b75d5519a2f6 Mon Sep 17 00:00:00 2001 From: JulianRooze Date: Fri, 28 Mar 2025 16:43:29 +0100 Subject: [PATCH] . --- .eslintrc.json | 4 +-- src/main.ts | 39 +++++++++++++++++++-- src/parsers/dotnet-trx/dotnet-trx-parser.ts | 15 +++++--- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ab3d9f6..adddab2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,6 +8,7 @@ "project": "./tsconfig.json" }, "rules": { + "no-var" : "off", "i18n-text/no-en": "off", "eslint-comments/no-use": "off", "import/no-namespace": "off", @@ -37,7 +38,6 @@ "@typescript-eslint/no-unnecessary-qualifier": "error", "@typescript-eslint/no-unnecessary-type-assertion": "error", "@typescript-eslint/no-useless-constructor": "error", - "@typescript-eslint/no-var-requires": "error", "@typescript-eslint/prefer-for-of": "warn", "@typescript-eslint/prefer-function-type": "warn", "@typescript-eslint/prefer-includes": "error", @@ -45,8 +45,6 @@ "@typescript-eslint/promise-function-async": "error", "@typescript-eslint/require-array-sort-compare": "error", "@typescript-eslint/restrict-plus-operands": "error", - "semi": "off", - "@typescript-eslint/semi": ["error", "never"], "@typescript-eslint/type-annotation-spacing": "error", "@typescript-eslint/unbound-method": "error" }, diff --git a/src/main.ts b/src/main.ts index 0fe798d..37013ed 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} from './test-results' +import {TestRunResult, TestRunResultWithUrl, TestSuiteResult} from './test-results' import {getAnnotations} from './report/get-annotations' import {getReport} from './report/get-report' @@ -198,7 +198,7 @@ class TestReporter { core.info(`Processing test results for check run ${name}`) - const results: TestRunResult[] = [] + var results: TestRunResult[] = [] const result: TestRunResultWithUrl = new TestRunResultWithUrl(results, null) for (const {file, content} of files) { @@ -212,6 +212,41 @@ 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] + + // 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 TestSuiteResult( + allSuites[0].name, + allGroups, + allSuites.reduce((sum, s) => sum + s.time, 0) + ) + + return new TestRunResult( + group[0].path, + [mergedSuite], + group.reduce((sum, r) => sum + r.time, 0) + ) + }) + } + + results = groupByPath(results) + core.info(`Creating check run ${name}`) try { const existingChecks = await this.octokit.rest.checks.listForRef({ diff --git a/src/parsers/dotnet-trx/dotnet-trx-parser.ts b/src/parsers/dotnet-trx/dotnet-trx-parser.ts index a81d4a2..a0eee9d 100644 --- a/src/parsers/dotnet-trx/dotnet-trx-parser.ts +++ b/src/parsers/dotnet-trx/dotnet-trx-parser.ts @@ -109,10 +109,17 @@ export class DotnetTrxParser implements TestParser { const totalTime = parseIsoDate(times.finish).getTime() - parseIsoDate(times.start).getTime() const suites = testClasses.map(testClass => { - const tests = testClass.tests.map(test => { - const error = this.getError(test) - return new TestCaseResult(test.name, test.result, test.duration, error) - }) + const tests = testClass.tests + .map(test => { + const error = this.getError(test) + + if (error?.message === 'Skipping test: it does not belong to this partition.') { + return null + } + + return new TestCaseResult(test.name, test.result, test.duration, error) + }) + .filter(t => t != null) const group = new TestGroupResult(null, tests) return new TestSuiteResult(testClass.name, [group]) })