This commit is contained in:
JulianRooze 2025-03-28 16:43:29 +01:00
parent 67e7f6effb
commit 8bcfbdee31
3 changed files with 49 additions and 9 deletions

View file

@ -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"
},

View file

@ -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<string, TestRunResult[]>
)
).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({

View file

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