@shiplane/github 0.5.2 → 0.6.0-nightly.3
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 +2 -2
- package/dist/index.d.ts +10 -5
- package/dist/index.js +226 -54
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -71,8 +71,8 @@ Source: `src/github-code-host.adapter.ts`, `src/github-actions-ci-pipeline.adapt
|
|
|
71
71
|
|
|
72
72
|
## 🧪 Example
|
|
73
73
|
|
|
74
|
-
`pnpm shiplane
|
|
75
|
-
Actions dispatching `deploy.yml`:
|
|
74
|
+
`pnpm shiplane ship --dry-run` in [`examples/`](./examples/shiplane.config.ts) shows the ship
|
|
75
|
+
through GitHub Actions dispatching `deploy.yml`:
|
|
76
76
|
|
|
77
77
|
```text
|
|
78
78
|
Plan · preview · nothing runs
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CiPipelinePort, CodeHostPort, Feature, ServiceAdapter, SourceControlPort } from "shiplane/plugin";
|
|
1
|
+
import { CatalogEntry, CiPipelinePort, CodeHostPort, Feature, ServiceAdapter, SourceControlPort } from "shiplane/plugin";
|
|
2
2
|
|
|
3
3
|
//#region src/github-code-host.adapter.d.ts
|
|
4
4
|
type GitHubCodeHostAdapter = ServiceAdapter<CodeHostPort>;
|
|
@@ -11,9 +11,7 @@ type GitHubActionsCiPipelineAdapter = ServiceAdapter<CiPipelinePort>;
|
|
|
11
11
|
* Workflow runs, dispatches and the minutes budget on GitHub Actions, through the gh CLI. Shipping
|
|
12
12
|
* through it dispatches `shipWorkflow` (default `ship.yml`) with `units` and `environment`.
|
|
13
13
|
*/
|
|
14
|
-
declare const gitHubActionsCiPipeline: ({
|
|
15
|
-
shipWorkflow
|
|
16
|
-
}?: {
|
|
14
|
+
declare const gitHubActionsCiPipeline: (options?: {
|
|
17
15
|
shipWorkflow?: string;
|
|
18
16
|
}) => GitHubActionsCiPipelineAdapter;
|
|
19
17
|
//#endregion
|
|
@@ -33,5 +31,12 @@ declare const releaseComments: ({
|
|
|
33
31
|
apps
|
|
34
32
|
}: ReleaseCommentsOptions) => Feature;
|
|
35
33
|
//#endregion
|
|
36
|
-
|
|
34
|
+
//#region src/catalog.d.ts
|
|
35
|
+
/**
|
|
36
|
+
* What a shiplane.yml names from this plugin: `codeHost: github`, `ciPipeline: github-actions`,
|
|
37
|
+
* and the `release-comments` feature.
|
|
38
|
+
*/
|
|
39
|
+
declare const catalog: readonly CatalogEntry[];
|
|
40
|
+
//#endregion
|
|
41
|
+
export { type GitHubActionsCiPipelineAdapter, type GitHubCodeHostAdapter, type ReleaseCommentsOptions, catalog, gitHubActionsCiPipeline, gitHubCodeHost, releaseComments };
|
|
37
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { actionsMinutes, adapterEntry, billedMinutes, deployRunTitle, deployState, featureEntry, firstLine, isReleaseSubject, issueName, previousTag, retrying, serviceIn, z } from "shiplane/plugin";
|
|
2
|
+
import { z as z$1 } from "shiplane";
|
|
2
3
|
//#region src/gh-cli.ts
|
|
3
4
|
const RATE_LIMITED = /rate limit|HTTP 429/i;
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const RATE_LIMIT_WAITS_MS = [
|
|
6
|
+
2e3,
|
|
7
|
+
4e3,
|
|
8
|
+
8e3,
|
|
9
|
+
16e3
|
|
10
|
+
];
|
|
11
|
+
/** What every adapter driving gh needs: gh signed in. */
|
|
12
|
+
const GH_REQUIREMENT = {
|
|
13
|
+
label: "gh",
|
|
14
|
+
check: {
|
|
15
|
+
command: "gh",
|
|
16
|
+
args: ["auth", "status"]
|
|
17
|
+
},
|
|
18
|
+
fix: {
|
|
19
|
+
command: "gh",
|
|
20
|
+
args: ["auth", "login"]
|
|
21
|
+
},
|
|
22
|
+
secrets: ["GH_TOKEN"]
|
|
23
|
+
};
|
|
6
24
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
25
|
/**
|
|
8
26
|
* The gh CLI in the repository: `must` throws on a failed call, `json` parses its output. A call
|
|
9
27
|
* GitHub rate limits is retried, waiting twice as long each time.
|
|
10
28
|
*/
|
|
11
|
-
const ghCli = (root, shell, wait = sleep) => {
|
|
29
|
+
const ghCli = ({ root, shell, wait = sleep }) => {
|
|
12
30
|
const must = async (args, input) => {
|
|
13
|
-
|
|
14
|
-
|
|
31
|
+
const result = await retrying({
|
|
32
|
+
run: () => shell.capture("gh", args, {
|
|
15
33
|
cwd: root,
|
|
16
34
|
input
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
35
|
+
}),
|
|
36
|
+
retryable: ({ status, stderr }) => status !== 0 && RATE_LIMITED.test(stderr),
|
|
37
|
+
delays: RATE_LIMIT_WAITS_MS,
|
|
38
|
+
wait
|
|
39
|
+
});
|
|
40
|
+
if (result.status === 0) return result.stdout;
|
|
41
|
+
const reason = firstLine(result.stderr);
|
|
42
|
+
throw new Error(`gh ${args.slice(0, 2).join(" ")} exited with ${result.status}${reason ? `: ${reason}` : ""}`);
|
|
26
43
|
};
|
|
27
44
|
const json = async (args) => JSON.parse(await must(args));
|
|
28
45
|
return {
|
|
@@ -43,6 +60,10 @@ const PrSchema = z.object({
|
|
|
43
60
|
url: z.string(),
|
|
44
61
|
headRefOid: z.string()
|
|
45
62
|
});
|
|
63
|
+
const IssueCommentSchema = z.object({
|
|
64
|
+
id: z.number(),
|
|
65
|
+
body: z.string()
|
|
66
|
+
});
|
|
46
67
|
const toOpenPr = ({ number, url, headRefOid }) => ({
|
|
47
68
|
number,
|
|
48
69
|
url,
|
|
@@ -69,6 +90,7 @@ const RepoMergeSchema = z.object({ data: z.object({ repository: z.object({
|
|
|
69
90
|
])
|
|
70
91
|
}) }) });
|
|
71
92
|
const ReleaseListSchema = z.array(z.object({ tagName: z.string() }));
|
|
93
|
+
const RepoSchema = z.object({ url: z.string() });
|
|
72
94
|
const DeploymentsSchema = z.object({ data: z.object({ repository: z.object({ deployments: z.object({ nodes: z.array(z.object({
|
|
73
95
|
environment: z.string().nullish(),
|
|
74
96
|
state: z.string().nullish(),
|
|
@@ -105,7 +127,10 @@ const DEPLOYMENTS_QUERY = `query($owner: String!, $name: String!) {
|
|
|
105
127
|
}
|
|
106
128
|
}`;
|
|
107
129
|
const githubHost = (root, shell) => {
|
|
108
|
-
const { must, json } = ghCli(
|
|
130
|
+
const { must, json } = ghCli({
|
|
131
|
+
root,
|
|
132
|
+
shell
|
|
133
|
+
});
|
|
109
134
|
const graphql = (query, variables = []) => json([
|
|
110
135
|
"api",
|
|
111
136
|
"graphql",
|
|
@@ -226,7 +251,7 @@ const githubHost = (root, shell) => {
|
|
|
226
251
|
"--json",
|
|
227
252
|
"tagName"
|
|
228
253
|
])).map(({ tagName }) => tagName)),
|
|
229
|
-
createRelease: async (tag, notes, latest) => {
|
|
254
|
+
createRelease: async (tag, notes, latest, previous) => {
|
|
230
255
|
await must([
|
|
231
256
|
"release",
|
|
232
257
|
"create",
|
|
@@ -235,7 +260,12 @@ const githubHost = (root, shell) => {
|
|
|
235
260
|
"--title",
|
|
236
261
|
tag,
|
|
237
262
|
"--notes",
|
|
238
|
-
notes
|
|
263
|
+
`${notes}${previous ? `\n\n**Full Changelog**: ${RepoSchema.parse(await json([
|
|
264
|
+
"repo",
|
|
265
|
+
"view",
|
|
266
|
+
"--json",
|
|
267
|
+
"url"
|
|
268
|
+
])).url}/compare/${previous}...${tag}` : ""}`,
|
|
239
269
|
...latest ? [] : ["--latest=false"]
|
|
240
270
|
]);
|
|
241
271
|
},
|
|
@@ -306,6 +336,39 @@ const githubHost = (root, shell) => {
|
|
|
306
336
|
const { data } = IssueCommentsSchema.parse(await graphql(`query { ${fields.join(" ")} }`));
|
|
307
337
|
return Object.values(data).map(({ issueOrPullRequest }) => issueOrPullRequest?.comments.nodes.map(({ body }) => body) ?? []);
|
|
308
338
|
},
|
|
339
|
+
prForBranch: async (branch) => {
|
|
340
|
+
const [pr] = z.array(PrSchema).parse(await json([
|
|
341
|
+
"pr",
|
|
342
|
+
"list",
|
|
343
|
+
"--head",
|
|
344
|
+
branch,
|
|
345
|
+
"--state",
|
|
346
|
+
"open",
|
|
347
|
+
"--limit",
|
|
348
|
+
"1",
|
|
349
|
+
"--json",
|
|
350
|
+
"number,url,headRefOid"
|
|
351
|
+
]));
|
|
352
|
+
return pr ? toOpenPr(pr) : null;
|
|
353
|
+
},
|
|
354
|
+
upsertComment: async ({ on, marker, body }) => {
|
|
355
|
+
const found = (await must([
|
|
356
|
+
"api",
|
|
357
|
+
`repos/{owner}/{repo}/issues/${on.number}/comments`,
|
|
358
|
+
"--paginate",
|
|
359
|
+
"--jq",
|
|
360
|
+
".[] | {id, body}"
|
|
361
|
+
])).split("\n").filter(Boolean).map((line) => IssueCommentSchema.parse(JSON.parse(line))).find((comment) => comment.body.includes(marker));
|
|
362
|
+
const [method, endpoint] = found ? ["PATCH", `repos/{owner}/{repo}/issues/comments/${found.id}`] : ["POST", `repos/{owner}/{repo}/issues/${on.number}/comments`];
|
|
363
|
+
await must([
|
|
364
|
+
"api",
|
|
365
|
+
"-X",
|
|
366
|
+
method,
|
|
367
|
+
endpoint,
|
|
368
|
+
"-f",
|
|
369
|
+
`body=${body}`
|
|
370
|
+
]);
|
|
371
|
+
},
|
|
309
372
|
comment: async ({ repository, number }, body) => {
|
|
310
373
|
const wait = lastPost + POST_GAP_MS - Date.now();
|
|
311
374
|
if (wait > 0) await sleep(wait);
|
|
@@ -324,17 +387,7 @@ const githubHost = (root, shell) => {
|
|
|
324
387
|
/** Pull requests, comments, release notes and deploy records through the gh CLI. */
|
|
325
388
|
const gitHubCodeHost = () => ({
|
|
326
389
|
name: "github",
|
|
327
|
-
requirements: () => [
|
|
328
|
-
label: "gh",
|
|
329
|
-
check: {
|
|
330
|
-
command: "gh",
|
|
331
|
-
args: ["auth", "status"]
|
|
332
|
-
},
|
|
333
|
-
fix: {
|
|
334
|
-
command: "gh",
|
|
335
|
-
args: ["auth", "login"]
|
|
336
|
-
}
|
|
337
|
-
}],
|
|
390
|
+
requirements: () => [GH_REQUIREMENT],
|
|
338
391
|
create: ({ root, shell }) => githubHost(root, shell)
|
|
339
392
|
});
|
|
340
393
|
//#endregion
|
|
@@ -353,9 +406,68 @@ const JobsSchema = z.array(z.object({
|
|
|
353
406
|
startedAt: z.string().nullable(),
|
|
354
407
|
completedAt: z.string().nullable()
|
|
355
408
|
}));
|
|
409
|
+
const RefSchema = z.object({ object: z.object({
|
|
410
|
+
sha: z.string(),
|
|
411
|
+
type: z.string()
|
|
412
|
+
}) });
|
|
413
|
+
const CommitSchema = z.object({ sha: z.string() });
|
|
414
|
+
/** A test version, `<version>-<branch>.<short sha>`, ends on the commit it was built from. */
|
|
415
|
+
const TEST_VERSION = /^\d+\.\d+\.\d+-[0-9a-z-]+\.g?([0-9a-f]{7,40})$/;
|
|
416
|
+
const isMissing = (error) => error instanceof Error && /HTTP 404|HTTP 422|Not Found|No commit found/.test(error.message);
|
|
417
|
+
/** Where shiplane's own workflow and its release tags live. */
|
|
418
|
+
const SHIPLANE_REPO = "arnaud-zg/js-packages";
|
|
419
|
+
/** What shiplane's workflow may do: comment on PRs and issues only with release comments. */
|
|
420
|
+
const permissionsOf = ({ features }) => [
|
|
421
|
+
"permissions:",
|
|
422
|
+
" contents: read",
|
|
423
|
+
" deployments: write",
|
|
424
|
+
" actions: read",
|
|
425
|
+
...features.includes("release-comments") ? [" issues: write", " pull-requests: write"] : []
|
|
426
|
+
];
|
|
427
|
+
/** Each secret its adapters read, passed by name: GitHub hands a called workflow no other. */
|
|
428
|
+
const secretsOf = ({ secrets }) => secrets.length === 0 ? [] : [" secrets:", ...secrets.map((name) => ` ${name}: \${{ secrets.${name} }}`)];
|
|
429
|
+
/** The workflow a repository ships from: a manual run calling shiplane's, pinned to a commit. */
|
|
430
|
+
const callerContent = (sha, version, needs) => [
|
|
431
|
+
"# Ships with shiplane: `pnpm shiplane ship --via ci`, or Run workflow here.",
|
|
432
|
+
"# Written by `shiplane setup`; `shiplane doctor` keeps the pin current.",
|
|
433
|
+
"name: Ship",
|
|
434
|
+
"run-name: Ship ${{ inputs.units || 'every released unit' }} to ${{ inputs.environment }}",
|
|
435
|
+
"",
|
|
436
|
+
"on:",
|
|
437
|
+
" workflow_dispatch:",
|
|
438
|
+
" inputs:",
|
|
439
|
+
" units:",
|
|
440
|
+
" description: \"Units to ship, space separated (empty: every unit the environment lacks)\"",
|
|
441
|
+
" type: string",
|
|
442
|
+
" default: \"\"",
|
|
443
|
+
" environment:",
|
|
444
|
+
" description: \"Where to ship the ref this runs on\"",
|
|
445
|
+
" type: choice",
|
|
446
|
+
" options: [preview, production]",
|
|
447
|
+
" default: preview",
|
|
448
|
+
"",
|
|
449
|
+
...permissionsOf(needs),
|
|
450
|
+
"",
|
|
451
|
+
"jobs:",
|
|
452
|
+
" ship:",
|
|
453
|
+
` uses: ${SHIPLANE_REPO}/.github/workflows/shiplane-ship.yml@${sha} # shiplane@${version}`,
|
|
454
|
+
" with:",
|
|
455
|
+
" units: ${{ inputs.units }}",
|
|
456
|
+
" environment: ${{ inputs.environment }}",
|
|
457
|
+
...secretsOf(needs),
|
|
458
|
+
""
|
|
459
|
+
].join("\n");
|
|
460
|
+
/** A workflow run as a deploy record: still going, succeeded, or anything else. */
|
|
461
|
+
const runState = ({ status, conclusion }) => {
|
|
462
|
+
if (status !== "completed") return "running";
|
|
463
|
+
return conclusion === "success" ? "done" : "none";
|
|
464
|
+
};
|
|
356
465
|
/** Workflow runs, dispatches and the Actions minutes budget through the gh CLI. */
|
|
357
466
|
const githubActions = (root, shell, shipWorkflow) => {
|
|
358
|
-
const { must, json } = ghCli(
|
|
467
|
+
const { must, json } = ghCli({
|
|
468
|
+
root,
|
|
469
|
+
shell
|
|
470
|
+
});
|
|
359
471
|
const runs = async (workflow) => {
|
|
360
472
|
const listed = await json([
|
|
361
473
|
"run",
|
|
@@ -367,14 +479,44 @@ const githubActions = (root, shell, shipWorkflow) => {
|
|
|
367
479
|
"--json",
|
|
368
480
|
"displayTitle,status,conclusion"
|
|
369
481
|
]).catch(() => []);
|
|
370
|
-
return RunsSchema.parse(listed).map((
|
|
371
|
-
title: displayTitle,
|
|
372
|
-
state:
|
|
482
|
+
return RunsSchema.parse(listed).map((run) => ({
|
|
483
|
+
title: run.displayTitle,
|
|
484
|
+
state: runState(run)
|
|
373
485
|
}));
|
|
374
486
|
};
|
|
375
487
|
return {
|
|
376
488
|
shipWorkflow,
|
|
489
|
+
label: "GitHub Actions",
|
|
490
|
+
workflowFile: (workflow) => `.github/workflows/${workflow}`,
|
|
491
|
+
dispatchLine: (workflow, ref, inputs) => [`gh workflow run ${workflow} --ref ${ref}`, ...Object.entries(inputs).map(([key, value]) => `-f ${key}=${value}`)].join(" "),
|
|
377
492
|
workflowRuns: runs,
|
|
493
|
+
callerWorkflow: async (version, needs) => {
|
|
494
|
+
const tag = `shiplane@${version}`;
|
|
495
|
+
const orMissing = (error) => {
|
|
496
|
+
if (isMissing(error)) return null;
|
|
497
|
+
throw error;
|
|
498
|
+
};
|
|
499
|
+
const short = TEST_VERSION.exec(version)?.[1];
|
|
500
|
+
if (short) {
|
|
501
|
+
const commit = await json(["api", `repos/${SHIPLANE_REPO}/commits/${short}`]).catch(orMissing);
|
|
502
|
+
if (commit === null) return { error: `no commit ${short} for ${tag}: pin shiplane-ship.yml by hand` };
|
|
503
|
+
const { sha } = CommitSchema.parse(commit);
|
|
504
|
+
return {
|
|
505
|
+
file: `.github/workflows/${shipWorkflow}`,
|
|
506
|
+
content: callerContent(sha, version, needs),
|
|
507
|
+
pin: sha
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const ref = await json(["api", `repos/${SHIPLANE_REPO}/git/ref/tags/${tag}`]).catch(orMissing);
|
|
511
|
+
if (ref === null) return { error: `no release tag ${tag}: pin shiplane-ship.yml by hand` };
|
|
512
|
+
const { object } = RefSchema.parse(ref);
|
|
513
|
+
const sha = object.type === "tag" ? RefSchema.parse(await json(["api", `repos/${SHIPLANE_REPO}/git/tags/${object.sha}`])).object.sha : object.sha;
|
|
514
|
+
return {
|
|
515
|
+
file: `.github/workflows/${shipWorkflow}`,
|
|
516
|
+
content: callerContent(sha, version, needs),
|
|
517
|
+
pin: sha
|
|
518
|
+
};
|
|
519
|
+
},
|
|
378
520
|
dispatch: async (workflow, ref, inputs) => {
|
|
379
521
|
await must([
|
|
380
522
|
"workflow",
|
|
@@ -428,29 +570,14 @@ const githubActions = (root, shell, shipWorkflow) => {
|
|
|
428
570
|
* Workflow runs, dispatches and the minutes budget on GitHub Actions, through the gh CLI. Shipping
|
|
429
571
|
* through it dispatches `shipWorkflow` (default `ship.yml`) with `units` and `environment`.
|
|
430
572
|
*/
|
|
431
|
-
const gitHubActionsCiPipeline = (
|
|
573
|
+
const gitHubActionsCiPipeline = (options = {}) => ({
|
|
432
574
|
name: "github-actions",
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
command: "gh",
|
|
437
|
-
args: ["auth", "status"]
|
|
438
|
-
},
|
|
439
|
-
fix: {
|
|
440
|
-
command: "gh",
|
|
441
|
-
args: ["auth", "login"]
|
|
442
|
-
}
|
|
443
|
-
}],
|
|
444
|
-
create: ({ root, shell }) => githubActions(root, shell, shipWorkflow)
|
|
575
|
+
options,
|
|
576
|
+
requirements: () => [GH_REQUIREMENT],
|
|
577
|
+
create: ({ root, shell }) => githubActions(root, shell, options.shipWorkflow ?? "ship.yml")
|
|
445
578
|
});
|
|
446
579
|
//#endregion
|
|
447
580
|
//#region src/issues.ts
|
|
448
|
-
/** The tag a unit had before this version, by version order. Null for its first release. */
|
|
449
|
-
const previousTag = (tags, unit, version, format = DEFAULT_TAG_FORMAT) => {
|
|
450
|
-
const [before = "", after = ""] = tagName(unit, "\0", format).split("\0");
|
|
451
|
-
const [newest] = [...tags].filter((tag) => tag.startsWith(before) && tag.endsWith(after)).map((tag) => tag.slice(before.length, tag.length - after.length)).filter((candidate) => /^\d/.test(candidate) && compareVersions(candidate, version) < 0).sort((left, right) => compareVersions(right, left));
|
|
452
|
-
return newest === void 0 ? null : tagName(unit, newest, format);
|
|
453
|
-
};
|
|
454
581
|
/** The pull requests squash-merged as these subjects (`... (#1912)`), release PRs aside. */
|
|
455
582
|
const pullRequestNumbers = (subjects) => [...new Set(subjects.flatMap((subject) => {
|
|
456
583
|
const found = /\(#(\d+)\)\s*$/.exec(subject)?.[1];
|
|
@@ -536,7 +663,12 @@ const uniqueRefs = (refs) => {
|
|
|
536
663
|
const followUpsOf = async (codeHost, context, tags, picked) => {
|
|
537
664
|
const reached = await Promise.all(picked.map(async (shipped) => {
|
|
538
665
|
const { unit, tag } = shipped;
|
|
539
|
-
const from = previousTag(
|
|
666
|
+
const from = previousTag({
|
|
667
|
+
tags,
|
|
668
|
+
unit: unit.name,
|
|
669
|
+
version: unit.version,
|
|
670
|
+
format: context.tagFormat
|
|
671
|
+
});
|
|
540
672
|
return {
|
|
541
673
|
shipped,
|
|
542
674
|
numbers: (from ? pullRequestNumbers(await context.subjectsReaching(unit, from, tag)) : []).sort((left, right) => left - right)
|
|
@@ -577,6 +709,7 @@ const releaseComments = ({ codeHost, sourceControl, apps }) => ({
|
|
|
577
709
|
type: "feature",
|
|
578
710
|
name: "release-comments",
|
|
579
711
|
adapters: [codeHost, sourceControl],
|
|
712
|
+
options: apps ? { apps } : {},
|
|
580
713
|
requirements: () => [...codeHost.requirements?.() ?? [], ...sourceControl.requirements?.() ?? []],
|
|
581
714
|
afterShip: async (context, shipped) => {
|
|
582
715
|
const picked = shipped.filter(({ unit }) => !apps || apps.includes(unit.name));
|
|
@@ -585,6 +718,45 @@ const releaseComments = ({ codeHost, sourceControl, apps }) => ({
|
|
|
585
718
|
}
|
|
586
719
|
});
|
|
587
720
|
//#endregion
|
|
588
|
-
|
|
721
|
+
//#region src/catalog.ts
|
|
722
|
+
/**
|
|
723
|
+
* What a shiplane.yml names from this plugin: `codeHost: github`, `ciPipeline: github-actions`,
|
|
724
|
+
* and the `release-comments` feature.
|
|
725
|
+
*/
|
|
726
|
+
const catalog = [
|
|
727
|
+
adapterEntry({
|
|
728
|
+
name: "github",
|
|
729
|
+
port: "codeHost",
|
|
730
|
+
description: "Pull requests, releases and deploy records on GitHub, through the gh CLI",
|
|
731
|
+
options: z$1.object({}),
|
|
732
|
+
make: () => gitHubCodeHost()
|
|
733
|
+
}),
|
|
734
|
+
adapterEntry({
|
|
735
|
+
name: "github-actions",
|
|
736
|
+
port: "ciPipeline",
|
|
737
|
+
description: "Ships through a GitHub Actions workflow, through the gh CLI",
|
|
738
|
+
options: z$1.object({ shipWorkflow: z$1.string().optional().describe("The workflow a ship through CI dispatches: ship.yml by default") }),
|
|
739
|
+
make: (options) => gitHubActionsCiPipeline(options)
|
|
740
|
+
}),
|
|
741
|
+
featureEntry({
|
|
742
|
+
name: "release-comments",
|
|
743
|
+
description: "Comments on each pull request and issue a ship releases",
|
|
744
|
+
options: z$1.object({ apps: z$1.array(z$1.string()).optional().describe("The apps whose ships comment; every app when absent") }),
|
|
745
|
+
slots: {
|
|
746
|
+
codeHost: { port: "codeHost" },
|
|
747
|
+
sourceControl: { port: "sourceControl" }
|
|
748
|
+
},
|
|
749
|
+
make: ({ apps }, { codeHost, sourceControl }) => {
|
|
750
|
+
if (!codeHost || !sourceControl) throw new Error("release-comments needs a codeHost and a sourceControl");
|
|
751
|
+
return releaseComments({
|
|
752
|
+
codeHost: serviceIn(codeHost),
|
|
753
|
+
sourceControl: serviceIn(sourceControl),
|
|
754
|
+
...apps ? { apps } : {}
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
})
|
|
758
|
+
];
|
|
759
|
+
//#endregion
|
|
760
|
+
export { catalog, gitHubActionsCiPipeline, gitHubCodeHost, releaseComments };
|
|
589
761
|
|
|
590
762
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/gh-cli.ts","../src/github-code-host.adapter.ts","../src/github-actions-ci-pipeline.adapter.ts","../src/issues.ts","../src/release-comments.feature.ts"],"sourcesContent":["import type { Shell } from \"shiplane/plugin\";\n\n// Primary and secondary limits both say \"rate limit\"; 429 is the plain HTTP form.\nconst RATE_LIMITED = /rate limit|HTTP 429/i;\nconst RETRIES = 4;\nconst FIRST_WAIT_MS = 2000;\n\nexport const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));\n\n/**\n * The gh CLI in the repository: `must` throws on a failed call, `json` parses its output. A call\n * GitHub rate limits is retried, waiting twice as long each time.\n */\nexport const ghCli = (root: string, shell: Shell, wait: (ms: number) => Promise<void> = sleep) => {\n const must = async (args: string[], input?: string) => {\n for (let attempt = 0; ; attempt++) {\n const result = await shell.capture(\"gh\", args, { cwd: root, input });\n if (result.status === 0) return result.stdout;\n const reason = result.stderr.trim().split(\"\\n\")[0] ?? \"\";\n if (RATE_LIMITED.test(result.stderr) && attempt < RETRIES) {\n await wait(FIRST_WAIT_MS * 2 ** attempt);\n continue;\n }\n throw new Error(\n `gh ${args.slice(0, 2).join(\" \")} exited with ${result.status}${reason ? `: ${reason}` : \"\"}`,\n );\n }\n };\n const json = async (args: string[]): Promise<unknown> => JSON.parse(await must(args));\n return { must, json };\n};\n","import type { CodeHostPort, ServiceAdapter, Shell } from \"shiplane/plugin\";\nimport { deployRunTitle, deployState, z } from \"shiplane/plugin\";\n\nimport { ghCli, sleep } from \"./gh-cli\";\n\nconst OpenPrsSchema = z.array(\n z.object({\n number: z.number(),\n url: z.string(),\n headRefName: z.string(),\n headRefOid: z.string(),\n }),\n);\nconst PrSchema = z.object({ number: z.number(), url: z.string(), headRefOid: z.string() });\nconst toOpenPr = ({ number, url, headRefOid }: z.infer<typeof PrSchema>) => ({\n number,\n url,\n head: headRefOid,\n});\nconst PrStateSchema = z.object({ state: z.enum([\"OPEN\", \"MERGED\", \"CLOSED\"]) });\nconst METHOD = { MERGE: \"--merge\", SQUASH: \"--squash\", REBASE: \"--rebase\" } as const;\nconst RepoMergeSchema = z.object({\n data: z.object({\n repository: z.object({\n mergeCommitAllowed: z.boolean(),\n squashMergeAllowed: z.boolean(),\n rebaseMergeAllowed: z.boolean(),\n viewerDefaultMergeMethod: z.enum([\"MERGE\", \"SQUASH\", \"REBASE\"]),\n }),\n }),\n});\nconst ReleaseListSchema = z.array(z.object({ tagName: z.string() }));\nconst DeploymentsSchema = z.object({\n data: z.object({\n repository: z.object({\n deployments: z.object({\n nodes: z.array(\n z.object({\n environment: z.string().nullish(),\n state: z.string().nullish(),\n ref: z.object({ name: z.string() }).nullish(),\n }),\n ),\n }),\n }),\n }),\n});\nconst LinkedPrSchema = z.object({\n number: z.number(),\n url: z.string(),\n body: z.string(),\n closingIssuesReferences: z.object({\n nodes: z.array(\n z.object({\n number: z.number(),\n repository: z.object({ name: z.string(), owner: z.object({ login: z.string() }) }),\n }),\n ),\n }),\n});\nconst CommentsSchema = z.object({\n comments: z.object({ nodes: z.array(z.object({ body: z.string() })) }),\n});\n// GraphQL answers aliases in the order they were asked, so Object.values reads them back in order.\nconst PullRequestsSchema = z.object({\n data: z.object({ repository: z.record(z.string(), LinkedPrSchema.nullable()) }),\n});\nconst IssueCommentsSchema = z.object({\n data: z.record(z.string(), z.object({ issueOrPullRequest: CommentsSchema.nullable() })),\n});\n// GitHub asks for a second between content-creating calls, or its secondary rate limit trips.\nconst POST_GAP_MS = 1000;\nconst LINKED_PR_FIELDS = `number url body closingIssuesReferences(first: 20) { nodes { number repository { name owner { login } } } }`;\nconst COMMENT_FIELDS = `comments(last: 100) { nodes { body } }`;\n// The method GitHub's merge button preselects: the viewer's last one, or the repository default.\nconst MERGE_QUERY = `query($owner: String!, $name: String!) {\n repository(owner: $owner, name: $name) {\n mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerDefaultMergeMethod\n }\n}`;\nconst DEPLOYMENTS_QUERY = `query($owner: String!, $name: String!) {\n repository(owner: $owner, name: $name) {\n deployments(environments: [\"preview\", \"production\"], first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n nodes { environment state ref { name } }\n }\n }\n}`;\n\nexport const githubHost = (root: string, shell: Shell): CodeHostPort => {\n const { must, json } = ghCli(root, shell);\n const graphql = (query: string, variables: string[] = []) =>\n json([\"api\", \"graphql\", ...variables, \"-f\", `query=${query}`]);\n let lastPost = 0;\n\n return {\n openPrsFrom: async (branchPrefix) => {\n const prs = OpenPrsSchema.parse(\n await json([\n \"pr\",\n \"list\",\n \"--state\",\n \"open\",\n \"--limit\",\n \"100\",\n \"--json\",\n \"number,url,headRefName,headRefOid\",\n ]),\n );\n return prs\n .filter(({ headRefName }) => headRefName.startsWith(branchPrefix))\n .map(toOpenPr)\n .sort((left, right) => left.number - right.number);\n },\n createPr: async ({ base, head, title, body, label }) => {\n // A fresh repository has none of shiplane's labels: gh refuses a PR with a missing one.\n await must([\"label\", \"create\", label, \"--color\", \"ededed\"]).catch((error: unknown) => {\n if (!(error instanceof Error && /already exists/i.test(error.message))) throw error;\n });\n await must([\n \"pr\",\n \"create\",\n \"--base\",\n base,\n \"--head\",\n head,\n \"--title\",\n title,\n \"--body\",\n body,\n \"--label\",\n label,\n ]);\n return toOpenPr(\n PrSchema.parse(await json([\"pr\", \"view\", head, \"--json\", \"number,url,headRefOid\"])),\n );\n },\n closePr: async (pr, comment) => {\n await must([\"pr\", \"close\", String(pr.number), \"--comment\", comment]);\n },\n prState: async (pr) =>\n PrStateSchema.parse(await json([\"pr\", \"view\", String(pr.number), \"--json\", \"state\"])).state,\n mergeMethods: async () => {\n const { repository } = RepoMergeSchema.parse(\n await json([\n \"api\",\n \"graphql\",\n \"-F\",\n \"owner={owner}\",\n \"-F\",\n \"name={repo}\",\n \"-f\",\n `query=${MERGE_QUERY}`,\n ]),\n ).data;\n const allowed = [\n repository.mergeCommitAllowed && METHOD.MERGE,\n repository.squashMergeAllowed && METHOD.SQUASH,\n repository.rebaseMergeAllowed && METHOD.REBASE,\n ].filter((method) => method !== false);\n return { allowed, preselected: METHOD[repository.viewerDefaultMergeMethod] };\n },\n merge: async (pr, method) => {\n await shell.attach(\"gh\", [\"pr\", \"merge\", String(pr.number), method], { cwd: root });\n },\n showDiff: async (pr) => {\n await shell.attach(\"gh\", [\"pr\", \"diff\", String(pr.number)], { cwd: root });\n },\n openInBrowser: async (pr) => {\n await shell.capture(\"gh\", [\"pr\", \"view\", String(pr.number), \"--web\"], { cwd: root });\n },\n releasedTags: async () =>\n new Set(\n ReleaseListSchema.parse(\n await json([\"release\", \"list\", \"--limit\", \"200\", \"--json\", \"tagName\"]),\n ).map(({ tagName }) => tagName),\n ),\n createRelease: async (tag, notes, latest) => {\n await must([\n \"release\",\n \"create\",\n tag,\n \"--verify-tag\",\n \"--title\",\n tag,\n \"--notes\",\n notes,\n ...(latest ? [] : [\"--latest=false\"]),\n ]);\n },\n deployments: async () => {\n const { data } = DeploymentsSchema.parse(\n await json([\n \"api\",\n \"graphql\",\n \"-F\",\n \"owner={owner}\",\n \"-F\",\n \"name={repo}\",\n \"-f\",\n `query=${DEPLOYMENTS_QUERY}`,\n ]),\n );\n return data.repository.deployments.nodes.flatMap(({ environment, state, ref }) =>\n ref && state && (environment === \"preview\" || environment === \"production\")\n ? [{ title: deployRunTitle(ref.name, environment), state: deployState([state]) }]\n : [],\n );\n },\n recordDeployment: async (ref, environment) => {\n const created = z\n .object({ id: z.number() })\n .parse(\n JSON.parse(\n await must(\n [\"api\", \"repos/{owner}/{repo}/deployments\", \"--method\", \"POST\", \"--input\", \"-\"],\n JSON.stringify({ ref, environment, auto_merge: false, required_contexts: [] }),\n ),\n ),\n );\n await must([\n \"api\",\n `repos/{owner}/{repo}/deployments/${created.id}/statuses`,\n \"--method\",\n \"POST\",\n \"-f\",\n \"state=success\",\n ]);\n },\n pullRequests: async (numbers) => {\n const fields = numbers.map(\n (number, index) => `a${index}: pullRequest(number: ${number}) { ${LINKED_PR_FIELDS} }`,\n );\n const { data } = PullRequestsSchema.parse(\n await graphql(\n `query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { ${fields.join(\" \")} } }`,\n [\"-F\", \"owner={owner}\", \"-F\", \"name={repo}\"],\n ),\n );\n return Object.values(data.repository).map((pr, index) => {\n if (!pr) throw new Error(`no pull request #${numbers[index]}`);\n return {\n repository: new URL(pr.url).pathname.split(\"/\").slice(1, 3).join(\"/\"),\n number: pr.number,\n body: pr.body,\n closes: pr.closingIssuesReferences.nodes.map(({ number: issue, repository }) => ({\n repository: `${repository.owner.login}/${repository.name}`,\n number: issue,\n })),\n };\n });\n },\n comments: async (refs) => {\n const fields = refs.map(({ repository, number }, index) => {\n const [owner = \"\", name = \"\"] = repository.split(\"/\");\n return `a${index}: repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)}) { issueOrPullRequest(number: ${number}) { ... on Issue { ${COMMENT_FIELDS} } ... on PullRequest { ${COMMENT_FIELDS} } } }`;\n });\n const { data } = IssueCommentsSchema.parse(await graphql(`query { ${fields.join(\" \")} }`));\n return Object.values(data).map(\n ({ issueOrPullRequest }) =>\n issueOrPullRequest?.comments.nodes.map(({ body }) => body) ?? [],\n );\n },\n comment: async ({ repository, number }, body) => {\n const wait = lastPost + POST_GAP_MS - Date.now();\n if (wait > 0) await sleep(wait);\n lastPost = Date.now();\n // The issues endpoint, not `gh issue comment`: it takes pull request numbers too.\n await must([\n \"api\",\n \"-X\",\n \"POST\",\n `repos/${repository}/issues/${number}/comments`,\n \"-f\",\n `body=${body}`,\n ]);\n },\n };\n};\n\nexport type GitHubCodeHostAdapter = ServiceAdapter<CodeHostPort>;\n\n/** Pull requests, comments, release notes and deploy records through the gh CLI. */\nexport const gitHubCodeHost = (): GitHubCodeHostAdapter => ({\n name: \"github\",\n requirements: () => [\n {\n label: \"gh\",\n check: { command: \"gh\", args: [\"auth\", \"status\"] },\n fix: { command: \"gh\", args: [\"auth\", \"login\"] },\n },\n ],\n create: ({ root, shell }) => githubHost(root, shell),\n});\n","import type { CiPipelinePort, Deploy, ServiceAdapter, Shell } from \"shiplane/plugin\";\nimport { actionsMinutes, billedMinutes, z } from \"shiplane/plugin\";\n\nimport { ghCli } from \"./gh-cli\";\n\nconst RunsSchema = z.array(\n z.object({ displayTitle: z.string(), status: z.string(), conclusion: z.string().nullish() }),\n);\nconst UsageSummarySchema = z.object({\n usageItems: z.array(\n z.object({ sku: z.string(), grossQuantity: z.number(), unitType: z.string() }),\n ),\n});\nconst JobsSchema = z.array(\n z.object({ startedAt: z.string().nullable(), completedAt: z.string().nullable() }),\n);\n\n/** Workflow runs, dispatches and the Actions minutes budget through the gh CLI. */\nconst githubActions = (root: string, shell: Shell, shipWorkflow: string): CiPipelinePort => {\n const { must, json } = ghCli(root, shell);\n const runs = async (workflow: string): Promise<Deploy[]> => {\n // A workflow not on the default branch yet has no runs, which gh reports as an error.\n const listed = await json([\n \"run\",\n \"list\",\n \"--workflow\",\n workflow,\n \"--limit\",\n \"100\",\n \"--json\",\n \"displayTitle,status,conclusion\",\n ]).catch(() => []);\n return RunsSchema.parse(listed).map(({ displayTitle, status, conclusion }) => ({\n title: displayTitle,\n state: status !== \"completed\" ? \"running\" : conclusion === \"success\" ? \"done\" : \"none\",\n }));\n };\n\n return {\n shipWorkflow,\n workflowRuns: runs,\n dispatch: async (workflow, ref, inputs) => {\n await must([\n \"workflow\",\n \"run\",\n workflow,\n \"--ref\",\n ref,\n ...Object.entries(inputs).flatMap(([key, value]) => [\"-f\", `${key}=${value}`]),\n ]);\n },\n minutes: async () => {\n try {\n const [plan, summary] = await Promise.all([\n must([\"api\", \"orgs/{owner}\", \"--jq\", \".plan.name\"]),\n json([\"api\", \"organizations/{owner}/settings/billing/usage/summary\"]),\n ]);\n return actionsMinutes(plan.trim(), UsageSummarySchema.parse(summary).usageItems);\n } catch {\n return null;\n }\n },\n measuredMinutes: async (workflow) => {\n try {\n const ids = z\n .array(z.object({ databaseId: z.number() }))\n .parse(\n await json([\n \"run\",\n \"list\",\n \"--workflow\",\n workflow,\n \"--status\",\n \"success\",\n \"--limit\",\n \"3\",\n \"--json\",\n \"databaseId\",\n ]),\n );\n return await Promise.all(\n ids.map(async ({ databaseId }) =>\n billedMinutes(\n JobsSchema.parse(\n await json([\n \"api\",\n `repos/{owner}/{repo}/actions/runs/${databaseId}/jobs`,\n \"--jq\",\n \"[.jobs[] | {startedAt: .started_at, completedAt: .completed_at}]\",\n ]),\n ),\n ),\n ),\n );\n } catch {\n return [];\n }\n },\n };\n};\n\nexport type GitHubActionsCiPipelineAdapter = ServiceAdapter<CiPipelinePort>;\n\n/**\n * Workflow runs, dispatches and the minutes budget on GitHub Actions, through the gh CLI. Shipping\n * through it dispatches `shipWorkflow` (default `ship.yml`) with `units` and `environment`.\n */\nexport const gitHubActionsCiPipeline = ({\n shipWorkflow = \"ship.yml\",\n}: { shipWorkflow?: string } = {}): GitHubActionsCiPipelineAdapter => ({\n name: \"github-actions\",\n requirements: () => [\n {\n label: \"gh\",\n check: { command: \"gh\", args: [\"auth\", \"status\"] },\n fix: { command: \"gh\", args: [\"auth\", \"login\"] },\n },\n ],\n create: ({ root, shell }) => githubActions(root, shell, shipWorkflow),\n});\n","import type { Environment, IssueRef, LinkedPr } from \"shiplane/plugin\";\nimport {\n compareVersions,\n DEFAULT_TAG_FORMAT,\n isReleaseSubject,\n issueName,\n tagName,\n} from \"shiplane/plugin\";\n\n/** The tag a unit had before this version, by version order. Null for its first release. */\nexport const previousTag = (\n tags: ReadonlySet<string>,\n unit: string,\n version: string,\n format: string = DEFAULT_TAG_FORMAT,\n) => {\n const [before = \"\", after = \"\"] = tagName(unit, \"\\0\", format).split(\"\\0\");\n const [newest] = [...tags]\n .filter((tag) => tag.startsWith(before) && tag.endsWith(after))\n .map((tag) => tag.slice(before.length, tag.length - after.length))\n .filter((candidate) => /^\\d/.test(candidate) && compareVersions(candidate, version) < 0)\n .sort((left, right) => compareVersions(right, left));\n return newest === undefined ? null : tagName(unit, newest, format);\n};\n\n/** The pull requests squash-merged as these subjects (`... (#1912)`), release PRs aside. */\nexport const pullRequestNumbers = (subjects: readonly string[]): number[] => [\n ...new Set(\n subjects.flatMap((subject) => {\n const found = /\\(#(\\d+)\\)\\s*$/.exec(subject)?.[1];\n return found && !isReleaseSubject(subject) ? [Number(found)] : [];\n }),\n ),\n];\n\nconst sameIssue = (left: IssueRef, right: IssueRef) =>\n left.repository === right.repository && left.number === right.number;\n\n/**\n * What GitHub says a PR closes, plus the template's commented `<!-- Ticket: owner/name#123 -->`\n * line. In that line a bare `#123` counts only right after `Ticket:`: later ones are stacked PRs.\n */\nexport const relatedIssues = (pr: LinkedPr): IssueRef[] => {\n const ticket = /<!--\\s*Ticket:([\\s\\S]*?)-->/.exec(pr.body)?.[1] ?? \"\";\n const named = [...ticket.matchAll(/([\\w.-]+\\/[\\w.-]+)#(\\d+)/g)].map(([, repository, number]) => ({\n repository: repository ?? pr.repository,\n number: Number(number),\n }));\n const bare = /^\\s*#(\\d+)\\b/.exec(ticket)?.[1];\n const all = [\n ...pr.closes,\n ...named,\n ...(bare ? [{ repository: pr.repository, number: Number(bare) }] : []),\n ];\n return all.filter((issue, index) => all.findIndex((other) => sameIssue(issue, other)) === index);\n};\n\n/** The hidden line that says a comment was already posted for this tag on this environment. */\nexport const releaseMarker = (tag: string, environment: Environment) =>\n `<!-- shiplane-release: ${tag} ${environment} -->`;\n\nconst mentions = (about: IssueRef, kind: \"pr\" | \"issue\", refs: readonly IssueRef[]) => {\n if (refs.length === 0) return \"\";\n const links = refs\n .map((ref) => (ref.repository === about.repository ? `#${ref.number}` : issueName(ref)))\n .join(\", \");\n const word = kind === \"pr\" ? \"PR\" : refs.length > 1 ? \"issues\" : \"issue\";\n return `, ${word} ${links}`;\n};\n\nexport interface Release {\n unit: string;\n version: string;\n tag: string;\n}\n\nconst versionsOf = (releases: readonly Release[]) => {\n const named = releases.map(({ unit, version }) => `**${version}** (${unit})`);\n const last = named.pop() ?? \"\";\n return named.length === 0 ? last : `${named.join(\", \")} and ${last}`;\n};\n\n/**\n * What a PR or an issue reads once releases it went into ship: short, in English.\n * An issue names its PRs, a PR names its issues.\n */\nexport const releaseComment = ({\n about,\n releases,\n environment,\n mention,\n}: {\n about: IssueRef;\n releases: readonly Release[];\n environment: Environment;\n mention: { kind: \"pr\" | \"issue\"; refs: readonly IssueRef[] };\n}) => {\n const links = mentions(about, mention.kind, mention.refs);\n const [only] = releases;\n const line =\n releases.length === 1 && only\n ? `in version **${only.version}** (${only.unit}${links}).`\n : `in versions ${versionsOf(releases)}${links}.`;\n const markers = releases.map(({ tag }) => releaseMarker(tag, environment)).join(\"\\n\");\n return `🚀 Released to **${environment}** ${line}\\n\\n${markers}`;\n};\n","import type {\n AfterShipContext,\n CodeHostPort,\n Environment,\n Feature,\n FollowUp,\n IssueRef,\n ServiceAdapter,\n Shipped,\n SourceControlPort,\n} from \"shiplane/plugin\";\nimport { issueName } from \"shiplane/plugin\";\n\nimport type { Release } from \"./issues\";\nimport {\n previousTag,\n pullRequestNumbers,\n relatedIssues,\n releaseComment,\n releaseMarker,\n} from \"./issues\";\n\nexport interface ReleaseCommentsOptions {\n /** Where the pull requests and issues live, and where the comments go. */\n codeHost: ServiceAdapter<CodeHostPort>;\n /** Where the tags are, to find the version a ship follows. */\n sourceControl: ServiceAdapter<SourceControlPort>;\n /** The apps whose ships comment; every app when absent. */\n apps?: string[];\n}\n\ninterface Target {\n about: IssueRef;\n environment: Environment;\n kind: \"pr\" | \"issue\";\n releases: (Release & { refs: IssueRef[] })[];\n}\n\nconst targetsOf = (\n linked: ReadonlyMap<number, { pr: IssueRef; issues: IssueRef[] }>,\n reached: readonly { shipped: Shipped; numbers: number[] }[],\n) => {\n const prs = new Map<string, Target>();\n const issues = new Map<string, Target>();\n const add = (\n into: Map<string, Target>,\n kind: Target[\"kind\"],\n about: IssueRef,\n { unit, tag, environment }: Shipped,\n refs: IssueRef[],\n ) => {\n const key = `${environment} ${issueName(about)}`;\n const target = into.get(key) ?? { about, environment, kind, releases: [] };\n const release = target.releases.find((entry) => entry.tag === tag);\n if (release) release.refs.push(...refs);\n else target.releases.push({ unit: unit.name, version: unit.version, tag, refs: [...refs] });\n into.set(key, target);\n };\n for (const { shipped, numbers } of reached) {\n for (const number of numbers) {\n const entry = linked.get(number);\n if (!entry) continue;\n add(prs, \"pr\", entry.pr, shipped, entry.issues);\n for (const issue of entry.issues) add(issues, \"issue\", issue, shipped, [entry.pr]);\n }\n }\n const sorted = [...prs.values()].sort((left, right) => left.about.number - right.about.number);\n return [...sorted, ...issues.values()];\n};\n\nconst uniqueRefs = (refs: readonly IssueRef[]) => {\n const seen = new Map(refs.map((ref) => [issueName(ref), ref]));\n return [...seen.values()];\n};\n\nconst followUpsOf = async (\n codeHost: CodeHostPort,\n context: AfterShipContext,\n tags: ReadonlySet<string>,\n picked: readonly Shipped[],\n): Promise<FollowUp[]> => {\n const reached = await Promise.all(\n picked.map(async (shipped) => {\n const { unit, tag } = shipped;\n const from = previousTag(tags, unit.name, unit.version, context.tagFormat);\n const numbers = from\n ? pullRequestNumbers(await context.subjectsReaching(unit, from, tag))\n : [];\n return { shipped, numbers: numbers.sort((left, right) => left - right) };\n }),\n );\n const numbers = [...new Set(reached.flatMap(({ numbers: found }) => found))].sort(\n (left, right) => left - right,\n );\n if (numbers.length === 0) return [];\n const prs = await codeHost.pullRequests(numbers);\n const linked = new Map(\n prs.map((pr, index) => [\n numbers[index] ?? pr.number,\n { pr: { repository: pr.repository, number: pr.number }, issues: relatedIssues(pr) },\n ]),\n );\n const targets = targetsOf(linked, reached);\n if (targets.length === 0) return [];\n const existing = await codeHost.comments(targets.map(({ about }) => about));\n return targets.flatMap(({ about, environment, kind, releases }, index) => {\n const pending = releases.filter(\n ({ tag }) =>\n !existing[index]?.some((comment) => comment.includes(releaseMarker(tag, environment))),\n );\n if (pending.length === 0) return [];\n const mention = {\n kind: kind === \"pr\" ? (\"issue\" as const) : (\"pr\" as const),\n refs: uniqueRefs(pending.flatMap(({ refs }) => refs)),\n };\n return [\n {\n label: `comment on ${issueName(about)}: ${pending.map(({ tag }) => tag).join(\", \")} on ${environment}`,\n run: () =>\n codeHost.comment(\n about,\n releaseComment({ about, releases: pending, environment, mention }),\n ),\n },\n ];\n });\n};\n\n/** Tells every PR the shipped versions hold, and every issue they relate to, that they are out: one comment per PR or issue, each tag and environment once. */\nexport const releaseComments = ({\n codeHost,\n sourceControl,\n apps,\n}: ReleaseCommentsOptions): Feature => ({\n type: \"feature\",\n name: \"release-comments\",\n adapters: [codeHost, sourceControl],\n requirements: () => [\n ...(codeHost.requirements?.() ?? []),\n ...(sourceControl.requirements?.() ?? []),\n ],\n afterShip: async (context, shipped) => {\n const picked = shipped.filter(({ unit }) => !apps || apps.includes(unit.name));\n if (picked.length === 0) return [];\n const host = context.open(codeHost);\n const tags = await context.open(sourceControl).tags();\n return followUpsOf(host, context, tags, picked);\n },\n});\n"],"mappings":";;AAGA,MAAM,eAAe;AACrB,MAAM,UAAU;AAChB,MAAM,gBAAgB;AAEtB,MAAa,SAAS,OAAe,IAAI,SAAe,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;AAM5F,MAAa,SAAS,MAAc,OAAc,OAAsC,UAAU;CAChG,MAAM,OAAO,OAAO,MAAgB,UAAmB;AACrD,OAAK,IAAI,UAAU,IAAK,WAAW;GACjC,MAAM,SAAS,MAAM,MAAM,QAAQ,MAAM,MAAM;IAAE,KAAK;IAAM;IAAO,CAAC;AACpE,OAAI,OAAO,WAAW,EAAG,QAAO,OAAO;GACvC,MAAM,SAAS,OAAO,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM;AACtD,OAAI,aAAa,KAAK,OAAO,OAAO,IAAI,UAAU,SAAS;AACzD,UAAM,KAAK,gBAAgB,KAAK,QAAQ;AACxC;;AAEF,SAAM,IAAI,MACR,MAAM,KAAK,MAAM,GAAG,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IJ,MAAa,mBAAmB,EAC9B,UACA,eACA,YACsC;CACtC,MAAM;CACN,MAAM;CACN,UAAU,CAAC,UAAU,cAAc;CACnC,oBAAoB,CAClB,GAAI,SAAS,gBAAgB,IAAI,EAAE,EACnC,GAAI,cAAc,gBAAgB,IAAI,EAAE,CACzC;CACD,WAAW,OAAO,SAAS,YAAY;EACrC,MAAM,SAAS,QAAQ,QAAQ,EAAE,WAAW,CAAC,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC;AAC9E,MAAI,OAAO,WAAW,EAAG,QAAO,EAAE;AAGlC,SAAO,YAFM,QAAQ,KAAK,SAEH,EAAE,SAAS,MADf,QAAQ,KAAK,cAAc,CAAC,MAAM,EACb,OAAO;;CAElD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["z"],"sources":["../src/gh-cli.ts","../src/github-code-host.adapter.ts","../src/github-actions-ci-pipeline.adapter.ts","../src/issues.ts","../src/release-comments.feature.ts","../src/catalog.ts"],"sourcesContent":["import type { Requirement, Shell } from \"shiplane/plugin\";\nimport { firstLine, retrying } from \"shiplane/plugin\";\n\n// Primary and secondary limits both say \"rate limit\"; 429 is the plain HTTP form.\nconst RATE_LIMITED = /rate limit|HTTP 429/i;\n// Four more tries, waiting twice as long each time.\nconst RATE_LIMIT_WAITS_MS = [2_000, 4_000, 8_000, 16_000];\n\n/** What every adapter driving gh needs: gh signed in. */\nexport const GH_REQUIREMENT: Requirement = {\n label: \"gh\",\n check: { command: \"gh\", args: [\"auth\", \"status\"] },\n fix: { command: \"gh\", args: [\"auth\", \"login\"] },\n // Every GitHub-hosted runner has gh already.\n secrets: [\"GH_TOKEN\"],\n};\n\nexport const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));\n\n/**\n * The gh CLI in the repository: `must` throws on a failed call, `json` parses its output. A call\n * GitHub rate limits is retried, waiting twice as long each time.\n */\nexport const ghCli = ({\n root,\n shell,\n wait = sleep,\n}: {\n root: string;\n shell: Shell;\n wait?: (ms: number) => Promise<void>;\n}) => {\n const must = async (args: string[], input?: string) => {\n const result = await retrying({\n run: () => shell.capture(\"gh\", args, { cwd: root, input }),\n retryable: ({ status, stderr }) => status !== 0 && RATE_LIMITED.test(stderr),\n delays: RATE_LIMIT_WAITS_MS,\n wait,\n });\n if (result.status === 0) return result.stdout;\n const reason = firstLine(result.stderr);\n throw new Error(\n `gh ${args.slice(0, 2).join(\" \")} exited with ${result.status}${reason ? `: ${reason}` : \"\"}`,\n );\n };\n const json = async (args: string[]): Promise<unknown> => JSON.parse(await must(args));\n return { must, json };\n};\n","import type { CodeHostPort, ServiceAdapter, Shell } from \"shiplane/plugin\";\nimport { deployRunTitle, deployState, z } from \"shiplane/plugin\";\n\nimport { GH_REQUIREMENT, ghCli, sleep } from \"./gh-cli\";\n\nconst OpenPrsSchema = z.array(\n z.object({\n number: z.number(),\n url: z.string(),\n headRefName: z.string(),\n headRefOid: z.string(),\n }),\n);\nconst PrSchema = z.object({ number: z.number(), url: z.string(), headRefOid: z.string() });\nconst IssueCommentSchema = z.object({ id: z.number(), body: z.string() });\nconst toOpenPr = ({ number, url, headRefOid }: z.infer<typeof PrSchema>) => ({\n number,\n url,\n head: headRefOid,\n});\nconst PrStateSchema = z.object({ state: z.enum([\"OPEN\", \"MERGED\", \"CLOSED\"]) });\nconst METHOD = { MERGE: \"--merge\", SQUASH: \"--squash\", REBASE: \"--rebase\" } as const;\nconst RepoMergeSchema = z.object({\n data: z.object({\n repository: z.object({\n mergeCommitAllowed: z.boolean(),\n squashMergeAllowed: z.boolean(),\n rebaseMergeAllowed: z.boolean(),\n viewerDefaultMergeMethod: z.enum([\"MERGE\", \"SQUASH\", \"REBASE\"]),\n }),\n }),\n});\nconst ReleaseListSchema = z.array(z.object({ tagName: z.string() }));\nconst RepoSchema = z.object({ url: z.string() });\nconst DeploymentsSchema = z.object({\n data: z.object({\n repository: z.object({\n deployments: z.object({\n nodes: z.array(\n z.object({\n environment: z.string().nullish(),\n state: z.string().nullish(),\n ref: z.object({ name: z.string() }).nullish(),\n }),\n ),\n }),\n }),\n }),\n});\nconst LinkedPrSchema = z.object({\n number: z.number(),\n url: z.string(),\n body: z.string(),\n closingIssuesReferences: z.object({\n nodes: z.array(\n z.object({\n number: z.number(),\n repository: z.object({ name: z.string(), owner: z.object({ login: z.string() }) }),\n }),\n ),\n }),\n});\nconst CommentsSchema = z.object({\n comments: z.object({ nodes: z.array(z.object({ body: z.string() })) }),\n});\n// GraphQL answers aliases in the order they were asked, so Object.values reads them back in order.\nconst PullRequestsSchema = z.object({\n data: z.object({ repository: z.record(z.string(), LinkedPrSchema.nullable()) }),\n});\nconst IssueCommentsSchema = z.object({\n data: z.record(z.string(), z.object({ issueOrPullRequest: CommentsSchema.nullable() })),\n});\n// GitHub asks for a second between content-creating calls, or its secondary rate limit trips.\nconst POST_GAP_MS = 1000;\nconst LINKED_PR_FIELDS = `number url body closingIssuesReferences(first: 20) { nodes { number repository { name owner { login } } } }`;\nconst COMMENT_FIELDS = `comments(last: 100) { nodes { body } }`;\n// The method GitHub's merge button preselects: the viewer's last one, or the repository default.\nconst MERGE_QUERY = `query($owner: String!, $name: String!) {\n repository(owner: $owner, name: $name) {\n mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerDefaultMergeMethod\n }\n}`;\nconst DEPLOYMENTS_QUERY = `query($owner: String!, $name: String!) {\n repository(owner: $owner, name: $name) {\n deployments(environments: [\"preview\", \"production\"], first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n nodes { environment state ref { name } }\n }\n }\n}`;\n\nexport const githubHost = (root: string, shell: Shell): CodeHostPort => {\n const { must, json } = ghCli({ root, shell });\n const graphql = (query: string, variables: string[] = []) =>\n json([\"api\", \"graphql\", ...variables, \"-f\", `query=${query}`]);\n let lastPost = 0;\n\n return {\n openPrsFrom: async (branchPrefix) => {\n const prs = OpenPrsSchema.parse(\n await json([\n \"pr\",\n \"list\",\n \"--state\",\n \"open\",\n \"--limit\",\n \"100\",\n \"--json\",\n \"number,url,headRefName,headRefOid\",\n ]),\n );\n return prs\n .filter(({ headRefName }) => headRefName.startsWith(branchPrefix))\n .map(toOpenPr)\n .sort((left, right) => left.number - right.number);\n },\n createPr: async ({ base, head, title, body, label }) => {\n // A fresh repository has none of shiplane's labels: gh refuses a PR with a missing one.\n await must([\"label\", \"create\", label, \"--color\", \"ededed\"]).catch((error: unknown) => {\n if (!(error instanceof Error && /already exists/i.test(error.message))) throw error;\n });\n await must([\n \"pr\",\n \"create\",\n \"--base\",\n base,\n \"--head\",\n head,\n \"--title\",\n title,\n \"--body\",\n body,\n \"--label\",\n label,\n ]);\n return toOpenPr(\n PrSchema.parse(await json([\"pr\", \"view\", head, \"--json\", \"number,url,headRefOid\"])),\n );\n },\n closePr: async (pr, comment) => {\n await must([\"pr\", \"close\", String(pr.number), \"--comment\", comment]);\n },\n prState: async (pr) =>\n PrStateSchema.parse(await json([\"pr\", \"view\", String(pr.number), \"--json\", \"state\"])).state,\n mergeMethods: async () => {\n const { repository } = RepoMergeSchema.parse(\n await json([\n \"api\",\n \"graphql\",\n \"-F\",\n \"owner={owner}\",\n \"-F\",\n \"name={repo}\",\n \"-f\",\n `query=${MERGE_QUERY}`,\n ]),\n ).data;\n const allowed = [\n repository.mergeCommitAllowed && METHOD.MERGE,\n repository.squashMergeAllowed && METHOD.SQUASH,\n repository.rebaseMergeAllowed && METHOD.REBASE,\n ].filter((method) => method !== false);\n return { allowed, preselected: METHOD[repository.viewerDefaultMergeMethod] };\n },\n merge: async (pr, method) => {\n await shell.attach(\"gh\", [\"pr\", \"merge\", String(pr.number), method], { cwd: root });\n },\n showDiff: async (pr) => {\n await shell.attach(\"gh\", [\"pr\", \"diff\", String(pr.number)], { cwd: root });\n },\n openInBrowser: async (pr) => {\n await shell.capture(\"gh\", [\"pr\", \"view\", String(pr.number), \"--web\"], { cwd: root });\n },\n releasedTags: async () =>\n new Set(\n ReleaseListSchema.parse(\n await json([\"release\", \"list\", \"--limit\", \"200\", \"--json\", \"tagName\"]),\n ).map(({ tagName }) => tagName),\n ),\n createRelease: async (tag, notes, latest, previous) => {\n const compare = previous\n ? `\\n\\n**Full Changelog**: ${RepoSchema.parse(await json([\"repo\", \"view\", \"--json\", \"url\"])).url}/compare/${previous}...${tag}`\n : \"\";\n await must([\n \"release\",\n \"create\",\n tag,\n \"--verify-tag\",\n \"--title\",\n tag,\n \"--notes\",\n `${notes}${compare}`,\n ...(latest ? [] : [\"--latest=false\"]),\n ]);\n },\n deployments: async () => {\n const { data } = DeploymentsSchema.parse(\n await json([\n \"api\",\n \"graphql\",\n \"-F\",\n \"owner={owner}\",\n \"-F\",\n \"name={repo}\",\n \"-f\",\n `query=${DEPLOYMENTS_QUERY}`,\n ]),\n );\n return data.repository.deployments.nodes.flatMap(({ environment, state, ref }) =>\n ref && state && (environment === \"preview\" || environment === \"production\")\n ? [{ title: deployRunTitle(ref.name, environment), state: deployState([state]) }]\n : [],\n );\n },\n recordDeployment: async (ref, environment) => {\n const created = z\n .object({ id: z.number() })\n .parse(\n JSON.parse(\n await must(\n [\"api\", \"repos/{owner}/{repo}/deployments\", \"--method\", \"POST\", \"--input\", \"-\"],\n JSON.stringify({ ref, environment, auto_merge: false, required_contexts: [] }),\n ),\n ),\n );\n await must([\n \"api\",\n `repos/{owner}/{repo}/deployments/${created.id}/statuses`,\n \"--method\",\n \"POST\",\n \"-f\",\n \"state=success\",\n ]);\n },\n pullRequests: async (numbers) => {\n const fields = numbers.map(\n (number, index) => `a${index}: pullRequest(number: ${number}) { ${LINKED_PR_FIELDS} }`,\n );\n const { data } = PullRequestsSchema.parse(\n await graphql(\n `query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { ${fields.join(\" \")} } }`,\n [\"-F\", \"owner={owner}\", \"-F\", \"name={repo}\"],\n ),\n );\n return Object.values(data.repository).map((pr, index) => {\n if (!pr) throw new Error(`no pull request #${numbers[index]}`);\n return {\n repository: new URL(pr.url).pathname.split(\"/\").slice(1, 3).join(\"/\"),\n number: pr.number,\n body: pr.body,\n closes: pr.closingIssuesReferences.nodes.map(({ number: issue, repository }) => ({\n repository: `${repository.owner.login}/${repository.name}`,\n number: issue,\n })),\n };\n });\n },\n comments: async (refs) => {\n const fields = refs.map(({ repository, number }, index) => {\n const [owner = \"\", name = \"\"] = repository.split(\"/\");\n return `a${index}: repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)}) { issueOrPullRequest(number: ${number}) { ... on Issue { ${COMMENT_FIELDS} } ... on PullRequest { ${COMMENT_FIELDS} } } }`;\n });\n const { data } = IssueCommentsSchema.parse(await graphql(`query { ${fields.join(\" \")} }`));\n return Object.values(data).map(\n ({ issueOrPullRequest }) =>\n issueOrPullRequest?.comments.nodes.map(({ body }) => body) ?? [],\n );\n },\n prForBranch: async (branch) => {\n const [pr] = z\n .array(PrSchema)\n .parse(\n await json([\n \"pr\",\n \"list\",\n \"--head\",\n branch,\n \"--state\",\n \"open\",\n \"--limit\",\n \"1\",\n \"--json\",\n \"number,url,headRefOid\",\n ]),\n );\n return pr ? toOpenPr(pr) : null;\n },\n upsertComment: async ({ on, marker, body }) => {\n // One JSON object per line: --paginate joins pages, --jq keeps each comment parseable.\n const listed = await must([\n \"api\",\n `repos/{owner}/{repo}/issues/${on.number}/comments`,\n \"--paginate\",\n \"--jq\",\n \".[] | {id, body}\",\n ]);\n const found = listed\n .split(\"\\n\")\n .filter(Boolean)\n .map((line) => IssueCommentSchema.parse(JSON.parse(line)))\n .find((comment) => comment.body.includes(marker));\n const [method, endpoint] = found\n ? [\"PATCH\", `repos/{owner}/{repo}/issues/comments/${found.id}`]\n : [\"POST\", `repos/{owner}/{repo}/issues/${on.number}/comments`];\n await must([\"api\", \"-X\", method, endpoint, \"-f\", `body=${body}`]);\n },\n comment: async ({ repository, number }, body) => {\n const wait = lastPost + POST_GAP_MS - Date.now();\n if (wait > 0) await sleep(wait);\n lastPost = Date.now();\n // The issues endpoint, not `gh issue comment`: it takes pull request numbers too.\n await must([\n \"api\",\n \"-X\",\n \"POST\",\n `repos/${repository}/issues/${number}/comments`,\n \"-f\",\n `body=${body}`,\n ]);\n },\n };\n};\n\nexport type GitHubCodeHostAdapter = ServiceAdapter<CodeHostPort>;\n\n/** Pull requests, comments, release notes and deploy records through the gh CLI. */\nexport const gitHubCodeHost = (): GitHubCodeHostAdapter => ({\n name: \"github\",\n requirements: () => [GH_REQUIREMENT],\n create: ({ root, shell }) => githubHost(root, shell),\n});\n","import type { CallerNeeds, CiPipelinePort, Deploy, ServiceAdapter, Shell } from \"shiplane/plugin\";\nimport { actionsMinutes, billedMinutes, z } from \"shiplane/plugin\";\n\nimport { GH_REQUIREMENT, ghCli } from \"./gh-cli\";\n\nconst RunsSchema = z.array(\n z.object({ displayTitle: z.string(), status: z.string(), conclusion: z.string().nullish() }),\n);\nconst UsageSummarySchema = z.object({\n usageItems: z.array(\n z.object({ sku: z.string(), grossQuantity: z.number(), unitType: z.string() }),\n ),\n});\nconst JobsSchema = z.array(\n z.object({ startedAt: z.string().nullable(), completedAt: z.string().nullable() }),\n);\n\nconst RefSchema = z.object({ object: z.object({ sha: z.string(), type: z.string() }) });\nconst CommitSchema = z.object({ sha: z.string() });\n\n/** A test version, `<version>-<branch>.<short sha>`, ends on the commit it was built from. */\nconst TEST_VERSION = /^\\d+\\.\\d+\\.\\d+-[0-9a-z-]+\\.g?([0-9a-f]{7,40})$/;\n\nconst isMissing = (error: unknown) =>\n error instanceof Error && /HTTP 404|HTTP 422|Not Found|No commit found/.test(error.message);\n\n/** Where shiplane's own workflow and its release tags live. */\nconst SHIPLANE_REPO = \"arnaud-zg/js-packages\";\n\n/** What shiplane's workflow may do: comment on PRs and issues only with release comments. */\nconst permissionsOf = ({ features }: CallerNeeds) => [\n \"permissions:\",\n \" contents: read\",\n \" deployments: write\",\n \" actions: read\",\n ...(features.includes(\"release-comments\") ? [\" issues: write\", \" pull-requests: write\"] : []),\n];\n\n/** Each secret its adapters read, passed by name: GitHub hands a called workflow no other. */\nconst secretsOf = ({ secrets }: CallerNeeds) =>\n secrets.length === 0\n ? []\n : [\" secrets:\", ...secrets.map((name) => ` ${name}: \\${{ secrets.${name} }}`)];\n\n/** The workflow a repository ships from: a manual run calling shiplane's, pinned to a commit. */\nconst callerContent = (sha: string, version: string, needs: CallerNeeds) =>\n [\n \"# Ships with shiplane: `pnpm shiplane ship --via ci`, or Run workflow here.\",\n \"# Written by `shiplane setup`; `shiplane doctor` keeps the pin current.\",\n \"name: Ship\",\n \"run-name: Ship ${{ inputs.units || 'every released unit' }} to ${{ inputs.environment }}\",\n \"\",\n \"on:\",\n \" workflow_dispatch:\",\n \" inputs:\",\n \" units:\",\n ' description: \"Units to ship, space separated (empty: every unit the environment lacks)\"',\n \" type: string\",\n ' default: \"\"',\n \" environment:\",\n ' description: \"Where to ship the ref this runs on\"',\n \" type: choice\",\n \" options: [preview, production]\",\n \" default: preview\",\n \"\",\n ...permissionsOf(needs),\n \"\",\n \"jobs:\",\n \" ship:\",\n ` uses: ${SHIPLANE_REPO}/.github/workflows/shiplane-ship.yml@${sha} # shiplane@${version}`,\n \" with:\",\n \" units: ${{ inputs.units }}\",\n \" environment: ${{ inputs.environment }}\",\n ...secretsOf(needs),\n \"\",\n ].join(\"\\n\");\n\ntype Run = z.infer<typeof RunsSchema>[number];\n\n/** A workflow run as a deploy record: still going, succeeded, or anything else. */\nconst runState = ({ status, conclusion }: Pick<Run, \"status\" | \"conclusion\">): Deploy[\"state\"] => {\n if (status !== \"completed\") return \"running\";\n return conclusion === \"success\" ? \"done\" : \"none\";\n};\n\n/** Workflow runs, dispatches and the Actions minutes budget through the gh CLI. */\nconst githubActions = (root: string, shell: Shell, shipWorkflow: string): CiPipelinePort => {\n const { must, json } = ghCli({ root, shell });\n const runs = async (workflow: string): Promise<Deploy[]> => {\n // A workflow not on the default branch yet has no runs, which gh reports as an error.\n const listed = await json([\n \"run\",\n \"list\",\n \"--workflow\",\n workflow,\n \"--limit\",\n \"100\",\n \"--json\",\n \"displayTitle,status,conclusion\",\n ]).catch(() => []);\n return RunsSchema.parse(listed).map((run) => ({\n title: run.displayTitle,\n state: runState(run),\n }));\n };\n\n return {\n shipWorkflow,\n label: \"GitHub Actions\",\n // GitHub runs the workflow file the ref holds.\n workflowFile: (workflow) => `.github/workflows/${workflow}`,\n dispatchLine: (workflow, ref, inputs) =>\n [\n `gh workflow run ${workflow} --ref ${ref}`,\n ...Object.entries(inputs).map(([key, value]) => `-f ${key}=${value}`),\n ].join(\" \"),\n workflowRuns: runs,\n callerWorkflow: async (version, needs) => {\n const tag = `shiplane@${version}`;\n const orMissing = (error: unknown) => {\n if (isMissing(error)) return null;\n throw error;\n };\n // A test version has no release tag: it pins the commit its short sha names.\n const short = TEST_VERSION.exec(version)?.[1];\n if (short) {\n const commit = await json([\"api\", `repos/${SHIPLANE_REPO}/commits/${short}`]).catch(\n orMissing,\n );\n if (commit === null) {\n return { error: `no commit ${short} for ${tag}: pin shiplane-ship.yml by hand` };\n }\n const { sha } = CommitSchema.parse(commit);\n return {\n file: `.github/workflows/${shipWorkflow}`,\n content: callerContent(sha, version, needs),\n pin: sha,\n };\n }\n const ref = await json([\"api\", `repos/${SHIPLANE_REPO}/git/ref/tags/${tag}`]).catch(\n orMissing,\n );\n if (ref === null) return { error: `no release tag ${tag}: pin shiplane-ship.yml by hand` };\n const { object } = RefSchema.parse(ref);\n // An annotated tag points at a tag object, which points at the commit.\n const sha =\n object.type === \"tag\"\n ? RefSchema.parse(await json([\"api\", `repos/${SHIPLANE_REPO}/git/tags/${object.sha}`]))\n .object.sha\n : object.sha;\n return {\n file: `.github/workflows/${shipWorkflow}`,\n content: callerContent(sha, version, needs),\n pin: sha,\n };\n },\n dispatch: async (workflow, ref, inputs) => {\n await must([\n \"workflow\",\n \"run\",\n workflow,\n \"--ref\",\n ref,\n ...Object.entries(inputs).flatMap(([key, value]) => [\"-f\", `${key}=${value}`]),\n ]);\n },\n minutes: async () => {\n try {\n const [plan, summary] = await Promise.all([\n must([\"api\", \"orgs/{owner}\", \"--jq\", \".plan.name\"]),\n json([\"api\", \"organizations/{owner}/settings/billing/usage/summary\"]),\n ]);\n return actionsMinutes(plan.trim(), UsageSummarySchema.parse(summary).usageItems);\n } catch {\n return null;\n }\n },\n measuredMinutes: async (workflow) => {\n try {\n const ids = z\n .array(z.object({ databaseId: z.number() }))\n .parse(\n await json([\n \"run\",\n \"list\",\n \"--workflow\",\n workflow,\n \"--status\",\n \"success\",\n \"--limit\",\n \"3\",\n \"--json\",\n \"databaseId\",\n ]),\n );\n return await Promise.all(\n ids.map(async ({ databaseId }) =>\n billedMinutes(\n JobsSchema.parse(\n await json([\n \"api\",\n `repos/{owner}/{repo}/actions/runs/${databaseId}/jobs`,\n \"--jq\",\n \"[.jobs[] | {startedAt: .started_at, completedAt: .completed_at}]\",\n ]),\n ),\n ),\n ),\n );\n } catch {\n return [];\n }\n },\n };\n};\n\nexport type GitHubActionsCiPipelineAdapter = ServiceAdapter<CiPipelinePort>;\n\n/**\n * Workflow runs, dispatches and the minutes budget on GitHub Actions, through the gh CLI. Shipping\n * through it dispatches `shipWorkflow` (default `ship.yml`) with `units` and `environment`.\n */\nexport const gitHubActionsCiPipeline = (\n options: { shipWorkflow?: string } = {},\n): GitHubActionsCiPipelineAdapter => ({\n name: \"github-actions\",\n options,\n requirements: () => [GH_REQUIREMENT],\n create: ({ root, shell }) => githubActions(root, shell, options.shipWorkflow ?? \"ship.yml\"),\n});\n","import type { Environment, IssueRef, LinkedPr } from \"shiplane/plugin\";\nimport { isReleaseSubject, issueName } from \"shiplane/plugin\";\n\n/** The pull requests squash-merged as these subjects (`... (#1912)`), release PRs aside. */\nexport const pullRequestNumbers = (subjects: readonly string[]): number[] => [\n ...new Set(\n subjects.flatMap((subject) => {\n const found = /\\(#(\\d+)\\)\\s*$/.exec(subject)?.[1];\n return found && !isReleaseSubject(subject) ? [Number(found)] : [];\n }),\n ),\n];\n\nconst sameIssue = (left: IssueRef, right: IssueRef) =>\n left.repository === right.repository && left.number === right.number;\n\n/**\n * What GitHub says a PR closes, plus the template's commented `<!-- Ticket: owner/name#123 -->`\n * line. In that line a bare `#123` counts only right after `Ticket:`: later ones are stacked PRs.\n */\nexport const relatedIssues = (pr: LinkedPr): IssueRef[] => {\n const ticket = /<!--\\s*Ticket:([\\s\\S]*?)-->/.exec(pr.body)?.[1] ?? \"\";\n const named = [...ticket.matchAll(/([\\w.-]+\\/[\\w.-]+)#(\\d+)/g)].map(([, repository, number]) => ({\n repository: repository ?? pr.repository,\n number: Number(number),\n }));\n const bare = /^\\s*#(\\d+)\\b/.exec(ticket)?.[1];\n const all = [\n ...pr.closes,\n ...named,\n ...(bare ? [{ repository: pr.repository, number: Number(bare) }] : []),\n ];\n return all.filter((issue, index) => all.findIndex((other) => sameIssue(issue, other)) === index);\n};\n\n/** The hidden line that says a comment was already posted for this tag on this environment. */\nexport const releaseMarker = (tag: string, environment: Environment) =>\n `<!-- shiplane-release: ${tag} ${environment} -->`;\n\nconst mentions = (about: IssueRef, kind: \"pr\" | \"issue\", refs: readonly IssueRef[]) => {\n if (refs.length === 0) return \"\";\n const links = refs\n .map((ref) => (ref.repository === about.repository ? `#${ref.number}` : issueName(ref)))\n .join(\", \");\n const word = kind === \"pr\" ? \"PR\" : refs.length > 1 ? \"issues\" : \"issue\";\n return `, ${word} ${links}`;\n};\n\nexport interface Release {\n unit: string;\n version: string;\n tag: string;\n}\n\nconst versionsOf = (releases: readonly Release[]) => {\n const named = releases.map(({ unit, version }) => `**${version}** (${unit})`);\n const last = named.pop() ?? \"\";\n return named.length === 0 ? last : `${named.join(\", \")} and ${last}`;\n};\n\n/**\n * What a PR or an issue reads once releases it went into ship: short, in English.\n * An issue names its PRs, a PR names its issues.\n */\nexport const releaseComment = ({\n about,\n releases,\n environment,\n mention,\n}: {\n about: IssueRef;\n releases: readonly Release[];\n environment: Environment;\n mention: { kind: \"pr\" | \"issue\"; refs: readonly IssueRef[] };\n}) => {\n const links = mentions(about, mention.kind, mention.refs);\n const [only] = releases;\n const line =\n releases.length === 1 && only\n ? `in version **${only.version}** (${only.unit}${links}).`\n : `in versions ${versionsOf(releases)}${links}.`;\n const markers = releases.map(({ tag }) => releaseMarker(tag, environment)).join(\"\\n\");\n return `🚀 Released to **${environment}** ${line}\\n\\n${markers}`;\n};\n","import type {\n AfterShipContext,\n CodeHostPort,\n Environment,\n Feature,\n FollowUp,\n IssueRef,\n ServiceAdapter,\n Shipped,\n SourceControlPort,\n} from \"shiplane/plugin\";\nimport { issueName, previousTag } from \"shiplane/plugin\";\n\nimport type { Release } from \"./issues\";\nimport { pullRequestNumbers, relatedIssues, releaseComment, releaseMarker } from \"./issues\";\n\nexport interface ReleaseCommentsOptions {\n /** Where the pull requests and issues live, and where the comments go. */\n codeHost: ServiceAdapter<CodeHostPort>;\n /** Where the tags are, to find the version a ship follows. */\n sourceControl: ServiceAdapter<SourceControlPort>;\n /** The apps whose ships comment; every app when absent. */\n apps?: string[];\n}\n\ninterface Target {\n about: IssueRef;\n environment: Environment;\n kind: \"pr\" | \"issue\";\n releases: (Release & { refs: IssueRef[] })[];\n}\n\nconst targetsOf = (\n linked: ReadonlyMap<number, { pr: IssueRef; issues: IssueRef[] }>,\n reached: readonly { shipped: Shipped; numbers: number[] }[],\n) => {\n const prs = new Map<string, Target>();\n const issues = new Map<string, Target>();\n const add = (\n into: Map<string, Target>,\n kind: Target[\"kind\"],\n about: IssueRef,\n { unit, tag, environment }: Shipped,\n refs: IssueRef[],\n ) => {\n const key = `${environment} ${issueName(about)}`;\n const target = into.get(key) ?? { about, environment, kind, releases: [] };\n const release = target.releases.find((entry) => entry.tag === tag);\n if (release) release.refs.push(...refs);\n else target.releases.push({ unit: unit.name, version: unit.version, tag, refs: [...refs] });\n into.set(key, target);\n };\n for (const { shipped, numbers } of reached) {\n for (const number of numbers) {\n const entry = linked.get(number);\n if (!entry) continue;\n add(prs, \"pr\", entry.pr, shipped, entry.issues);\n for (const issue of entry.issues) add(issues, \"issue\", issue, shipped, [entry.pr]);\n }\n }\n const sorted = [...prs.values()].sort((left, right) => left.about.number - right.about.number);\n return [...sorted, ...issues.values()];\n};\n\nconst uniqueRefs = (refs: readonly IssueRef[]) => {\n const seen = new Map(refs.map((ref) => [issueName(ref), ref]));\n return [...seen.values()];\n};\n\nconst followUpsOf = async (\n codeHost: CodeHostPort,\n context: AfterShipContext,\n tags: ReadonlySet<string>,\n picked: readonly Shipped[],\n): Promise<FollowUp[]> => {\n const reached = await Promise.all(\n picked.map(async (shipped) => {\n const { unit, tag } = shipped;\n const from = previousTag({\n tags,\n unit: unit.name,\n version: unit.version,\n format: context.tagFormat,\n });\n const numbers = from\n ? pullRequestNumbers(await context.subjectsReaching(unit, from, tag))\n : [];\n return { shipped, numbers: numbers.sort((left, right) => left - right) };\n }),\n );\n const numbers = [...new Set(reached.flatMap(({ numbers: found }) => found))].sort(\n (left, right) => left - right,\n );\n if (numbers.length === 0) return [];\n const prs = await codeHost.pullRequests(numbers);\n const linked = new Map(\n prs.map((pr, index) => [\n numbers[index] ?? pr.number,\n { pr: { repository: pr.repository, number: pr.number }, issues: relatedIssues(pr) },\n ]),\n );\n const targets = targetsOf(linked, reached);\n if (targets.length === 0) return [];\n const existing = await codeHost.comments(targets.map(({ about }) => about));\n return targets.flatMap(({ about, environment, kind, releases }, index) => {\n const pending = releases.filter(\n ({ tag }) =>\n !existing[index]?.some((comment) => comment.includes(releaseMarker(tag, environment))),\n );\n if (pending.length === 0) return [];\n const mention = {\n kind: kind === \"pr\" ? (\"issue\" as const) : (\"pr\" as const),\n refs: uniqueRefs(pending.flatMap(({ refs }) => refs)),\n };\n return [\n {\n label: `comment on ${issueName(about)}: ${pending.map(({ tag }) => tag).join(\", \")} on ${environment}`,\n run: () =>\n codeHost.comment(\n about,\n releaseComment({ about, releases: pending, environment, mention }),\n ),\n },\n ];\n });\n};\n\n/** Tells every PR the shipped versions hold, and every issue they relate to, that they are out: one comment per PR or issue, each tag and environment once. */\nexport const releaseComments = ({\n codeHost,\n sourceControl,\n apps,\n}: ReleaseCommentsOptions): Feature => ({\n type: \"feature\",\n name: \"release-comments\",\n adapters: [codeHost, sourceControl],\n options: apps ? { apps } : {},\n requirements: () => [\n ...(codeHost.requirements?.() ?? []),\n ...(sourceControl.requirements?.() ?? []),\n ],\n afterShip: async (context, shipped) => {\n const picked = shipped.filter(({ unit }) => !apps || apps.includes(unit.name));\n if (picked.length === 0) return [];\n const host = context.open(codeHost);\n const tags = await context.open(sourceControl).tags();\n return followUpsOf(host, context, tags, picked);\n },\n});\n","import type { CodeHostPort, SourceControlPort } from \"shiplane\";\nimport type { CatalogEntry } from \"shiplane/plugin\";\nimport { z } from \"shiplane\";\nimport { adapterEntry, featureEntry, serviceIn } from \"shiplane/plugin\";\n\nimport { gitHubActionsCiPipeline } from \"./github-actions-ci-pipeline.adapter\";\nimport { gitHubCodeHost } from \"./github-code-host.adapter\";\nimport { releaseComments } from \"./release-comments.feature\";\n\n/**\n * What a shiplane.yml names from this plugin: `codeHost: github`, `ciPipeline: github-actions`,\n * and the `release-comments` feature.\n */\nexport const catalog: readonly CatalogEntry[] = [\n adapterEntry({\n name: \"github\",\n port: \"codeHost\",\n description: \"Pull requests, releases and deploy records on GitHub, through the gh CLI\",\n options: z.object({}),\n make: () => gitHubCodeHost(),\n }),\n adapterEntry({\n name: \"github-actions\",\n port: \"ciPipeline\",\n description: \"Ships through a GitHub Actions workflow, through the gh CLI\",\n options: z.object({\n shipWorkflow: z\n .string()\n .optional()\n .describe(\"The workflow a ship through CI dispatches: ship.yml by default\"),\n }),\n make: (options) => gitHubActionsCiPipeline(options),\n }),\n featureEntry({\n name: \"release-comments\",\n description: \"Comments on each pull request and issue a ship releases\",\n options: z.object({\n apps: z\n .array(z.string())\n .optional()\n .describe(\"The apps whose ships comment; every app when absent\"),\n }),\n slots: {\n codeHost: { port: \"codeHost\" },\n sourceControl: { port: \"sourceControl\" },\n },\n make: ({ apps }, { codeHost, sourceControl }) => {\n if (!codeHost || !sourceControl) {\n throw new Error(\"release-comments needs a codeHost and a sourceControl\");\n }\n return releaseComments({\n codeHost: serviceIn<CodeHostPort>(codeHost),\n sourceControl: serviceIn<SourceControlPort>(sourceControl),\n ...(apps ? { apps } : {}),\n });\n },\n }),\n];\n"],"mappings":";;;AAIA,MAAM,eAAe;AAErB,MAAM,sBAAsB;CAAC;CAAO;CAAO;CAAO;CAAO;;AAGzD,MAAa,iBAA8B;CACzC,OAAO;CACP,OAAO;EAAE,SAAS;EAAM,MAAM,CAAC,QAAQ,SAAS;EAAE;CAClD,KAAK;EAAE,SAAS;EAAM,MAAM,CAAC,QAAQ,QAAQ;EAAE;CAE/C,SAAS,CAAC,WAAW;CACtB;AAED,MAAa,SAAS,OAAe,IAAI,SAAe,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;AAM5F,MAAa,SAAS,EACpB,MACA,OACA,OAAO,YAKH;CACJ,MAAM,OAAO,OAAO,MAAgB,UAAmB;EACrD,MAAM,SAAS,MAAM,SAAS;GAC5B,WAAW,MAAM,QAAQ,MAAM,MAAM;IAAE,KAAK;IAAM;IAAO,CAAC;GAC1D,YAAY,EAAE,QAAQ,aAAa,WAAW,KAAK,aAAa,KAAK,OAAO;GAC5E,QAAQ;GACR;GACD,CAAC;AACF,MAAI,OAAO,WAAW,EAAG,QAAO,OAAO;EACvC,MAAM,SAAS,UAAU,OAAO,OAAO;AACvC,QAAM,IAAI,MACR,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,eAAe,OAAO,SAAS,SAAS,KAAK,WAAW,KAC1F;;CAEH,MAAM,OAAO,OAAO,SAAqC,KAAK,MAAM,MAAM,KAAK,KAAK,CAAC;AACrF,QAAO;EAAE;EAAM;EAAM;;;;ACzCvB,MAAM,gBAAgB,EAAE,MACtB,EAAE,OAAO;CACP,QAAQ,EAAE,QAAQ;CAClB,KAAK,EAAE,QAAQ;CACf,aAAa,EAAE,QAAQ;CACvB,YAAY,EAAE,QAAQ;CACvB,CAAC,CACH;AACD,MAAM,WAAW,EAAE,OAAO;CAAE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EACN,aAAa;EACb,SAASA,IAAE,OAAO,EAAE,CAAC;EACrB,YAAY,gBAAgB;EAC7B,CAAC;CACF,aAAa;EACX,MAAM;EACN,MAAM;EACN,aAAa;EACb,SAASA,IAAE,OAAO,EAChB,cAAcA,IACX,QAAQ,CACR,UAAU,CACV,SAAS,iEAAiE,EAC9E,CAAC;EACF,OAAO,YAAY,wBAAwB,QAAQ;EACpD,CAAC;CACF,aAAa;EACX,MAAM;EACN,aAAa;EACb,SAASA,IAAE,OAAO,EAChB,MAAMA,IACH,MAAMA,IAAE,QAAQ,CAAC,CACjB,UAAU,CACV,SAAS,sDAAsD,EACnE,CAAC;EACF,OAAO;GACL,UAAU,EAAE,MAAM,YAAY;GAC9B,eAAe,EAAE,MAAM,iBAAiB;GACzC;EACD,OAAO,EAAE,QAAQ,EAAE,UAAU,oBAAoB;AAC/C,OAAI,CAAC,YAAY,CAAC,cAChB,OAAM,IAAI,MAAM,wDAAwD;AAE1E,UAAO,gBAAgB;IACrB,UAAU,UAAwB,SAAS;IAC3C,eAAe,UAA6B,cAAc;IAC1D,GAAI,OAAO,EAAE,MAAM,GAAG,EAAE;IACzB,CAAC;;EAEL,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shiplane/github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-nightly.3",
|
|
4
4
|
"description": "GitHub plugin for shiplane: release PRs, GitHub Releases, deployment records and the ship workflow on Actions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shiplane",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"prettier": "^3.10.1",
|
|
38
38
|
"typescript": "6.0.3",
|
|
39
39
|
"vitest": "^5.1.0",
|
|
40
|
-
"shiplane": "0.
|
|
40
|
+
"shiplane": "0.6.0-nightly.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"shiplane": "0.
|
|
43
|
+
"shiplane": "0.6.0-nightly.3"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsdown",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"format": "prettier --write . --cache --cache-location .cache/.prettiercache",
|
|
49
49
|
"lint": "eslint --cache --cache-location .cache/.eslintcache",
|
|
50
50
|
"test": "vitest run",
|
|
51
|
+
"test:mutate": "stryker run ../../stryker.config.mjs",
|
|
51
52
|
"typecheck": "tsc -p tsconfig.typecheck.json"
|
|
52
53
|
}
|
|
53
54
|
}
|