mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Enforce Check Run API limits
This commit is contained in:
parent
fdd3509024
commit
7af0073fa3
5 changed files with 49 additions and 11 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import * as github from '@actions/github'
|
||||
import {EventPayloads} from '@octokit/webhooks'
|
||||
|
||||
import {TestResult} from '../parsers/parser-types'
|
||||
import {ellipsis} from './markdown-utils'
|
||||
|
||||
export function getCheckRunSha(): string {
|
||||
if (github.context.payload.pull_request) {
|
||||
const pr = github.context.payload.pull_request as EventPayloads.WebhookPayloadPullRequestPullRequest
|
||||
|
|
@ -9,3 +12,19 @@ export function getCheckRunSha(): string {
|
|||
|
||||
return github.context.sha
|
||||
}
|
||||
|
||||
export function enforceCheckRunLimits(result: TestResult, maxAnnotations: number): void {
|
||||
const output = result.output
|
||||
if (!output) {
|
||||
return
|
||||
}
|
||||
|
||||
// Limit number of created annotations
|
||||
output.annotations?.splice(maxAnnotations + 1)
|
||||
|
||||
// Limit number of characters in annotation fields
|
||||
for (const err of output.annotations ?? []) {
|
||||
err.title = ellipsis(err.title || '', 255)
|
||||
err.message = ellipsis(err.message, 65535)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue