mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
.
This commit is contained in:
parent
67e7f6effb
commit
8bcfbdee31
3 changed files with 49 additions and 9 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
"project": "./tsconfig.json"
|
"project": "./tsconfig.json"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"no-var" : "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",
|
||||||
|
|
@ -37,7 +38,6 @@
|
||||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||||
"@typescript-eslint/no-useless-constructor": "error",
|
"@typescript-eslint/no-useless-constructor": "error",
|
||||||
"@typescript-eslint/no-var-requires": "error",
|
|
||||||
"@typescript-eslint/prefer-for-of": "warn",
|
"@typescript-eslint/prefer-for-of": "warn",
|
||||||
"@typescript-eslint/prefer-function-type": "warn",
|
"@typescript-eslint/prefer-function-type": "warn",
|
||||||
"@typescript-eslint/prefer-includes": "error",
|
"@typescript-eslint/prefer-includes": "error",
|
||||||
|
|
@ -45,8 +45,6 @@
|
||||||
"@typescript-eslint/promise-function-async": "error",
|
"@typescript-eslint/promise-function-async": "error",
|
||||||
"@typescript-eslint/require-array-sort-compare": "error",
|
"@typescript-eslint/require-array-sort-compare": "error",
|
||||||
"@typescript-eslint/restrict-plus-operands": "error",
|
"@typescript-eslint/restrict-plus-operands": "error",
|
||||||
"semi": "off",
|
|
||||||
"@typescript-eslint/semi": ["error", "never"],
|
|
||||||
"@typescript-eslint/type-annotation-spacing": "error",
|
"@typescript-eslint/type-annotation-spacing": "error",
|
||||||
"@typescript-eslint/unbound-method": "error"
|
"@typescript-eslint/unbound-method": "error"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
39
src/main.ts
39
src/main.ts
|
|
@ -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} from './test-results'
|
import {TestRunResult, TestRunResultWithUrl, TestSuiteResult} 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'
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ class TestReporter {
|
||||||
|
|
||||||
core.info(`Processing test results for check run ${name}`)
|
core.info(`Processing test results for check run ${name}`)
|
||||||
|
|
||||||
const results: TestRunResult[] = []
|
var results: TestRunResult[] = []
|
||||||
const result: TestRunResultWithUrl = new TestRunResultWithUrl(results, null)
|
const result: TestRunResultWithUrl = new TestRunResultWithUrl(results, null)
|
||||||
|
|
||||||
for (const {file, content} of files) {
|
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}`)
|
core.info(`Creating check run ${name}`)
|
||||||
try {
|
try {
|
||||||
const existingChecks = await this.octokit.rest.checks.listForRef({
|
const existingChecks = await this.octokit.rest.checks.listForRef({
|
||||||
|
|
|
||||||
|
|
@ -109,10 +109,17 @@ export class DotnetTrxParser implements TestParser {
|
||||||
const totalTime = parseIsoDate(times.finish).getTime() - parseIsoDate(times.start).getTime()
|
const totalTime = parseIsoDate(times.finish).getTime() - parseIsoDate(times.start).getTime()
|
||||||
|
|
||||||
const suites = testClasses.map(testClass => {
|
const suites = testClasses.map(testClass => {
|
||||||
const tests = testClass.tests.map(test => {
|
const tests = testClass.tests
|
||||||
const error = this.getError(test)
|
.map(test => {
|
||||||
return new TestCaseResult(test.name, test.result, test.duration, error)
|
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)
|
const group = new TestGroupResult(null, tests)
|
||||||
return new TestSuiteResult(testClass.name, [group])
|
return new TestSuiteResult(testClass.name, [group])
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue