@decohere/ci-tools 0.0.1-dev.9 → 0.0.1-dev.90
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/package.json +8 -2
- package/src/audit/enforce.mjs +7 -5
- package/src/audit/format.mjs +133 -0
- package/src/audit/summarize.mjs +10 -32
- package/src/audit/upsert-clickup.mjs +117 -0
- package/src/audit/upsert-issue.mjs +22 -37
- package/src/bench/bench.mjs +1 -1
- package/src/bench/trace.mjs +1 -1
- package/src/github/credential-nudge.mjs +320 -0
- package/src/github/oidc-bootstrap-nudge.mjs +368 -0
- package/src/github/publish-verify.mjs +209 -0
- package/src/github/smoke-create-launcher.mjs +70 -0
- package/src/release/sync-dependencies.mjs +1 -2
- package/tests/audit/format.test.mjs +115 -0
- package/tests/github/credential-nudge.test.mjs +65 -0
- package/tests/github/oidc-bootstrap-nudge.test.mjs +104 -0
- package/tests/github/publish-verify.test.mjs +95 -0
- package/tests/github/smoke-create-launcher.test.mjs +71 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { runCreateLauncherSmoke } from "../../src/github/smoke-create-launcher.mjs";
|
|
4
|
+
|
|
5
|
+
const fs = await vi.importActual("node:fs");
|
|
6
|
+
const PUBLISH_YML = fileURLToPath(
|
|
7
|
+
new URL("../../../../.github/workflows/publish.yml", import.meta.url),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
describe("runCreateLauncherSmoke", () => {
|
|
11
|
+
it("execs npx from a temp directory, not the repo root", () => {
|
|
12
|
+
/** @type {{ cmd: string, args: string[], opts: { cwd?: string } }[]} */
|
|
13
|
+
const calls = [];
|
|
14
|
+
const written = [];
|
|
15
|
+
|
|
16
|
+
const result = runCreateLauncherSmoke({
|
|
17
|
+
createVersion: "0.0.1-dev.80",
|
|
18
|
+
authToken: "tok",
|
|
19
|
+
tmpdir: () => "/tmp",
|
|
20
|
+
mkdtempSync: (prefix) => `${prefix}abc`,
|
|
21
|
+
writeFileSync: (path, body) => {
|
|
22
|
+
written.push({ path, body });
|
|
23
|
+
},
|
|
24
|
+
spawnSync: (cmd, args, opts) => {
|
|
25
|
+
calls.push({ cmd, args, opts });
|
|
26
|
+
return { status: 0 };
|
|
27
|
+
},
|
|
28
|
+
stdio: "pipe",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
expect(result.workDir).toBe("/tmp/decohere-create-smoke-abc");
|
|
32
|
+
expect(result.workDir).not.toBe(process.cwd());
|
|
33
|
+
expect(calls).toHaveLength(1);
|
|
34
|
+
expect(calls[0].cmd).toBe("npx");
|
|
35
|
+
expect(calls[0].args).toEqual(["--yes", "@decohere/create@0.0.1-dev.80", "--help"]);
|
|
36
|
+
expect(calls[0].opts.cwd).toBe("/tmp/decohere-create-smoke-abc");
|
|
37
|
+
expect(calls[0].opts.cwd).not.toBe(process.cwd());
|
|
38
|
+
expect(written).toEqual([
|
|
39
|
+
{
|
|
40
|
+
path: "/tmp/decohere-create-smoke-abc/.npmrc",
|
|
41
|
+
body: "@decohere:registry=https://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=tok\n",
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("fails closed without version or token", () => {
|
|
47
|
+
expect(() => runCreateLauncherSmoke({ createVersion: "", authToken: "tok" })).toThrow(
|
|
48
|
+
"CREATE_VERSION is required",
|
|
49
|
+
);
|
|
50
|
+
expect(() =>
|
|
51
|
+
runCreateLauncherSmoke({ createVersion: "0.0.1-dev.80", authToken: "" }),
|
|
52
|
+
).toThrow("NODE_AUTH_TOKEN is required");
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("publish.yml create smoke + tag", () => {
|
|
57
|
+
const yml = fs.readFileSync(PUBLISH_YML, "utf8");
|
|
58
|
+
|
|
59
|
+
it("wires create smoke through the isolated launcher", () => {
|
|
60
|
+
expect(yml).toContain("node projects/ci-tools/src/github/smoke-create-launcher.mjs");
|
|
61
|
+
expect(yml).toContain("CREATE_VERSION:");
|
|
62
|
+
expect(yml).not.toContain("npx --yes");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("grants the tag job actions:read so publish-prepare can download CI artifacts", () => {
|
|
66
|
+
const tag = yml.slice(yml.indexOf("\n tag:"));
|
|
67
|
+
const perms = tag.slice(tag.indexOf("permissions:"), tag.indexOf("steps:"));
|
|
68
|
+
expect(perms).toMatch(/contents:\s*write/);
|
|
69
|
+
expect(perms).toMatch(/actions:\s*read/);
|
|
70
|
+
});
|
|
71
|
+
});
|