mirror of
https://github.com/dorny/test-reporter.git
synced 2026-03-21 23:52:12 +01:00
Simplify the code as the cast to WorkflowRunPR type is not necessary
Fixes the error: ``` test-reporter/src/utils/github-utils.ts 18:17 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion ```
This commit is contained in:
parent
67e9e545d6
commit
8446e5e701
1 changed files with 1 additions and 3 deletions
|
|
@ -6,8 +6,6 @@ import * as github from '@actions/github'
|
||||||
import {GitHub} from '@actions/github/lib/utils'
|
import {GitHub} from '@actions/github/lib/utils'
|
||||||
import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types'
|
import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types'
|
||||||
|
|
||||||
type WorkflowRunPR = WorkflowRunEvent['workflow_run']['pull_requests'][number]
|
|
||||||
|
|
||||||
export function getCheckRunContext(): {sha: string; runId: number} {
|
export function getCheckRunContext(): {sha: string; runId: number} {
|
||||||
if (github.context.eventName === 'workflow_run') {
|
if (github.context.eventName === 'workflow_run') {
|
||||||
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
|
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
|
||||||
|
|
@ -15,7 +13,7 @@ export function getCheckRunContext(): {sha: string; runId: number} {
|
||||||
if (!event.workflow_run) {
|
if (!event.workflow_run) {
|
||||||
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
|
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
|
||||||
}
|
}
|
||||||
const prs = (event.workflow_run.pull_requests ?? []) as WorkflowRunPR[]
|
const prs = event.workflow_run.pull_requests ?? []
|
||||||
// For `workflow_run`, we want to report against the PR commit when possible so annotations land
|
// For `workflow_run`, we want to report against the PR commit when possible so annotations land
|
||||||
// on the contributor's changes. Prefer the PR whose `head.ref` matches `workflow_run.head_branch`,
|
// on the contributor's changes. Prefer the PR whose `head.ref` matches `workflow_run.head_branch`,
|
||||||
// then fall back to the first PR head SHA, and finally to `workflow_run.head_sha` for non-PR runs.
|
// then fall back to the first PR head SHA, and finally to `workflow_run.head_sha` for non-PR runs.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue