import { PullRequestCheck, PullRequestChecks, PullRequestCheckSuite } from "./githubPullRequestService.js"; /** * A job of a GitHub Actions workflow, reduced to what decides the names of the * checks it reports and the jobs it waits for. */ export interface WorkflowJob { /** The job's key under `jobs:`. */ readonly id: string; /** The job's `name:`, which may contain `${{ }}` expressions, or its key when it has none. */ readonly name: string; /** The keys of the jobs it lists in `needs:`. */ readonly needs: readonly string[]; /** Whether it calls a reusable workflow, whose jobs report as ` / `. */ readonly reusable: boolean; /** Whether it runs a matrix, whose jobs may report as ` ()`. */ readonly matrix: boolean; } /** * Reads the jobs of a workflow file, or returns `undefined` when it has none * that can be read, in which case none of its checks count as the dependency * of a required check. * * The parser reports values it does not support, such as an empty * `workflow_dispatch:` trigger, while still reading the rest, so its errors * are ignored. It supports no anchors either, which ends the jobs it reads * early; the jobs it misses only contribute no dependencies. */ export declare function parseWorkflowJobs(text: string): ReadonlyMap | undefined; /** * Marks each check that a required check waits for, directly or through other * jobs, with that required check's name in {@link PullRequestCheck.requiredBy}. * * GitHub does not report which jobs a job `needs:`, so they are read from the * workflow of the run that reported each check. This matters for an aggregate * gate, such as a `PR Gate` job that needs every other job of its workflow: * GitHub only creates its check once everything it needs has finished, so a * job it needs can fail long before the gate itself reports. * * @param requiredNames The required checks whose dependencies to mark. * @param getWorkflowJobs The jobs of the workflow at a path, if it could be read. */ export declare function annotateRequiredCheckDependencies(checks: readonly PullRequestCheck[], requiredNames: Iterable, getWorkflowJobs: (path: string) => ReadonlyMap | undefined): readonly PullRequestCheck[]; /** * The names of the checks the base branch requires: those its branch * protection and rulesets name, and any check GitHub reports as required. */ export declare function getRequiredPullRequestCheckNames(value: PullRequestChecks): ReadonlySet; /** * The required checks that have not finished: those still running, and those * that have not reported at all. Only their dependencies count; see * {@link classifyRequiredPullRequestChecks}. */ export declare function getUnfinishedRequiredPullRequestCheckNames(value: PullRequestChecks): readonly string[]; export type PullRequestCheckState = "passed" | "pending" | "failed"; /** How a check stands; the one rule every pull request surface judges checks by. */ export declare function getPullRequestCheckState(check: Pick): PullRequestCheckState; export interface RequiredPullRequestChecks { /** Whether the base branch requires no check, so that every check counts. */ readonly everyCheck: boolean; /** The checks that count, in the order they were reported. */ readonly checks: readonly PullRequestCheck[]; /** The counted checks that failed. */ readonly failed: readonly PullRequestCheck[]; /** The required checks that have not reported yet. */ readonly missing: readonly string[]; /** Whether a counted check is still running, or a required check has not reported yet. */ readonly pending: boolean; } /** * Decides which checks of a pull request head count, and how they stand. * * A required check counts, and so does every check it needs while it has not * finished, so a failure surfaces as soon as a job the required check waits * for fails. Once a required check has finished, its own result decides: an * aggregate gate may deliberately tolerate the failure of a job it needs. A * required check that has not reported yet is pending. When the base branch * requires no check at all, every check counts, including check suites that * have not reported a check yet. * * @param isIgnored Excludes checks by name, as do the patterns of * `chat.artifactIntegrations.githubPullRequests.autoMarkReadyIgnoredChecks` * when deciding readiness. An excluded required check also excludes the * checks it needs. */ export declare function classifyRequiredPullRequestChecks(value: PullRequestChecks, isIgnored?: (name: string) => boolean): RequiredPullRequestChecks; /** * Stands in for a check suite that has not reported a check yet, such as a * workflow whose jobs have not started, so that it counts as a check. */ export declare function toUnreportedCheckSuiteCheck(suite: PullRequestCheckSuite): PullRequestCheck; /** * Whether a check stands in for a check suite that has not reported a check * yet (see {@link toUnreportedCheckSuiteCheck}), which has no runs, logs or * annotations to read. */ export declare function isUnreportedCheckSuite(check: PullRequestCheck): boolean; export type PullRequestChecksStatus = "pending" | "success" | "failure"; /** * Summarizes the checks that count for a pull request head (see * {@link classifyRequiredPullRequestChecks}) as one status: a failure as soon * as any of them failed, even while others still run. Returns `undefined` * when no check counts. */ export declare function getRequiredPullRequestChecksStatus(value: PullRequestChecks): PullRequestChecksStatus | undefined;