@theholocron/astromech 5.0.0-alpha.574 → 5.0.0-alpha.576
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 +16 -0
- package/dist/index.d.mts +48 -1
- package/dist/index.mjs +74 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -234,6 +234,22 @@ never gives `success`. Nothing calls it yet: the reusable `ci.yml` still polls w
|
|
|
234
234
|
verdicts differ (it needs `jq`; CI has it, and without `jq` or `CI` it skips). One deliberate difference: the jq passes an empty
|
|
235
235
|
`expected` list, the function does not.
|
|
236
236
|
|
|
237
|
+
`requiredChecksVerdict({ expected, statuses, checkRuns, commitStatuses, incomplete? })` is the verdict for a repo with no
|
|
238
|
+
aggregate (`ci: { aggregate: "none" }`; SPEC-0118, #2754, step 1): the same question, "are the required checks green?",
|
|
239
|
+
answered from the newest run of each required check, as `{ state: "success" | "failure" | "pending" | "none", failing }`
|
|
240
|
+
(the shape of the CLI's `PullRequestChecks`; each `failing` entry is `{ name, url?, required }`). It is pure and runs
|
|
241
|
+
`evaluateAggregate()` and `newestCheckRuns()` with no deadline, so matching is theirs, and `evaluateAggregate()` itself is
|
|
242
|
+
unchanged. Nothing calls it yet; `close work`, the board and Sentinel will, so the rule lives in one place. The rules:
|
|
243
|
+
|
|
244
|
+
- Only the newest run of each name counts; `skipped` and `neutral` pass.
|
|
245
|
+
- `success` only when every required check is satisfied; one that has not posted is `pending`.
|
|
246
|
+
- `failure` as soon as a required check's newest run failed (`failure`, `timed_out`, `startup_failure`, `action_required`,
|
|
247
|
+
`stale`), because waiting cannot turn it green.
|
|
248
|
+
- A re-run still going over an earlier failure is `pending`; so is a `cancelled` newest run (`evaluateAggregate()` counts
|
|
249
|
+
that as a failure).
|
|
250
|
+
- An empty `expected` list or an `incomplete` read is `none`, never `success`.
|
|
251
|
+
- Only required checks decide: a failing optional check is listed in `failing` with `required: false` and never changes `state`.
|
|
252
|
+
|
|
237
253
|
### `codecov.yml`
|
|
238
254
|
|
|
239
255
|
Astromech no longer writes `codecov.yml`: the `coverage` provider does, through its optional `Coverage.configFiles()`
|
package/dist/index.d.mts
CHANGED
|
@@ -201,6 +201,53 @@ interface PostAggregateResult {
|
|
|
201
201
|
* again if the verdict moved, so a slow older computation cannot leave a stale `in_progress` over a `success`.
|
|
202
202
|
*/
|
|
203
203
|
export declare function postAggregate(input: PostAggregateInput): Promise<PostAggregateResult>;
|
|
204
|
+
/** Everything {@link requiredChecksVerdict} reads: one commit's runs and statuses and what must be green. */
|
|
205
|
+
interface RequiredChecksInput {
|
|
206
|
+
/** Check ids: each needs a check run named `<id> / ...`. An empty list makes the verdict `none`. */
|
|
207
|
+
expected: string[];
|
|
208
|
+
/** Contexts that must reach success, as a check run named like the context, else as a commit status. */
|
|
209
|
+
statuses: string[];
|
|
210
|
+
/** Every check run on the commit, any order and any number per name. */
|
|
211
|
+
checkRuns: AggregateCheckRun[];
|
|
212
|
+
/** The commit statuses, newest first as the API returns them. */
|
|
213
|
+
commitStatuses: AggregateCommitStatus[];
|
|
214
|
+
/** Set when the state could not be read in full (a truncated list, a failed read): the verdict is then `none`. */
|
|
215
|
+
incomplete?: string;
|
|
216
|
+
}
|
|
217
|
+
/** Where the required checks of a commit stand: the same four words as `PullRequestChecks.state` in the CLI. */
|
|
218
|
+
type RequiredChecksState = "success" | "failure" | "pending" | "none";
|
|
219
|
+
/** One failing check of a commit. */
|
|
220
|
+
interface RequiredChecksFailure {
|
|
221
|
+
/** The failing check run's name, or the id or context of a required check that failed. */
|
|
222
|
+
name: string;
|
|
223
|
+
/** A link to the check, absent when there is none. */
|
|
224
|
+
url?: string;
|
|
225
|
+
/** True when the check is required; an optional failure never changes the state. */
|
|
226
|
+
required: boolean;
|
|
227
|
+
}
|
|
228
|
+
/** The verdict, shaped like the CLI's `PullRequestChecks` (without the `sha`), so a caller can pass it on as it is. */
|
|
229
|
+
interface RequiredChecksVerdict {
|
|
230
|
+
/** `success` only when every required check is green; `pending` while one can still change; `none` when unknown. */
|
|
231
|
+
state: RequiredChecksState;
|
|
232
|
+
/** The failing checks of the commit, the required ones first; empty unless something failed. */
|
|
233
|
+
failing: RequiredChecksFailure[];
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Decides whether the required checks of one commit are green, without the `ci / Required checks` aggregate.
|
|
237
|
+
*
|
|
238
|
+
* Pure: no clock, no network, no GitHub types. It is the one place the rule lives; callers pass it the runs and
|
|
239
|
+
* statuses they read and the `{ expected, statuses }` list of the required checks. Matching and the newest-run rule
|
|
240
|
+
* are {@link evaluateAggregate}'s and `newestCheckRuns()`'s, run with no deadline.
|
|
241
|
+
*
|
|
242
|
+
* - Only the newest run of each check name counts; `skipped` and `neutral` pass.
|
|
243
|
+
* - `success` only when every required check is satisfied; one that has not posted is `pending`.
|
|
244
|
+
* - `failure` as soon as a required check's newest run failed, even while a sibling run is still going.
|
|
245
|
+
* - A re-run still going over an earlier failure is `pending`, and so is a `cancelled` newest run (which
|
|
246
|
+
* {@link evaluateAggregate} itself counts as a failure; its own behaviour is unchanged).
|
|
247
|
+
* - An empty `expected` list or an `incomplete` read is `none` (unknown), never `success`.
|
|
248
|
+
* - Only required checks decide. A failing optional check is listed in `failing` with `required: false`.
|
|
249
|
+
*/
|
|
250
|
+
export declare function requiredChecksVerdict(input: RequiredChecksInput): RequiredChecksVerdict;
|
|
204
251
|
/** A commit status a coverage provider reports on a pull request (names only), as `Coverage.statusContexts()` returns it. */
|
|
205
252
|
interface StatusContext {
|
|
206
253
|
/** The context GitHub shows, such as `codecov/patch`. */
|
|
@@ -1627,4 +1674,4 @@ declare function createConfig$8(): string;
|
|
|
1627
1674
|
declare function createConfig$9(): string;
|
|
1628
1675
|
/** The `.yamlignore` body. */
|
|
1629
1676
|
declare function createIgnoreConfig(): string;
|
|
1630
|
-
export { type AggregateAnnotation, type AggregateApi, type AggregateCheckRun, type AggregateChecks, type AggregateCommitStatus, type AggregateResult, type AggregateRow, type AggregateWrite, type Astromech, type AstromechOptions, type CheckReleaseLinesInput, type CiJobReport, type CiOptions, type CiReport, type CreateHeaderOptions, type DependabotConfigOptions, type DeployOnReleaseOptions, type DeployOnReleaseReport, type DeployOnReleaseResult, type WorkspacePackage as DeployWorkspacePackage, type DocsCoverageMode, type EvaluateAggregateInput, type ExecFn, type GitTag, type GroupJobReport, type GroupOptions, type GroupReport, type HeaderFunctions, type LegacyTarget, type LocalRunner, type MergedScripts, type NpmDistTags, type OrgContext, type PackageBehind, type PackageRole, type PackageScriptProblem, type PlannedKind, type PlannedTask, type PostAggregateInput, type PostAggregateResult, type PreviewConfig, type ReleaseLine, type ReleaseTagCheck, type ReleaseTagState, type RepoShape, type RunLogger, type RunOptions, type RunTaskInput, type RunTaskReport, type StatusContext, type TaskDef, type TaskGroup, type TaskScope, type TsconfigOptions, type WorkflowHeaderFormat, type WorkspacePackage$1 as WorkspacePackage, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createIgnoreConfig as createYamlignore, createConfig$9 as createYamllint };
|
|
1677
|
+
export { type AggregateAnnotation, type AggregateApi, type AggregateCheckRun, type AggregateChecks, type AggregateCommitStatus, type AggregateResult, type AggregateRow, type AggregateWrite, type Astromech, type AstromechOptions, type CheckReleaseLinesInput, type CiJobReport, type CiOptions, type CiReport, type CreateHeaderOptions, type DependabotConfigOptions, type DeployOnReleaseOptions, type DeployOnReleaseReport, type DeployOnReleaseResult, type WorkspacePackage as DeployWorkspacePackage, type DocsCoverageMode, type EvaluateAggregateInput, type ExecFn, type GitTag, type GroupJobReport, type GroupOptions, type GroupReport, type HeaderFunctions, type LegacyTarget, type LocalRunner, type MergedScripts, type NpmDistTags, type OrgContext, type PackageBehind, type PackageRole, type PackageScriptProblem, type PlannedKind, type PlannedTask, type PostAggregateInput, type PostAggregateResult, type PreviewConfig, type ReleaseLine, type ReleaseTagCheck, type ReleaseTagState, type RepoShape, type RequiredChecksFailure, type RequiredChecksInput, type RequiredChecksState, type RequiredChecksVerdict, type RunLogger, type RunOptions, type RunTaskInput, type RunTaskReport, type StatusContext, type TaskDef, type TaskGroup, type TaskScope, type TsconfigOptions, type WorkflowHeaderFormat, type WorkspacePackage$1 as WorkspacePackage, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createIgnoreConfig as createYamlignore, createConfig$9 as createYamllint };
|
package/dist/index.mjs
CHANGED
|
@@ -55,13 +55,13 @@ function renderAggregate(rows) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
// src/aggregate/evaluate-aggregate/evaluate-aggregate.ts
|
|
58
|
-
const PASSING = /* @__PURE__ */ new Set([
|
|
58
|
+
const PASSING$1 = /* @__PURE__ */ new Set([
|
|
59
59
|
"success",
|
|
60
60
|
"skipped",
|
|
61
61
|
"neutral"
|
|
62
62
|
]);
|
|
63
63
|
function passes(conclusion) {
|
|
64
|
-
return PASSING.has(conclusion ?? "");
|
|
64
|
+
return PASSING$1.has(conclusion ?? "");
|
|
65
65
|
}
|
|
66
66
|
function row(id, kind, state, detail, url) {
|
|
67
67
|
return {
|
|
@@ -285,6 +285,77 @@ async function postAggregate(input) {
|
|
|
285
285
|
rewritten
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
|
+
// src/aggregate/required-checks-verdict/required-checks-verdict.ts
|
|
289
|
+
const NO_DEADLINE = {
|
|
290
|
+
now: 0,
|
|
291
|
+
startedAt: 0,
|
|
292
|
+
timeoutMs: Number.POSITIVE_INFINITY
|
|
293
|
+
};
|
|
294
|
+
const PASSING = [
|
|
295
|
+
"success",
|
|
296
|
+
"skipped",
|
|
297
|
+
"neutral"
|
|
298
|
+
];
|
|
299
|
+
function rowsFor(input, checkRuns) {
|
|
300
|
+
return evaluateAggregate({
|
|
301
|
+
expected: input.expected,
|
|
302
|
+
statuses: input.statuses,
|
|
303
|
+
checkRuns,
|
|
304
|
+
commitStatuses: input.commitStatuses,
|
|
305
|
+
...NO_DEADLINE
|
|
306
|
+
}).rows.filter((row) => row.kind !== "config");
|
|
307
|
+
}
|
|
308
|
+
function isBad(run) {
|
|
309
|
+
return run.status === "completed" && !PASSING.includes(run.conclusion ?? "") && run.conclusion !== "cancelled";
|
|
310
|
+
}
|
|
311
|
+
function failure(name, url, required) {
|
|
312
|
+
return url === null ? {
|
|
313
|
+
name,
|
|
314
|
+
required
|
|
315
|
+
} : {
|
|
316
|
+
name,
|
|
317
|
+
url,
|
|
318
|
+
required
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Decides whether the required checks of one commit are green, without the `ci / Required checks` aggregate.
|
|
323
|
+
*
|
|
324
|
+
* Pure: no clock, no network, no GitHub types. It is the one place the rule lives; callers pass it the runs and
|
|
325
|
+
* statuses they read and the `{ expected, statuses }` list of the required checks. Matching and the newest-run rule
|
|
326
|
+
* are {@link evaluateAggregate}'s and `newestCheckRuns()`'s, run with no deadline.
|
|
327
|
+
*
|
|
328
|
+
* - Only the newest run of each check name counts; `skipped` and `neutral` pass.
|
|
329
|
+
* - `success` only when every required check is satisfied; one that has not posted is `pending`.
|
|
330
|
+
* - `failure` as soon as a required check's newest run failed, even while a sibling run is still going.
|
|
331
|
+
* - A re-run still going over an earlier failure is `pending`, and so is a `cancelled` newest run (which
|
|
332
|
+
* {@link evaluateAggregate} itself counts as a failure; its own behaviour is unchanged).
|
|
333
|
+
* - An empty `expected` list or an `incomplete` read is `none` (unknown), never `success`.
|
|
334
|
+
* - Only required checks decide. A failing optional check is listed in `failing` with `required: false`.
|
|
335
|
+
*/
|
|
336
|
+
function requiredChecksVerdict(input) {
|
|
337
|
+
const newest = newestCheckRuns(input.checkRuns);
|
|
338
|
+
const optional = newest.filter((run) => isBad(run) && rowsFor(input, [run]).every((row) => row.state === "missing")).map((run) => failure(run.name, run.url, false));
|
|
339
|
+
if (input.expected.length === 0 || input.incomplete !== void 0) return {
|
|
340
|
+
state: "none",
|
|
341
|
+
failing: optional
|
|
342
|
+
};
|
|
343
|
+
const settled = newest.map((run) => run.conclusion === "cancelled" ? {
|
|
344
|
+
...run,
|
|
345
|
+
status: "in_progress",
|
|
346
|
+
conclusion: null
|
|
347
|
+
} : run);
|
|
348
|
+
const failed = rowsFor(input, settled.filter((run) => run.status === "completed")).filter((row) => row.state === "failure");
|
|
349
|
+
const failing = [...failed.map((row) => failure(row.id, row.url, true)), ...optional];
|
|
350
|
+
if (failed.length > 0) return {
|
|
351
|
+
state: "failure",
|
|
352
|
+
failing
|
|
353
|
+
};
|
|
354
|
+
return {
|
|
355
|
+
state: rowsFor(input, settled).every((row) => row.state === "success") ? "success" : "pending",
|
|
356
|
+
failing
|
|
357
|
+
};
|
|
358
|
+
}
|
|
288
359
|
// src/vocabulary/suites/suites.ts
|
|
289
360
|
/**
|
|
290
361
|
* The suites the registry declares, in the order their first leaf appears: `test`, `lint`, `scan` and `validate`. A suite is declared by the `suite` field of its
|
|
@@ -4586,4 +4657,4 @@ function createConfig$9() {
|
|
|
4586
4657
|
function createIgnoreConfig() {
|
|
4587
4658
|
return `${workflowHeader()}${_yamlignore_default}`;
|
|
4588
4659
|
}
|
|
4589
|
-
export { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, AGGREGATE_TIMEOUT_MS, CI_ORDER, DCO_CHECK, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, REUSABLE_ACTIONS, REUSABLE_WORKFLOWS, SUITES, TASKS, TEMPLATE_HOME, WORKFLOW_CHECK_CONTEXTS, WORKFLOW_TEMPLATES, WORKFLOW_TEMPLATE_PROPERTIES, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, codecovUploads, compareVersions, createAstromech, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createHeader, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createTsconfig, createIgnoreConfig as createYamlignore, createConfig$9 as createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, deriveDeployPaths, describeTasks, evaluateAggregate, extractPreviewConfig, formatJson, frozenReusablePaths, generateCombinedDeployContent, generateThinCallerContent, hostedReusableWorkflows, idFromSource, isDeprecated, isGeneratedScript, isTask, legacyCaller, legacyCallerFile, legacyFile, legacyGate, legacyName, legacyWorkflowKey, localize, localizeActions, matchNamespace, mergeScripts, normalizeWorkflowWith, packageLocation, planSuites, planTasks, postAggregate, readWorkspacePackages, recordDeploys, requiredChecks, resolveTaskName, reusableTemplates, runCi, runGroup, runTask, scriptName, scriptsFor, stampDeprecated, suiteMembers, taskKey, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages };
|
|
4660
|
+
export { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, AGGREGATE_TIMEOUT_MS, CI_ORDER, DCO_CHECK, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, REUSABLE_ACTIONS, REUSABLE_WORKFLOWS, SUITES, TASKS, TEMPLATE_HOME, WORKFLOW_CHECK_CONTEXTS, WORKFLOW_TEMPLATES, WORKFLOW_TEMPLATE_PROPERTIES, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, codecovUploads, compareVersions, createAstromech, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createHeader, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createTsconfig, createIgnoreConfig as createYamlignore, createConfig$9 as createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, deriveDeployPaths, describeTasks, evaluateAggregate, extractPreviewConfig, formatJson, frozenReusablePaths, generateCombinedDeployContent, generateThinCallerContent, hostedReusableWorkflows, idFromSource, isDeprecated, isGeneratedScript, isTask, legacyCaller, legacyCallerFile, legacyFile, legacyGate, legacyName, legacyWorkflowKey, localize, localizeActions, matchNamespace, mergeScripts, normalizeWorkflowWith, packageLocation, planSuites, planTasks, postAggregate, readWorkspacePackages, recordDeploys, requiredChecks, requiredChecksVerdict, resolveTaskName, reusableTemplates, runCi, runGroup, runTask, scriptName, scriptsFor, stampDeprecated, suiteMembers, taskKey, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/astromech",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.576",
|
|
4
4
|
"description": "The Holocron task runner — one task manifest drives `holocron run`, `holocron run ci`, the CI workflows, package.json scripts, linters, and required checks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@commitlint/lint": "^21.2.3",
|
|
56
56
|
"@commitlint/load": "^21.2.3",
|
|
57
57
|
"@commitlint/types": "^21.2.3",
|
|
58
|
-
"@theholocron/datapad": "5.0.0-alpha.
|
|
59
|
-
"@theholocron/fs-utils": "^1.17.0-alpha.9",
|
|
58
|
+
"@theholocron/datapad": "5.0.0-alpha.576",
|
|
60
59
|
"@theholocron/json-utils": "^1.17.0-alpha.9",
|
|
60
|
+
"@theholocron/fs-utils": "^1.17.0-alpha.9",
|
|
61
61
|
"@theholocron/misc-utils": "^1.17.0-alpha.9",
|
|
62
62
|
"@theholocron/pkg-utils": "^1.17.0-alpha.9"
|
|
63
63
|
},
|