mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
25 lines
812 B
TypeScript
25 lines
812 B
TypeScript
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
|
|
return pr.head.sha
|
|
}
|
|
|
|
return github.context.sha
|
|
}
|
|
|
|
export function enforceCheckRunLimits(result: TestResult, maxAnnotations: number): void {
|
|
// Limit number of created annotations
|
|
result.annotations.splice(maxAnnotations + 1)
|
|
|
|
// Limit number of characters in annotation fields
|
|
for (const err of result.annotations) {
|
|
err.title = ellipsis(err.title || '', 255)
|
|
err.message = ellipsis(err.message, 65535)
|
|
}
|
|
}
|