@vitest-evals/github-reporter 0.15.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -3
- package/dist/cli.js +303 -23
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +303 -23
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +125 -1
- package/dist/index.d.ts +125 -1
- package/dist/index.js +427 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +422 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -80,9 +80,63 @@ type CollectOptions = {
|
|
|
80
80
|
/** Converts a Vitest JSON report into the compact eval report model. */
|
|
81
81
|
declare function collectEvalReport(input: VitestJsonReport, options?: CollectOptions): EvalReport;
|
|
82
82
|
|
|
83
|
+
/** Optional floors and legacy fail-on-any-failure policy for a combined report. */
|
|
84
|
+
type EvalGatePolicy = {
|
|
85
|
+
/**
|
|
86
|
+
* Minimum fraction of eval cases that must pass, in the range `[0, 1]`.
|
|
87
|
+
* Example: `0.8` requires at least 80% of eval cases to pass.
|
|
88
|
+
*/
|
|
89
|
+
minPassRate?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Minimum average eval score across scored cases, in the range `[0, 1]`.
|
|
92
|
+
*/
|
|
93
|
+
minScoreAverage?: number;
|
|
94
|
+
/**
|
|
95
|
+
* When true, require every eval case to pass. Equivalent to setting
|
|
96
|
+
* `minPassRate` to `1`, and combined with an explicit floor by taking the
|
|
97
|
+
* stricter value.
|
|
98
|
+
*/
|
|
99
|
+
failOnFailures?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/** Result of applying a gate policy to a combined eval report. */
|
|
102
|
+
type EvalGateResult = {
|
|
103
|
+
/** Whether the configured policy accepts this report. */
|
|
104
|
+
ok: boolean;
|
|
105
|
+
/** Compact status used by action outputs and summaries. */
|
|
106
|
+
status: "passed" | "failed";
|
|
107
|
+
/** True when any gate input was configured. */
|
|
108
|
+
enforced: boolean;
|
|
109
|
+
/** Eval pass rate when the report includes at least one eval case. */
|
|
110
|
+
passRate: number | null;
|
|
111
|
+
/** Short title for Check Runs and workflow annotations. */
|
|
112
|
+
title: string;
|
|
113
|
+
/** Longer explanation used in logs, summaries, and annotations. */
|
|
114
|
+
message: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Decide whether a combined eval report meets the configured CI gate.
|
|
118
|
+
*
|
|
119
|
+
* With no policy inputs, the result mirrors the report status and is not
|
|
120
|
+
* treated as an enforced gate. With floors or `failOnFailures`, non-eval
|
|
121
|
+
* failures and empty eval reports fail closed, and qualitative misses only
|
|
122
|
+
* fail when they break the configured floors.
|
|
123
|
+
*/
|
|
124
|
+
declare function evaluateEvalGate(report: EvalReport, policy?: EvalGatePolicy): EvalGateResult;
|
|
125
|
+
/** Compute the eval pass rate for a report, or null when there are no evals. */
|
|
126
|
+
declare function computePassRate(report: EvalReport): number | null;
|
|
127
|
+
/** Format a 0-1 ratio as a percentage with one decimal place. */
|
|
128
|
+
declare function formatPercent(value: number | null | undefined): string;
|
|
129
|
+
/** Build a suite-level workflow annotation for a failed enforced gate. */
|
|
130
|
+
declare function renderGateWorkflowCommand(gate: EvalGateResult): string | undefined;
|
|
131
|
+
|
|
83
132
|
/** Options for limiting rendered GitHub annotations. */
|
|
84
133
|
type AnnotationOptions = {
|
|
85
134
|
maxAnnotations?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Suite gate decision. When the gate passed, quality misses are demoted to
|
|
137
|
+
* warnings so a green score-gated check is not flooded with red failures.
|
|
138
|
+
*/
|
|
139
|
+
gate?: EvalGateResult;
|
|
86
140
|
};
|
|
87
141
|
/** GitHub Check Run annotation payload. */
|
|
88
142
|
type CheckAnnotation = {
|
|
@@ -105,6 +159,7 @@ type SummaryOptions = {
|
|
|
105
159
|
maxReasonChars?: number;
|
|
106
160
|
maxOutputChars?: number;
|
|
107
161
|
maxToolCalls?: number;
|
|
162
|
+
gate?: EvalGateResult;
|
|
108
163
|
};
|
|
109
164
|
/** Renders the GitHub Actions job summary markdown for an eval report. */
|
|
110
165
|
declare function renderJobSummary(report: EvalReport, options?: SummaryOptions): string;
|
|
@@ -116,8 +171,15 @@ type PublishCheckRunOptions = SummaryOptions & {
|
|
|
116
171
|
sha?: string;
|
|
117
172
|
name?: string;
|
|
118
173
|
apiUrl?: string;
|
|
174
|
+
detailsUrl?: string;
|
|
175
|
+
externalId?: string;
|
|
119
176
|
checkRunId?: number;
|
|
120
177
|
maxAnnotations?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Suite gate decision. When omitted, the report is evaluated with the
|
|
180
|
+
* default advisory policy so title/conclusion stay consistent.
|
|
181
|
+
*/
|
|
182
|
+
gate?: EvalGateResult;
|
|
121
183
|
};
|
|
122
184
|
/** Result of attempting to publish a GitHub Check Run. */
|
|
123
185
|
type PublishCheckRunResult = {
|
|
@@ -127,8 +189,70 @@ type PublishCheckRunResult = {
|
|
|
127
189
|
status: "created" | "updated";
|
|
128
190
|
id?: number;
|
|
129
191
|
htmlUrl?: string;
|
|
192
|
+
sha?: string;
|
|
130
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Resolve the commit SHA a Check Run should attach to.
|
|
196
|
+
*
|
|
197
|
+
* On `pull_request`, `GITHUB_SHA` is the temporary merge commit. PR status and
|
|
198
|
+
* required checks attach to the head commit, so prefer an explicit head SHA
|
|
199
|
+
* (option/env or `pull_request.head.sha` from the event payload) first.
|
|
200
|
+
*/
|
|
201
|
+
declare function resolveCheckSha(env?: NodeJS.ProcessEnv, options?: {
|
|
202
|
+
sha?: string;
|
|
203
|
+
eventPath?: string;
|
|
204
|
+
}): string | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Build a Check Run details URL that points back at the current workflow job
|
|
207
|
+
* (or run) when GitHub Actions env is present.
|
|
208
|
+
*/
|
|
209
|
+
declare function resolveCheckDetailsUrl(env?: NodeJS.ProcessEnv, options?: {
|
|
210
|
+
detailsUrl?: string;
|
|
211
|
+
}): string | undefined;
|
|
131
212
|
/** Publishes the eval report to a GitHub Check Run when configuration allows it. */
|
|
132
213
|
declare function publishCheckRun(report: EvalReport, options?: PublishCheckRunOptions): Promise<PublishCheckRunResult>;
|
|
133
214
|
|
|
134
|
-
|
|
215
|
+
/** Options for reading eval JSON files and publishing GitHub report surfaces. */
|
|
216
|
+
type PublishEvalReportOptions = SummaryOptions & EvalGatePolicy & {
|
|
217
|
+
resultPatterns: string[];
|
|
218
|
+
cwd?: string;
|
|
219
|
+
workspace?: string;
|
|
220
|
+
summaryEnabled?: boolean;
|
|
221
|
+
summaryPath?: string;
|
|
222
|
+
annotations?: boolean;
|
|
223
|
+
checkRun?: boolean;
|
|
224
|
+
failOnCheckError?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* When true, keep the workflow step green on a failed gate so the Check
|
|
227
|
+
* Run owns PR status instead of a canned job failure line. Defaults to
|
|
228
|
+
* true only when a Check Run is actually published; if publishing is
|
|
229
|
+
* skipped/fails, the step still exits non-zero on a failed gate.
|
|
230
|
+
*/
|
|
231
|
+
softFail?: boolean;
|
|
232
|
+
maxAnnotations?: number;
|
|
233
|
+
checkRunId?: number;
|
|
234
|
+
checkName?: string;
|
|
235
|
+
token?: string;
|
|
236
|
+
repository?: string;
|
|
237
|
+
sha?: string;
|
|
238
|
+
detailsUrl?: string;
|
|
239
|
+
externalId?: string;
|
|
240
|
+
warn?: (message: string) => void;
|
|
241
|
+
};
|
|
242
|
+
/** Result from publishing eval reports, including merged report data. */
|
|
243
|
+
type PublishEvalReportResult = {
|
|
244
|
+
report: EvalReport;
|
|
245
|
+
resultFiles: string[];
|
|
246
|
+
gate: EvalGateResult;
|
|
247
|
+
/**
|
|
248
|
+
* True when an enforced gate rejects the report and soft-fail did not keep
|
|
249
|
+
* the step green. Advisory (ungated) runs never fail the step, matching
|
|
250
|
+
* `fail-on-failures: false` defaults.
|
|
251
|
+
*/
|
|
252
|
+
shouldFail: boolean;
|
|
253
|
+
checkRun?: PublishCheckRunResult;
|
|
254
|
+
};
|
|
255
|
+
/** Reads, merges, and publishes eval reports to GitHub Actions surfaces. */
|
|
256
|
+
declare function publishEvalReport(options: PublishEvalReportOptions): Promise<PublishEvalReportResult>;
|
|
257
|
+
|
|
258
|
+
export { type AnnotationOptions, type CheckAnnotation, type EvalCase, type EvalFailure, type EvalGatePolicy, type EvalGateResult, type EvalReport, type PublishCheckRunOptions, type PublishCheckRunResult, type PublishEvalReportOptions, type PublishEvalReportResult, type SummaryOptions, buildCheckAnnotations, collectEvalReport, computePassRate, evaluateEvalGate, formatPercent, publishCheckRun, publishEvalReport, renderGateWorkflowCommand, renderJobSummary, renderWorkflowCommands, resolveCheckDetailsUrl, resolveCheckSha };
|