@intentius/chant 0.124.79 → 0.124.81
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/ci-note-commands.d.ts +199 -0
- package/dist/ci-note-commands.d.ts.map +1 -0
- package/dist/ci-note-commands.js +372 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +7 -1
- package/dist/cli/handlers/pr-notes.d.ts +13 -0
- package/dist/cli/handlers/pr-notes.d.ts.map +1 -0
- package/dist/cli/handlers/pr-notes.js +73 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +10 -1
- package/dist/cli/mcp/product-tools.d.ts.map +1 -1
- package/dist/cli/mcp/product-tools.js +1 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +10 -0
- package/dist/cli/registry.d.ts +4 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/capability.d.ts +22 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/pr-pipeline.d.ts +22 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +26 -0
- package/dist/components/product-pipeline.d.ts +12 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +5 -1
- package/dist/lifecycle/release-version.d.ts.map +1 -1
- package/dist/lifecycle/release-version.js +1 -2
- package/dist/op/index.d.ts +3 -3
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +2 -2
- package/dist/op/op-waves-after-plan.d.ts +33 -0
- package/dist/op/op-waves-after-plan.d.ts.map +1 -1
- package/dist/op/op-waves-after-plan.js +41 -4
- package/dist/op/op-waves-capability.d.ts +13 -1
- package/dist/op/op-waves-capability.d.ts.map +1 -1
- package/dist/op/op-waves-capability.js +22 -14
- package/dist/op/op-waves-run-hooks.d.ts.map +1 -1
- package/dist/op/op-waves-run-hooks.js +1 -2
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +125 -20
- package/dist/op/op-waves.d.ts +9 -5
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/parallelism.d.ts +9 -0
- package/dist/parallelism.d.ts.map +1 -1
- package/dist/parallelism.js +15 -0
- package/dist/pr-forge-reads.d.ts +151 -1
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +265 -1
- package/dist/release-floors.d.ts +15 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +17 -3
- package/dist/wave-runtime.mjs +288 -288
- package/package.json +1 -1
- package/src/ci-note-commands.test.ts +377 -0
- package/src/ci-note-commands.ts +479 -0
- package/src/cli/handlers/build.ts +7 -1
- package/src/cli/handlers/pr-notes.ts +70 -0
- package/src/cli/main.ts +10 -1
- package/src/cli/mcp/product-tools.test.ts +1 -2
- package/src/cli/mcp/product-tools.ts +1 -2
- package/src/cli/parse-args.ts +8 -0
- package/src/cli/registry.ts +4 -0
- package/src/components/capability.ts +22 -0
- package/src/components/pr-pipeline.ts +35 -0
- package/src/components/product-pipeline.test.ts +14 -0
- package/src/components/product-pipeline.ts +13 -1
- package/src/lifecycle/release-version.ts +1 -2
- package/src/op/index.ts +3 -2
- package/src/op/op-waves-after-plan-wave.test.ts +2 -3
- package/src/op/op-waves-after-plan.ts +61 -4
- package/src/op/op-waves-capability.test.ts +3 -1
- package/src/op/op-waves-capability.ts +27 -18
- package/src/op/op-waves-gate-port.test.ts +231 -0
- package/src/op/op-waves-parallel-plans.test.ts +185 -0
- package/src/op/op-waves-parallelism.test.ts +5 -0
- package/src/op/op-waves-run-hooks.test.ts +2 -3
- package/src/op/op-waves-run-hooks.ts +1 -2
- package/src/op/op-waves-run.ts +123 -23
- package/src/op/op-waves-step-wave.test.ts +3 -4
- package/src/op/op-waves.ts +9 -5
- package/src/parallelism.ts +26 -0
- package/src/pr-forge-reads-compare.test.ts +145 -0
- package/src/pr-forge-reads.test.ts +203 -0
- package/src/pr-forge-reads.ts +398 -1
- package/src/release-floors.ts +24 -3
package/src/pr-forge-reads.ts
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* state and merge commit, the pull requests from a branch (or a branch
|
|
5
5
|
* prefix) in any state, every note on a pull request, GitHub's check runs on
|
|
6
6
|
* a commit, a pull request's commits, a collaborator's permission level, and
|
|
7
|
-
* every open pull request in the repository
|
|
7
|
+
* every open pull request in the repository; and a head's workflow runs
|
|
8
|
+
* (GitLab's pipelines), a run, its jobs, and the artifacts it kept, by name in
|
|
9
|
+
* a run or across the repository, as a product's review agent reads them
|
|
10
|
+
* (#4846); the files a head changes since its merge base, a job by id, and
|
|
11
|
+
* a file of a GitLab job's artifacts (#4862).
|
|
8
12
|
*
|
|
9
13
|
* They take the same options as the clients in `./pr-forge.ts` and live in
|
|
10
14
|
* their own module, imported only by the products that call them, so the
|
|
@@ -101,6 +105,124 @@ export interface PullRequestsFromOptions {
|
|
|
101
105
|
limit?: number;
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
/**
|
|
109
|
+
* A workflow run (#4846): a GitHub or Forgejo Actions run, or a GitLab
|
|
110
|
+
* pipeline.
|
|
111
|
+
*/
|
|
112
|
+
export interface WorkflowRun {
|
|
113
|
+
id: number;
|
|
114
|
+
/**
|
|
115
|
+
* The event that started it. GitHub's `event`. Forgejo's `trigger_event`,
|
|
116
|
+
* the workflow's own trigger: Forgejo lists a `pull_request_target` run
|
|
117
|
+
* with `event: pull_request`, which is {@link listedEvent}. GitLab's
|
|
118
|
+
* `source` (`merge_request_event`, `push`, `schedule`, `api`, ...).
|
|
119
|
+
*/
|
|
120
|
+
event: string;
|
|
121
|
+
/** The event as the forge lists it, when that differs from {@link event} (Forgejo's `event` beside its `trigger_event`). */
|
|
122
|
+
listedEvent?: string;
|
|
123
|
+
/** The workflow's file name, such as `pipeline.yml`: the last part of GitHub's `path`, Forgejo's `workflow_id`. GitLab has none. */
|
|
124
|
+
workflow?: string;
|
|
125
|
+
/** GitHub's workflow path without its `@ref`, such as `.github/workflows/pipeline.yml`. */
|
|
126
|
+
path?: string;
|
|
127
|
+
/** The commit it ran on. */
|
|
128
|
+
headSha: string;
|
|
129
|
+
/** The branch it ran on (GitLab's `ref`, which for a merge request pipeline is `refs/merge-requests/<iid>/head`). */
|
|
130
|
+
headBranch?: string;
|
|
131
|
+
/** The repository its head is in, as `owner/name` (GitHub's `head_repository`), when the forge names it. */
|
|
132
|
+
headRepo?: string;
|
|
133
|
+
/** The forge's word for where it is: GitHub's `queued`, `in_progress`, `completed`; Forgejo's and GitLab's `running`, `success`, `failure` or `failed`, ... */
|
|
134
|
+
status: string;
|
|
135
|
+
/** GitHub's conclusion once completed. */
|
|
136
|
+
conclusion?: string;
|
|
137
|
+
/** It finished, whatever its outcome. */
|
|
138
|
+
done: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* The pull requests the run names: GitHub's `pull_requests`, the
|
|
141
|
+
* `pull_request` of Forgejo's `event_payload`, GitLab's merge request when
|
|
142
|
+
* the pipeline is one's. `base` is the base branch the event named.
|
|
143
|
+
*/
|
|
144
|
+
pullRequests: { number: number; head?: string; headSha?: string; base?: string }[];
|
|
145
|
+
url?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** One of a run's jobs. */
|
|
149
|
+
export interface RunJob {
|
|
150
|
+
id: number;
|
|
151
|
+
name: string;
|
|
152
|
+
status: string;
|
|
153
|
+
conclusion?: string;
|
|
154
|
+
done: boolean;
|
|
155
|
+
/** The run (pipeline) it belongs to, when the forge names it (#4862). */
|
|
156
|
+
run?: number;
|
|
157
|
+
/** The branch or ref it ran on: GitHub's and Forgejo's `head_branch`, GitLab's `ref`. */
|
|
158
|
+
ref?: string;
|
|
159
|
+
/** GitLab only: true when it ran for a tag. */
|
|
160
|
+
tag?: boolean;
|
|
161
|
+
/** The job's page on the forge. */
|
|
162
|
+
url?: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** A file a comparison changes, with the path it had before a rename when the forge names it (#4862). */
|
|
166
|
+
export interface ChangedFile {
|
|
167
|
+
path: string;
|
|
168
|
+
previousPath?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** What {@link ForgeReads.compare} reads. */
|
|
172
|
+
export interface Comparison {
|
|
173
|
+
files: ChangedFile[];
|
|
174
|
+
/**
|
|
175
|
+
* True when the forge may have left files out: GitHub lists at most 300,
|
|
176
|
+
* Forgejo listed fewer commits than it counts or a commit without its
|
|
177
|
+
* files, GitLab's compare timed out.
|
|
178
|
+
*/
|
|
179
|
+
truncated: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* An artifact a run kept, not expired. On GitLab, a job's artifacts archive:
|
|
184
|
+
* `id` is the job's id and `name` its name.
|
|
185
|
+
*/
|
|
186
|
+
export interface RunArtifact {
|
|
187
|
+
id: number;
|
|
188
|
+
name: string;
|
|
189
|
+
/** The run that kept it, when the forge names it. */
|
|
190
|
+
run?: number;
|
|
191
|
+
/** The commit that run ran on, when the forge names it. */
|
|
192
|
+
headSha?: string;
|
|
193
|
+
size?: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** What {@link ForgeReads.headRuns} reads. */
|
|
197
|
+
export interface HeadRunsOptions {
|
|
198
|
+
/** Only runs of this event (GitHub's and Forgejo's `event`, GitLab's `source`). */
|
|
199
|
+
event?: string;
|
|
200
|
+
/** At most this many runs. Default 100. */
|
|
201
|
+
limit?: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** What {@link ForgeReads.branchRuns} reads. */
|
|
205
|
+
export interface BranchRunsOptions {
|
|
206
|
+
/** Only runs of this event (GitHub's and Forgejo's `event`, GitLab's `source`). */
|
|
207
|
+
event?: string;
|
|
208
|
+
/** At most this many runs. Default 100. */
|
|
209
|
+
limit?: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** What {@link ForgeReads.pullRequestsUpdated} reads. */
|
|
213
|
+
export interface PullRequestsUpdatedOptions {
|
|
214
|
+
/** At most this many pull requests. Default 500. */
|
|
215
|
+
limit?: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** What {@link ForgeReads.artifacts} reads. */
|
|
219
|
+
export interface ArtifactsOptions {
|
|
220
|
+
/** Only the artifacts this run (pipeline) kept. Without it, the repository's. */
|
|
221
|
+
run?: number;
|
|
222
|
+
/** At most this many artifacts. Default 100. */
|
|
223
|
+
limit?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
104
226
|
/** The reads, for GitHub, Forgejo and GitLab alike. */
|
|
105
227
|
export interface ForgeReads {
|
|
106
228
|
kind: ForgeKind;
|
|
@@ -129,12 +251,46 @@ export interface ForgeReads {
|
|
|
129
251
|
permission(login: string): Promise<string | undefined>;
|
|
130
252
|
/** Every open pull request in the repository, into any base, ascending by number. */
|
|
131
253
|
openPullRequests(): Promise<OpenPullRequest[]>;
|
|
254
|
+
/** The workflow runs (GitLab's pipelines) on commit `sha`, newest first (#4846). */
|
|
255
|
+
headRuns(sha: string, opts?: HeadRunsOptions): Promise<WorkflowRun[]>;
|
|
256
|
+
/** The workflow runs (GitLab's pipelines) on branch `branch`, newest first (#4785). */
|
|
257
|
+
branchRuns(branch: string, opts?: BranchRunsOptions): Promise<WorkflowRun[]>;
|
|
258
|
+
/**
|
|
259
|
+
* The pull requests in any state updated at or after `since` (ISO 8601),
|
|
260
|
+
* forks' among them, newest update first (#4785): what a poll of comment
|
|
261
|
+
* commands reads.
|
|
262
|
+
*/
|
|
263
|
+
pullRequestsUpdated(since: string, opts?: PullRequestsUpdatedOptions): Promise<PullRequestDetail[]>;
|
|
264
|
+
/** A workflow run (pipeline), or undefined when the forge has none by that id. */
|
|
265
|
+
run(id: number): Promise<WorkflowRun | undefined>;
|
|
266
|
+
/** A run's jobs, in the order the forge lists them. */
|
|
267
|
+
runJobs(run: number): Promise<RunJob[]>;
|
|
268
|
+
/** The artifacts named `name` that are not expired, in a run or across the repository, newest first. */
|
|
269
|
+
artifacts(name: string, opts?: ArtifactsOptions): Promise<RunArtifact[]>;
|
|
270
|
+
/**
|
|
271
|
+
* The files `head` changes since its merge base with `base` (#4862):
|
|
272
|
+
* GitHub's and Forgejo's `compare/<base>...<head>`, GitLab's
|
|
273
|
+
* `repository/compare` with `straight=false`. Forgejo names each commit's
|
|
274
|
+
* files, without a rename's old path, so a file a later commit changes
|
|
275
|
+
* back is still listed.
|
|
276
|
+
*/
|
|
277
|
+
compare(base: string, head: string): Promise<Comparison>;
|
|
278
|
+
/** A job by id, or undefined when the forge has none by that id (#4862). */
|
|
279
|
+
job(id: number): Promise<RunJob | undefined>;
|
|
280
|
+
/**
|
|
281
|
+
* GitLab only: one file of a job's artifacts, as text, or undefined when
|
|
282
|
+
* the job kept no such file (#4862). GitHub and Forgejo hand an artifact
|
|
283
|
+
* out as one archive.
|
|
284
|
+
*/
|
|
285
|
+
artifactFile?(job: number, path: string): Promise<string | undefined>;
|
|
132
286
|
}
|
|
133
287
|
|
|
134
288
|
interface Get {
|
|
135
289
|
(path: string): Promise<unknown>;
|
|
136
290
|
/** Pages of a list until one comes back short, at most `max` items. */
|
|
137
291
|
list(path: string, max?: number): Promise<unknown[]>;
|
|
292
|
+
/** The body as text, or undefined on a 404. */
|
|
293
|
+
text(path: string): Promise<string | undefined>;
|
|
138
294
|
}
|
|
139
295
|
|
|
140
296
|
function getter(base: string, headers: Record<string, string>, fetchImpl: ForgeFetch, pageSize: number, pageParams: (page: number) => string): Get {
|
|
@@ -156,6 +312,14 @@ function getter(base: string, headers: Record<string, string>, fetchImpl: ForgeF
|
|
|
156
312
|
}
|
|
157
313
|
return out.slice(0, max);
|
|
158
314
|
};
|
|
315
|
+
get.text = async (path) => {
|
|
316
|
+
const url = `${root}${path}`;
|
|
317
|
+
const res = await fetchImpl(url, { method: "GET", headers });
|
|
318
|
+
const text = await res.text();
|
|
319
|
+
if (res.status === 404) return undefined;
|
|
320
|
+
if (!res.ok) throw new ForgeApiError("GET", url, res.status, text);
|
|
321
|
+
return text;
|
|
322
|
+
};
|
|
159
323
|
return get;
|
|
160
324
|
}
|
|
161
325
|
|
|
@@ -185,6 +349,22 @@ const orUndefined = async <T>(read: Promise<T>): Promise<T | undefined> => {
|
|
|
185
349
|
}
|
|
186
350
|
};
|
|
187
351
|
const DEFAULT_LIMIT = 500;
|
|
352
|
+
const RUN_LIMIT = 100;
|
|
353
|
+
const byIdDesc = (a: { id: number }, b: { id: number }): number => b.id - a.id;
|
|
354
|
+
/** Forgejo's and GitLab's words for a run or job that is over. GitHub says `completed`. */
|
|
355
|
+
const OVER = new Set(["completed", "success", "failure", "failed", "cancelled", "canceled", "skipped"]);
|
|
356
|
+
|
|
357
|
+
/** Pages of a list the forge wraps in an object (`{ total_count, workflow_runs }`), or answers bare, until a page comes back short. */
|
|
358
|
+
async function listIn(get: Get, path: string, field: string, pageSize: number, pageParams: (page: number) => string, max: number): Promise<Record<string, unknown>[]> {
|
|
359
|
+
const out: Record<string, unknown>[] = [];
|
|
360
|
+
for (let page = 1; page <= 50 && out.length < max; page++) {
|
|
361
|
+
const got = await get(`${path}${path.includes("?") ? "&" : "?"}${pageParams(page)}`);
|
|
362
|
+
const items = (Array.isArray(got) ? got : isObject(got) && Array.isArray(got[field]) ? got[field] : []).filter(isObject);
|
|
363
|
+
out.push(...items);
|
|
364
|
+
if (items.length < pageSize) break;
|
|
365
|
+
}
|
|
366
|
+
return out.slice(0, max);
|
|
367
|
+
}
|
|
188
368
|
|
|
189
369
|
function githubShapedReads(kind: "github" | "forgejo", opts: GithubForgeOptions): ForgeReads {
|
|
190
370
|
const headers =
|
|
@@ -218,6 +398,57 @@ function githubShapedReads(kind: "github" | "forgejo", opts: GithubForgeOptions)
|
|
|
218
398
|
for (const [k, val] of Object.entries(fields)) if (val !== undefined) (out as unknown as Record<string, unknown>)[k] = val;
|
|
219
399
|
return out;
|
|
220
400
|
};
|
|
401
|
+
const pageParams = (page: number): string => (kind === "github" ? `per_page=100&page=${page}` : `limit=50&page=${page}`);
|
|
402
|
+
const runOf = (v: unknown): WorkflowRun | undefined => {
|
|
403
|
+
if (!isObject(v)) return undefined;
|
|
404
|
+
const id = num(v.id);
|
|
405
|
+
const headSha = str(v.head_sha) ?? str(v.commit_sha);
|
|
406
|
+
if (id === undefined || !headSha) return undefined;
|
|
407
|
+
const listed = str(v.event) ?? "";
|
|
408
|
+
const event = str(v.trigger_event) ?? listed;
|
|
409
|
+
const path = str(v.path)?.replace(/@.*$/, "");
|
|
410
|
+
const workflow = str(v.workflow_id) ?? path?.split("/").pop();
|
|
411
|
+
const status = str(v.status) ?? "";
|
|
412
|
+
const conclusion = str(v.conclusion);
|
|
413
|
+
const headRepo = isObject(v.head_repository) ? str(v.head_repository.full_name) : undefined;
|
|
414
|
+
const pullRequests: WorkflowRun["pullRequests"] = [];
|
|
415
|
+
for (const p of Array.isArray(v.pull_requests) ? v.pull_requests.filter(isObject) : []) {
|
|
416
|
+
const number = num(p.number);
|
|
417
|
+
if (number === undefined) continue;
|
|
418
|
+
const head = isObject(p.head) ? p.head : {};
|
|
419
|
+
const fields = { head: str(head.ref), headSha: str(head.sha), base: isObject(p.base) ? str(p.base.ref) : undefined };
|
|
420
|
+
pullRequests.push({ number, ...Object.fromEntries(Object.entries(fields).filter(([, x]) => x !== undefined)) });
|
|
421
|
+
}
|
|
422
|
+
// Forgejo names the event's pull request only in the payload it keeps as a string.
|
|
423
|
+
let payload: unknown = v.event_payload;
|
|
424
|
+
if (typeof payload === "string") {
|
|
425
|
+
try {
|
|
426
|
+
payload = JSON.parse(payload);
|
|
427
|
+
} catch {
|
|
428
|
+
payload = undefined;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const pull = isObject(payload) && isObject(payload.pull_request) ? payload.pull_request : undefined;
|
|
432
|
+
const number = pull ? num(pull.number) : undefined;
|
|
433
|
+
if (pull && number !== undefined && !pullRequests.some((p) => p.number === number)) {
|
|
434
|
+
const head = isObject(pull.head) ? pull.head : {};
|
|
435
|
+
const fields = { head: str(head.ref), headSha: str(head.sha), base: isObject(pull.base) ? str(pull.base.ref) : undefined };
|
|
436
|
+
pullRequests.push({ number, ...Object.fromEntries(Object.entries(fields).filter(([, x]) => x !== undefined)) });
|
|
437
|
+
}
|
|
438
|
+
const fields = { listedEvent: listed !== event ? listed : undefined, workflow, path, headBranch: str(v.head_branch), headRepo, conclusion, url: str(v.html_url) };
|
|
439
|
+
const out: WorkflowRun = { id, event, headSha, status, done: OVER.has(status), pullRequests };
|
|
440
|
+
for (const [k, val] of Object.entries(fields)) if (val !== undefined) (out as unknown as Record<string, unknown>)[k] = val;
|
|
441
|
+
return out;
|
|
442
|
+
};
|
|
443
|
+
const artifactOf = (v: Record<string, unknown>, name: string): RunArtifact | undefined => {
|
|
444
|
+
const id = num(v.id);
|
|
445
|
+
if (id === undefined || str(v.name) !== name || v.expired === true) return undefined;
|
|
446
|
+
const wr = isObject(v.workflow_run) ? v.workflow_run : {};
|
|
447
|
+
const run = num(wr.id) ?? num(v.run_id) ?? num(v.workflow_run_id);
|
|
448
|
+
const headSha = str(wr.head_sha);
|
|
449
|
+
const size = num(v.size_in_bytes) ?? num(v.size);
|
|
450
|
+
return { id, name, ...(run !== undefined ? { run } : {}), ...(headSha ? { headSha } : {}), ...(size !== undefined ? { size } : {}) };
|
|
451
|
+
};
|
|
221
452
|
/** Forgejo answers a pull request list with 404 while the repository is still empty; a missing repository 404s on its own read too. */
|
|
222
453
|
const pulls = async (query: string, max?: number): Promise<unknown[]> => {
|
|
223
454
|
try {
|
|
@@ -315,6 +546,112 @@ function githubShapedReads(kind: "github" | "forgejo", opts: GithubForgeOptions)
|
|
|
315
546
|
}
|
|
316
547
|
return out.sort((a, b) => a.number - b.number);
|
|
317
548
|
},
|
|
549
|
+
async headRuns(sha, o = {}) {
|
|
550
|
+
const query = `head_sha=${encodeURIComponent(sha)}${o.event ? `&event=${encodeURIComponent(o.event)}` : ""}`;
|
|
551
|
+
const listed = (await listIn(get, `${repo}/actions/runs?${query}`, "workflow_runs", pageSize, pageParams, o.limit ?? RUN_LIMIT)).map(runOf).filter(defined);
|
|
552
|
+
// Forgejo filters by the listed event, so a pull_request_target run comes back for `pull_request`: both words count.
|
|
553
|
+
return listed.filter((r) => r.headSha === sha && (!o.event || r.event === o.event || r.listedEvent === o.event)).sort(byIdDesc);
|
|
554
|
+
},
|
|
555
|
+
async branchRuns(branch, o = {}) {
|
|
556
|
+
const query = `branch=${encodeURIComponent(branch)}${o.event ? `&event=${encodeURIComponent(o.event)}` : ""}`;
|
|
557
|
+
const listed = (await listIn(get, `${repo}/actions/runs?${query}`, "workflow_runs", pageSize, pageParams, o.limit ?? RUN_LIMIT)).map(runOf).filter(defined);
|
|
558
|
+
return listed.filter((r) => r.headBranch === undefined || r.headBranch === branch).filter((r) => !o.event || r.event === o.event || r.listedEvent === o.event).sort(byIdDesc);
|
|
559
|
+
},
|
|
560
|
+
async pullRequestsUpdated(since, o = {}) {
|
|
561
|
+
const limit = o.limit ?? DEFAULT_LIMIT;
|
|
562
|
+
const from = Date.parse(since);
|
|
563
|
+
const out: PullRequestDetail[] = [];
|
|
564
|
+
// Newest update first, so the first page item older than `since` ends the read.
|
|
565
|
+
const query = kind === "github" ? "state=all&sort=updated&direction=desc" : "state=all&sort=recentupdate";
|
|
566
|
+
for (let page = 1; page <= 50 && out.length < limit; page++) {
|
|
567
|
+
let items: unknown;
|
|
568
|
+
try {
|
|
569
|
+
items = await get(`${repo}/pulls?${query}&${pageParams(page)}`);
|
|
570
|
+
} catch (err) {
|
|
571
|
+
if (kind !== "forgejo" || !notFound(err)) throw err;
|
|
572
|
+
await get(repo);
|
|
573
|
+
return [];
|
|
574
|
+
}
|
|
575
|
+
const list = Array.isArray(items) ? items : [];
|
|
576
|
+
let older = false;
|
|
577
|
+
for (const v of list) {
|
|
578
|
+
const d = detail(v);
|
|
579
|
+
if (!d) continue;
|
|
580
|
+
if (d.updated !== undefined && Date.parse(d.updated) < from) {
|
|
581
|
+
older = true;
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
out.push(d);
|
|
585
|
+
}
|
|
586
|
+
if (older || list.length < pageSize) break;
|
|
587
|
+
}
|
|
588
|
+
return out.slice(0, limit);
|
|
589
|
+
},
|
|
590
|
+
run: async (id) => runOf(await orUndefined(get(`${repo}/actions/runs/${id}`))),
|
|
591
|
+
runJobs: async (run) => (await listIn(get, `${repo}/actions/runs/${run}/jobs`, "jobs", pageSize, pageParams, 1000)).map(jobOf).filter(defined),
|
|
592
|
+
async artifacts(name, o = {}) {
|
|
593
|
+
const where = o.run !== undefined ? `${repo}/actions/runs/${o.run}/artifacts` : `${repo}/actions/artifacts`;
|
|
594
|
+
const listed = await listIn(get, `${where}?name=${encodeURIComponent(name)}`, "artifacts", pageSize, pageParams, o.limit ?? RUN_LIMIT);
|
|
595
|
+
return listed.map((a) => artifactOf(a, name)).filter(defined).map((a) => (o.run !== undefined && a.run === undefined ? { ...a, run: o.run } : a)).sort(byIdDesc);
|
|
596
|
+
},
|
|
597
|
+
async compare(base, head) {
|
|
598
|
+
const got = await get(`${repo}/compare/${encodeURIComponent(base)}...${encodeURIComponent(head)}`);
|
|
599
|
+
const c = isObject(got) ? got : {};
|
|
600
|
+
if (kind === "github") {
|
|
601
|
+
const listed = Array.isArray(c.files) ? c.files.filter(isObject) : [];
|
|
602
|
+
const files = listed.map((f) => changed(f.filename, f.previous_filename)).filter(defined);
|
|
603
|
+
return { files, truncated: listed.length >= GITHUB_COMPARE_FILES };
|
|
604
|
+
}
|
|
605
|
+
// Forgejo names the files of each commit between the merge base and the head.
|
|
606
|
+
const commits = Array.isArray(c.commits) ? c.commits.filter(isObject) : [];
|
|
607
|
+
const seen = new Set<string>();
|
|
608
|
+
const files: ChangedFile[] = [];
|
|
609
|
+
for (const commit of commits) {
|
|
610
|
+
for (const f of Array.isArray(commit.files) ? commit.files.filter(isObject) : []) {
|
|
611
|
+
const file = changed(f.filename);
|
|
612
|
+
if (file && !seen.has(file.path)) {
|
|
613
|
+
seen.add(file.path);
|
|
614
|
+
files.push(file);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
const total = num(c.total_commits);
|
|
619
|
+
return { files, truncated: (total !== undefined && commits.length < total) || commits.some((commit) => !Array.isArray(commit.files)) };
|
|
620
|
+
},
|
|
621
|
+
job: async (id) => jobOf(await orUndefined(get(`${repo}/actions/jobs/${id}`))),
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** GitHub lists at most this many files of a comparison. */
|
|
626
|
+
const GITHUB_COMPARE_FILES = 300;
|
|
627
|
+
|
|
628
|
+
const changed = (path: unknown, previous?: unknown): ChangedFile | undefined => {
|
|
629
|
+
const p = str(path);
|
|
630
|
+
const was = str(previous);
|
|
631
|
+
return p ? { path: p, ...(was && was !== p ? { previousPath: was } : {}) } : undefined;
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
/** A job as GitHub, Forgejo or GitLab answers it. */
|
|
635
|
+
function jobOf(j: unknown): RunJob | undefined {
|
|
636
|
+
if (!isObject(j)) return undefined;
|
|
637
|
+
const id = num(j.id);
|
|
638
|
+
const name = str(j.name);
|
|
639
|
+
if (id === undefined || !name) return undefined;
|
|
640
|
+
const status = str(j.status) ?? "";
|
|
641
|
+
const conclusion = str(j.conclusion);
|
|
642
|
+
const run = num(j.run_id) ?? (isObject(j.pipeline) ? num(j.pipeline.id) : undefined);
|
|
643
|
+
const ref = str(j.head_branch) ?? str(j.ref);
|
|
644
|
+
const url = str(j.html_url) ?? str(j.web_url);
|
|
645
|
+
return {
|
|
646
|
+
id,
|
|
647
|
+
name,
|
|
648
|
+
status,
|
|
649
|
+
...(conclusion ? { conclusion } : {}),
|
|
650
|
+
done: OVER.has(status),
|
|
651
|
+
...(run !== undefined ? { run } : {}),
|
|
652
|
+
...(ref ? { ref } : {}),
|
|
653
|
+
...(typeof j.tag === "boolean" ? { tag: j.tag } : {}),
|
|
654
|
+
...(url ? { url } : {}),
|
|
318
655
|
};
|
|
319
656
|
}
|
|
320
657
|
|
|
@@ -336,6 +673,36 @@ export function gitlabReads(opts: GitlabForgeOptions): ForgeReads {
|
|
|
336
673
|
const get = getter(opts.apiBase, opts.token ? { [opts.tokenHeader ?? "PRIVATE-TOKEN"]: opts.token } : {}, opts.fetch ?? (globalThis.fetch as unknown as ForgeFetch), 100, (page) => `per_page=100&page=${page}`);
|
|
337
674
|
const project = `/projects/${encodeURIComponent(decodeURIComponent(opts.project))}`;
|
|
338
675
|
const mrs = `${project}/merge_requests`;
|
|
676
|
+
const gitlabPage = (page: number): string => `per_page=100&page=${page}`;
|
|
677
|
+
const MR_REF = /^refs\/merge-requests\/(\d+)\/(?:head|merge|train)$/;
|
|
678
|
+
const pipelineOf = (v: unknown): WorkflowRun | undefined => {
|
|
679
|
+
if (!isObject(v)) return undefined;
|
|
680
|
+
const id = num(v.id);
|
|
681
|
+
const headSha = str(v.sha);
|
|
682
|
+
if (id === undefined || !headSha) return undefined;
|
|
683
|
+
const status = str(v.status) ?? "";
|
|
684
|
+
const ref = str(v.ref);
|
|
685
|
+
const mr = ref ? MR_REF.exec(ref) : null;
|
|
686
|
+
const fields = { headBranch: ref, url: str(v.web_url) };
|
|
687
|
+
const out: WorkflowRun = { id, event: str(v.source) ?? "", headSha, status, done: OVER.has(status), pullRequests: mr ? [{ number: Number(mr[1]), headSha }] : [] };
|
|
688
|
+
for (const [k, val] of Object.entries(fields)) if (val !== undefined) (out as unknown as Record<string, unknown>)[k] = val;
|
|
689
|
+
return out;
|
|
690
|
+
};
|
|
691
|
+
/** A job's artifacts archive, when it kept one. */
|
|
692
|
+
const archiveOf = (j: Record<string, unknown>, name: string): RunArtifact | undefined => {
|
|
693
|
+
const id = num(j.id);
|
|
694
|
+
if (id === undefined || str(j.name) !== name) return undefined;
|
|
695
|
+
const files = Array.isArray(j.artifacts) ? j.artifacts.filter(isObject) : [];
|
|
696
|
+
const archive = files.find((f) => f.file_type === "archive") ?? (isObject(j.artifacts_file) ? j.artifacts_file : undefined);
|
|
697
|
+
if (!archive) return undefined;
|
|
698
|
+
const expires = str(j.artifacts_expire_at);
|
|
699
|
+
if (expires && Date.parse(expires) <= Date.now()) return undefined;
|
|
700
|
+
const pipeline = isObject(j.pipeline) ? j.pipeline : {};
|
|
701
|
+
const run = num(pipeline.id);
|
|
702
|
+
const headSha = str(pipeline.sha);
|
|
703
|
+
const size = num(archive.size);
|
|
704
|
+
return { id, name, ...(run !== undefined ? { run } : {}), ...(headSha ? { headSha } : {}), ...(size !== undefined ? { size } : {}) };
|
|
705
|
+
};
|
|
339
706
|
const own = (v: Record<string, unknown>): boolean => num(v.source_project_id) === undefined || num(v.source_project_id) === num(v.target_project_id);
|
|
340
707
|
const detail = (v: unknown): PullRequestDetail | undefined => {
|
|
341
708
|
if (!isObject(v)) return undefined;
|
|
@@ -410,6 +777,36 @@ export function gitlabReads(opts: GitlabForgeOptions): ForgeReads {
|
|
|
410
777
|
}
|
|
411
778
|
return out.sort((a, b) => a.number - b.number);
|
|
412
779
|
},
|
|
780
|
+
async headRuns(sha, o = {}) {
|
|
781
|
+
const query = `sha=${encodeURIComponent(sha)}${o.event ? `&source=${encodeURIComponent(o.event)}` : ""}&order_by=id&sort=desc`;
|
|
782
|
+
const listed = (await listIn(get, `${project}/pipelines?${query}`, "", 100, gitlabPage, o.limit ?? RUN_LIMIT)).map(pipelineOf).filter(defined);
|
|
783
|
+
return listed.filter((r) => r.headSha === sha && (!o.event || r.event === o.event)).sort(byIdDesc);
|
|
784
|
+
},
|
|
785
|
+
async branchRuns(branch, o = {}) {
|
|
786
|
+
const query = `ref=${encodeURIComponent(branch)}${o.event ? `&source=${encodeURIComponent(o.event)}` : ""}&order_by=id&sort=desc`;
|
|
787
|
+
const listed = (await listIn(get, `${project}/pipelines?${query}`, "", 100, gitlabPage, o.limit ?? RUN_LIMIT)).map(pipelineOf).filter(defined);
|
|
788
|
+
return listed.filter((r) => r.headBranch === branch && (!o.event || r.event === o.event)).sort(byIdDesc);
|
|
789
|
+
},
|
|
790
|
+
async pullRequestsUpdated(since, o = {}) {
|
|
791
|
+
const listed = await get.list(`${mrs}?state=all&updated_after=${encodeURIComponent(since)}&order_by=updated_at&sort=desc`, o.limit ?? DEFAULT_LIMIT);
|
|
792
|
+
return listed.map(detail).filter(defined);
|
|
793
|
+
},
|
|
794
|
+
run: async (id) => pipelineOf(await orUndefined(get(`${project}/pipelines/${id}`))),
|
|
795
|
+
runJobs: async (run) => (await get.list(`${project}/pipelines/${run}/jobs?include_retried=false`)).map(jobOf).filter(defined),
|
|
796
|
+
async artifacts(name, o = {}) {
|
|
797
|
+
const limit = o.limit ?? RUN_LIMIT;
|
|
798
|
+
// GitLab keeps artifacts per job: a pipeline's jobs of that name, or the project's newest jobs, that kept an archive.
|
|
799
|
+
const jobs = o.run !== undefined ? await get.list(`${project}/pipelines/${o.run}/jobs`) : await get.list(`${project}/jobs`, 10 * limit);
|
|
800
|
+
return jobs.filter(isObject).map((j) => archiveOf(j, name)).filter(defined).sort(byIdDesc).slice(0, limit);
|
|
801
|
+
},
|
|
802
|
+
async compare(base, head) {
|
|
803
|
+
const got = await get(`${project}/repository/compare?from=${encodeURIComponent(base)}&to=${encodeURIComponent(head)}&straight=false`);
|
|
804
|
+
const c = isObject(got) ? got : {};
|
|
805
|
+
const files = (Array.isArray(c.diffs) ? c.diffs.filter(isObject) : []).map((d) => changed(d.new_path ?? d.old_path, d.old_path)).filter(defined);
|
|
806
|
+
return { files, truncated: c.compare_timeout === true };
|
|
807
|
+
},
|
|
808
|
+
job: async (id) => jobOf(await orUndefined(get(`${project}/jobs/${id}`))),
|
|
809
|
+
artifactFile: (job, path) => get.text(`${project}/jobs/${job}/artifacts/${path.split("/").map(encodeURIComponent).join("/")}`),
|
|
413
810
|
};
|
|
414
811
|
}
|
|
415
812
|
|
package/src/release-floors.ts
CHANGED
|
@@ -19,13 +19,25 @@
|
|
|
19
19
|
* this constant to the next patch (#4501). The check fails while a floor
|
|
20
20
|
* still names this constant after its version shipped.
|
|
21
21
|
*/
|
|
22
|
-
export const NEXT_RELEASE = "0.124.
|
|
22
|
+
export const NEXT_RELEASE = "0.124.81";
|
|
23
|
+
|
|
24
|
+
/** The first chant whose terraform lexicon's `terraform-apply` reads take `dir` and `workspace`, and read an upstream with `resolveRoot`'s binary and `readEnv` (terragucci issue 1303). */
|
|
25
|
+
export const TERRAFORM_APPLY_INSTANCE_READS_FLOOR = "0.124.80";
|
|
26
|
+
|
|
27
|
+
/** The first chant whose terraform lexicon's `terraform-apply` takes `binary`, and `terraformApplyCapabilityWith({ resolveRoot })` gives each root its own binary (terragucci issue 1303). */
|
|
28
|
+
export const TERRAFORM_APPLY_ROOT_BINARY_FLOOR = "0.124.80";
|
|
29
|
+
|
|
30
|
+
/** The first chant whose op wave hands a step's capability the wave's `cwd` (`DeployContext.cwd`), where `terraform-apply` looks for `chant.config.*` and `terragrunt-apply` runs when the step names neither (#4854). */
|
|
31
|
+
export const OP_WAVE_STEP_CWD_FLOOR = "0.124.80";
|
|
32
|
+
|
|
33
|
+
/** The first chant whose terraform lexicon's `terraform-apply` takes `workspace`: init in `default`, then `workspace select -or-create=true`, and plan, apply and output in it (#4854). */
|
|
34
|
+
export const TERRAFORM_APPLY_WORKSPACE_FLOOR = "0.124.80";
|
|
23
35
|
|
|
24
36
|
/** The first chant whose change-set member can carry `outputs`, the outputs its plan changes, and counts a member with any as a change (#4849). */
|
|
25
|
-
export const CHANGE_SET_OUTPUTS_FLOOR =
|
|
37
|
+
export const CHANGE_SET_OUTPUTS_FLOOR = "0.124.79";
|
|
26
38
|
|
|
27
39
|
/** The first chant whose terraform lexicon's `terragruntApplyCapability` takes `resolveUnit` and plans a wave as one `run --all` per pair of pinned releases (#4849). */
|
|
28
|
-
export const TERRAGRUNT_UNIT_PINS_FLOOR =
|
|
40
|
+
export const TERRAGRUNT_UNIT_PINS_FLOOR = "0.124.79";
|
|
29
41
|
|
|
30
42
|
/** The first chant whose sql lexicon's `yodelCommitSpec("new", ...)` takes `envs`, so `--replace-own` reads those histories as the reader (#4815). */
|
|
31
43
|
export const YODEL_NEW_ENVS_FLOOR = "0.124.78";
|
|
@@ -33,6 +45,15 @@ export const YODEL_NEW_ENVS_FLOOR = "0.124.78";
|
|
|
33
45
|
/** The first chant whose sql lexicon's `yodelRefusalReply` reads yodel rebase's conflict refusal as yodel prints it, `<a> and the migrations after <p> up to <b>` or `<a> and the chain ending at <b>` (#4821). */
|
|
34
46
|
export const YODEL_CONFLICT_REPLY_FLOOR = "0.124.78";
|
|
35
47
|
|
|
48
|
+
/** The first chant with `@intentius/chant/ci-note-commands`, `chant components pr-notes` and the GitLab pipeline's `note-commands` job (`--note-commands`), and whose forge reads answer `branchRuns` and `pullRequestsUpdated` (#4785). */
|
|
49
|
+
export const NOTE_COMMANDS_FLOOR = "0.124.80";
|
|
50
|
+
|
|
51
|
+
/** The first chant whose forge reads answer `compare`, `job` and, on GitLab, `artifactFile`, and whose `RunJob` names its `run`, `ref`, `tag` and `url` (#4862). */
|
|
52
|
+
export const PR_FORGE_COMPARE_READS_FLOOR = "0.124.80";
|
|
53
|
+
|
|
54
|
+
/** The first chant whose forge reads answer `headRuns`, `run`, `runJobs` and `artifacts`: a head's workflow runs (GitLab's pipelines), a run, its jobs and its artifacts by name (#4846). */
|
|
55
|
+
export const PR_FORGE_RUN_READS_FLOOR = "0.124.80";
|
|
56
|
+
|
|
36
57
|
/** The first chant whose `@intentius/chant/pr-forge-reads` exports the forge reads beside the clients (#4809). */
|
|
37
58
|
export const PR_FORGE_READS_FLOOR = "0.124.78";
|
|
38
59
|
|