@jphutchins/code-review 0.1.0-alpha.56 → 0.1.0-alpha.58
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/dist/index.js +66 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schema/findings.schema.json +1 -1
- package/templates/comment.eta +2 -1
package/dist/index.js
CHANGED
|
@@ -63,7 +63,9 @@ var Confidence = t.refinement(t.number, (n) => n >= 0 && n <= 1, "Confidence");
|
|
|
63
63
|
var Likelihood = t.refinement(t.number, (n) => n >= 0 && n <= 1, "Likelihood");
|
|
64
64
|
var FiniteNumber = t.refinement(t.number, (n) => Number.isFinite(n), "FiniteNumber");
|
|
65
65
|
var NonNegativePrice = t.refinement(t.number, (n) => n >= 0, "NonNegativePrice");
|
|
66
|
-
var
|
|
66
|
+
var SEMVER_SUFFIX = "(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?";
|
|
67
|
+
var SCHEMA_VERSION_RE = new RegExp(`^(0|[1-9]\\d*)\\.(\\d+)\\.(\\d+)${SEMVER_SUFFIX}$`);
|
|
68
|
+
var anchoredSchemaVersionPattern = (version) => `^${version.split(".").slice(0, 2).join("\\.")}\\.[0-9]+${SEMVER_SUFFIX}$`;
|
|
67
69
|
var SchemaVersion = t.refinement(
|
|
68
70
|
t.string,
|
|
69
71
|
(s) => SCHEMA_VERSION_RE.test(s),
|
|
@@ -3393,7 +3395,7 @@ var post = async (input, ghApi = runGhApi, readArtifact = ghArtifactReader) => {
|
|
|
3393
3395
|
noticeBody(
|
|
3394
3396
|
`${DEFAULT_MARKER}
|
|
3395
3397
|
|
|
3396
|
-
\u26A0\uFE0F **CI-fix pass completed with no findings** for \`${input.headSha.slice(0, 7)}\`${input.unverifiedNoLogs === true ? ' \u2014 **but no failing-job logs were available**, so it
|
|
3398
|
+
\u26A0\uFE0F **CI-fix pass completed with no findings** for \`${input.headSha.slice(0, 7)}\`${input.unverifiedNoLogs === true ? ' \u2014 **but no failing-job logs were available**, so it worked from the diff and any local reproduction of the checks, and "no findings" is not evidence of none' : ""} \u2014 the completed full review of \`${priorSha ? priorSha.slice(0, 7) : "an earlier commit"}\` is preserved below.${dropNote ? `
|
|
3397
3399
|
|
|
3398
3400
|
${dropNote}` : ""}`,
|
|
3399
3401
|
sticky.body
|
|
@@ -4234,8 +4236,14 @@ var IssueCommentCodec = t.intersection([
|
|
|
4234
4236
|
author_association: t.union([t.string, t.null])
|
|
4235
4237
|
})
|
|
4236
4238
|
]);
|
|
4237
|
-
var JobCodec = t.type({
|
|
4238
|
-
|
|
4239
|
+
var JobCodec = t.type({
|
|
4240
|
+
id: t.number,
|
|
4241
|
+
// A null name (an API edge) degrades to a nameless entry rather than aborting the whole gather —
|
|
4242
|
+
// the identity the reproduction steer needs is best-effort, never load-bearing.
|
|
4243
|
+
name: t.union([t.string, t.null]),
|
|
4244
|
+
conclusion: t.union([t.string, t.null])
|
|
4245
|
+
});
|
|
4246
|
+
var JOBS_JQ = ".jobs[] | {id: .id, name: .name, conclusion: .conclusion}";
|
|
4239
4247
|
var fetchPrMeta = async (repo, prNumber, ghApi) => {
|
|
4240
4248
|
const stdout = await ghApi([
|
|
4241
4249
|
`repos/${repo}/pulls/${String(prNumber)}`,
|
|
@@ -4396,6 +4404,13 @@ var downloadFailingJobLogs = async (repo, runId, outDir, ghApi) => {
|
|
|
4396
4404
|
for (const job of selected) {
|
|
4397
4405
|
try {
|
|
4398
4406
|
const log = await ghApi([`repos/${repo}/actions/jobs/${String(job.id)}/logs`]);
|
|
4407
|
+
if (log.trim() === "no log available" || log.trim() === "") {
|
|
4408
|
+
process.stderr.write(
|
|
4409
|
+
`Warning: job ${String(job.id)} has no log available (placeholder body) \u2014 not staged
|
|
4410
|
+
`
|
|
4411
|
+
);
|
|
4412
|
+
continue;
|
|
4413
|
+
}
|
|
4399
4414
|
writeFileSync(join(outDir, `job_${String(job.id)}.log`), log);
|
|
4400
4415
|
staged += 1;
|
|
4401
4416
|
} catch (err) {
|
|
@@ -4405,6 +4420,15 @@ var downloadFailingJobLogs = async (repo, runId, outDir, ghApi) => {
|
|
|
4405
4420
|
);
|
|
4406
4421
|
}
|
|
4407
4422
|
}
|
|
4423
|
+
writeFileSync(
|
|
4424
|
+
join(outDir, "failed_jobs.json"),
|
|
4425
|
+
`${JSON.stringify(
|
|
4426
|
+
failing.map((j) => ({ name: j.name, conclusion: j.conclusion })),
|
|
4427
|
+
null,
|
|
4428
|
+
2
|
|
4429
|
+
)}
|
|
4430
|
+
`
|
|
4431
|
+
);
|
|
4408
4432
|
if (failing.length > selected.length) {
|
|
4409
4433
|
process.stderr.write(
|
|
4410
4434
|
`::warning::${annotationSafe(`${String(failing.length)} failing job(s) in run ${runId}; staged ${String(staged)} of the first ${String(selected.length)} log(s) \u2014 the review does not see the rest`)}
|
|
@@ -4412,8 +4436,11 @@ var downloadFailingJobLogs = async (repo, runId, outDir, ghApi) => {
|
|
|
4412
4436
|
);
|
|
4413
4437
|
}
|
|
4414
4438
|
if (staged === 0) {
|
|
4439
|
+
const reported = failing.length > 0 ? `${String(failing.length)} failing job(s) reported` : "no job concluded 'failure' (timeouts or cancellations)";
|
|
4415
4440
|
process.stderr.write(
|
|
4416
|
-
`::warning::${annotationSafe(
|
|
4441
|
+
`::warning::${annotationSafe(
|
|
4442
|
+
`No failing-job logs could be staged for run ${runId} (${reported}) \u2014 the review must reproduce the failures itself${failing.length > 0 ? " (the failing jobs are listed in failed_jobs.json)" : ""}`
|
|
4443
|
+
)}
|
|
4417
4444
|
`
|
|
4418
4445
|
);
|
|
4419
4446
|
}
|
|
@@ -5464,11 +5491,20 @@ var deadlineCmd = defineCommand({
|
|
|
5464
5491
|
}
|
|
5465
5492
|
});
|
|
5466
5493
|
var derivedSchemaVersion = (kind, raw) => kind === "findings" ? declaredVersion(raw) : void 0;
|
|
5467
|
-
var printableSchema = (schemaPath) => {
|
|
5494
|
+
var printableSchema = (schemaPath, pinVersion) => {
|
|
5468
5495
|
const schema = JSON.parse(readFileSync(schemaPath, "utf-8"));
|
|
5469
5496
|
const enforcementSchema = Object.fromEntries(
|
|
5470
5497
|
Object.entries(schema).filter(([key2]) => key2 !== "$schema")
|
|
5471
5498
|
);
|
|
5499
|
+
if (!pinVersion) return JSON.stringify(enforcementSchema, null, 2);
|
|
5500
|
+
const properties = enforcementSchema["properties"];
|
|
5501
|
+
const schemaVersion = typeof properties === "object" && properties !== null ? properties["schema_version"] : void 0;
|
|
5502
|
+
if (typeof schemaVersion === "object" && schemaVersion !== null) {
|
|
5503
|
+
properties["schema_version"] = {
|
|
5504
|
+
...schemaVersion,
|
|
5505
|
+
pattern: anchoredSchemaVersionPattern(DEFAULT_SCHEMA_VERSION)
|
|
5506
|
+
};
|
|
5507
|
+
}
|
|
5472
5508
|
return JSON.stringify(enforcementSchema, null, 2);
|
|
5473
5509
|
};
|
|
5474
5510
|
var validateCmd = defineCommand({
|
|
@@ -5514,7 +5550,7 @@ var validateCmd = defineCommand({
|
|
|
5514
5550
|
process.stderr.write(
|
|
5515
5551
|
`
|
|
5516
5552
|
The ${kind} document must conform to this schema (the field descriptions are the authoritative spec \u2014 match the property names exactly):
|
|
5517
|
-
${printableSchema(schemaPath)}
|
|
5553
|
+
${printableSchema(schemaPath, kind === "findings" && schemaPath === schemaPathFor(kind))}
|
|
5518
5554
|
`
|
|
5519
5555
|
);
|
|
5520
5556
|
}
|
|
@@ -5983,7 +6019,26 @@ var printSchemaCmd = defineCommand({
|
|
|
5983
6019
|
run: async ({ args }) => {
|
|
5984
6020
|
const schemaKind = requireSchemaKind(args.name);
|
|
5985
6021
|
const schemaPath = requireSchemaPath(schemaKind, args["schema-version"]);
|
|
5986
|
-
process.stdout.write(
|
|
6022
|
+
process.stdout.write(
|
|
6023
|
+
`${printableSchema(schemaPath, schemaKind === "findings" && schemaPath === schemaPathFor(schemaKind))}
|
|
6024
|
+
`
|
|
6025
|
+
);
|
|
6026
|
+
}
|
|
6027
|
+
});
|
|
6028
|
+
var defaultVersionCmd = defineCommand({
|
|
6029
|
+
meta: {
|
|
6030
|
+
name: "default-version",
|
|
6031
|
+
description: "Print the in-force schema version the installed registry resolves by default \u2014 the value a draft should stamp as schema_version"
|
|
6032
|
+
},
|
|
6033
|
+
args: {
|
|
6034
|
+
kind: {
|
|
6035
|
+
type: "string",
|
|
6036
|
+
description: "Schema kind (findings | triage | prices); default: findings"
|
|
6037
|
+
}
|
|
6038
|
+
},
|
|
6039
|
+
run: async ({ args }) => {
|
|
6040
|
+
const kind = requireSchemaKind(args.kind || "findings");
|
|
6041
|
+
process.stdout.write(`${defaultVersion(kind)}
|
|
5987
6042
|
`);
|
|
5988
6043
|
}
|
|
5989
6044
|
});
|
|
@@ -6081,7 +6136,7 @@ var stopGateCmd = defineCommand({
|
|
|
6081
6136
|
var gatherCmd = defineCommand({
|
|
6082
6137
|
meta: {
|
|
6083
6138
|
name: "gather",
|
|
6084
|
-
description: "Resolve the PR from the CI head SHA and gather review inputs (diff with git-diff fallback, PR context, prior bot review, untrusted PR conversation to triage, failing-job logs) as files for the review agent"
|
|
6139
|
+
description: "Resolve the PR from the CI head SHA and gather review inputs (diff with git-diff fallback, PR context, prior bot review, untrusted PR conversation to triage, failing-job logs and the failing jobs' identities in failed_jobs.json) as files for the review agent"
|
|
6085
6140
|
},
|
|
6086
6141
|
args: {
|
|
6087
6142
|
repo: { type: "string", description: "Repository (owner/name)", required: true },
|
|
@@ -6654,6 +6709,7 @@ var main = defineCommand({
|
|
|
6654
6709
|
extract: extractCmd,
|
|
6655
6710
|
"validate-patches": validatePatchesCmd,
|
|
6656
6711
|
"print-schema": printSchemaCmd,
|
|
6712
|
+
"default-version": defaultVersionCmd,
|
|
6657
6713
|
"stop-gate": stopGateCmd,
|
|
6658
6714
|
"budget-hook": budgetHookCmd,
|
|
6659
6715
|
"print-settings": printSettingsCmd,
|
|
@@ -6665,6 +6721,6 @@ if (!process.env["VITEST"]) {
|
|
|
6665
6721
|
await runMain(main);
|
|
6666
6722
|
}
|
|
6667
6723
|
|
|
6668
|
-
export { main, snapshotIfValid };
|
|
6724
|
+
export { main, printableSchema, snapshotIfValid };
|
|
6669
6725
|
//# sourceMappingURL=index.js.map
|
|
6670
6726
|
//# sourceMappingURL=index.js.map
|