Automatic lifecycle management with withCheckRun
Automatic lifecycle management with withCheckRun
import { createInMemory } from "@anabranch/check-runs"; import { Task } from "@anabranch/anabranch"; const checkRuns = createInMemory(); await checkRuns .withCheckRun("my-check", "abc123def456", (started) => Task.of(async () => { // Write annotations during the check await started.writeAnnotation({ path: "src/index.ts", startLine: 42, level: "warning", message: "Unused import", }); }) ) .run(); // Automatically completes with "success" or "failure" based on callback result
Error thrown when attempting to push annotations to a closed check run.
Error thrown when using update() with annotations instead of the channel.
Error thrown when attempting to modify a completed check run.
Error thrown when attempting to start an already in-progress check run.
Error thrown when a check run is not found.
- batcherConfig: AnnotationBatcherConfig
- batchers: Map<number, BatcherState>
- client: CheckRunsLike
-
complete(): Task<CheckRun, AnyCheckRunsError>checkRun: CheckRun,conclusion: CheckRunConclusion,options?: CheckRunUpdate
-
create(): Task<CheckRun, AnyCheckRunsError>name: string,headSha: string,options?: CreateOptions
-
fromLike(): CheckRunsclient: CheckRunsLike,config?: AnnotationBatcherConfig
- setupStartedCheckRun(started: CheckRun): Task<StartedCheckRun, never>
- start(checkRun: CheckRun): Task<StartedCheckRun, AnyCheckRunsError>
- toAnyCheckRunsError(error: unknown): AnyCheckRunsError
-
update(): Task<CheckRun, AnyCheckRunsError>checkRun: CheckRun,options: CheckRunUpdate
-
watch(): Stream<CheckRun, AnyCheckRunsError>checkRun: CheckRun,options?: WatchOptions
-
withCheckRun<T>(): Task<T, AnyCheckRunsError>name: string,headSha: string,use: (started: StartedCheckRun) => Task<T, AnyCheckRunsError>,options?: CreateOptions
Error thrown when the GitHub API returns an error response.
Base error class for CheckRuns operations.
Annotation attached to a check run for reporting issues.
-
endLine: number
Ending line number (1-indexed).
-
level: "notice" | "warning" | "failure"
Severity level of the annotation.
-
message: string
Description of the issue.
-
path: string
File path relative to repository root.
-
rawDetails: string
Raw details in markdown format.
-
startLine: number
Starting line number (1-indexed).
-
title: string
Title shown in the annotation.
Configuration for annotation batching.
-
batchSize: number
Maximum annotations per batch. GitHub limits to 50. @default 50
-
flushInterval: number
Maximum time between flushes in milliseconds. @default 5000
Represents a GitHub check run with its state and metadata.
-
completedAt: Date
Timestamp when the check run finished.
-
conclusion: CheckRunConclusion
Final result, set only when status is 'completed'.
-
headSha: string
SHA of the commit being checked.
-
id: number
Unique identifier for the check run.
-
name: string
Name of the check run displayed in the UI.
-
startedAt: Date
Timestamp when the check run started.
-
status: CheckRunStatus
Current status of the check run.
-
summary: string
Summary text shown in the check run output.
-
text: string
Detailed markdown content.
-
title: string
Title displayed in the check run output.
Options for completing a check run with a conclusion.
-
conclusion: "success"
| "failure"
| "neutral"
| "cancelled"
| "timed_out"
| "action_required"Final result status of the check run.
Additional details included with CheckRuns errors.
-
checkRunId: number
ID of the affected check run.
-
rateLimitRemaining: number
Remaining rate limit quota.
-
rateLimitReset: Date
Time when rate limit resets.
-
status: number
HTTP status code from the API response.
-
complete(): Task<CheckRun, CheckRunsApiError>checkRun: CheckRun,conclusion: CheckRunConclusion,options?: CheckRunUpdate
-
create(): Task<CheckRun, CheckRunsApiError>name: string,headSha: string,options?: CreateOptions
- start(checkRun: CheckRun): Task<CheckRun, CheckRunsApiError>
-
update(): Task<CheckRun, CheckRunsApiError>checkRun: CheckRun,options: CheckRunUpdate
-
watch(): Stream<CheckRun, AnyCheckRunsError>checkRun: CheckRun,options?: WatchOptions
Configuration options for the CheckRuns client.
-
baseUrl: string
GitHub API base URL. Defaults to 'https://api.github.com'.
-
owner: string
Repository owner (user or organization).
-
repo: string
Repository name.
-
token: string
GitHub API token with repo permissions.
Fields that can be updated on an existing check run.
-
annotations: import("./annotation.ts").Annotation[]
Annotations to add to the check run.
-
summary: string
Summary of the check run results.
-
text: string
Detailed text content with Markdown support.
-
title: string
Title displayed in the check run UI.
Options for creating a new check run.
-
status: "queued" | "in_progress"
Initial status of the check run. @default 'queued'
A started check run with annotation streaming capabilities.
-
writeAnnotation: (annotation: Annotation) => Promise<void>
Write an annotation with backpressure. Waits for buffer capacity before writing.
Options for watching a check run until completion.
-
interval: number
Polling interval in milliseconds. @default 5000
-
signal: AbortSignal
AbortSignal to cancel the watch operation.
-
timeout: number
Maximum time to wait in milliseconds. @default 60000
| "failure"
| "neutral"
| "cancelled"
| "timed_out"
| "action_required"
Possible conclusion values for a completed check run.
Possible status values for a check run.