-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.test.ts
More file actions
107 lines (95 loc) · 3.67 KB
/
Copy pathverify.test.ts
File metadata and controls
107 lines (95 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import {
assertPublishManifest,
rewriteExportTargets,
rewriteWorkspaceDependencies,
} from "./release/package-manifest.ts";
import { profileSteps, resolveComparisonBase, verificationProfiles } from "./verify.ts";
describe("verification profiles", () => {
test("architecture checks ignore generated distribution trees", async () => {
const packageJson = await Bun.file(new URL("../package.json", import.meta.url)).json();
expect(packageJson.scripts["check:architecture:deps"]).toContain("--exclude '(^|/)dist/'");
});
test("release is full plus artifact checks", () => {
expect(profileSteps("release")).toEqual([
...profileSteps("full"),
"build-packages",
"publish-dry-run",
"package-smoke",
]);
});
test("every profile is non-empty and contains no duplicate steps", () => {
for (const steps of Object.values(verificationProfiles)) {
expect(steps.length).toBeGreaterThan(0);
expect(new Set(steps).size).toBe(steps.length);
}
});
test("full is the complete CI gate", () => {
expect(profileSteps("full")).toEqual([
"lint",
"lint-changed",
"typecheck",
"architecture",
"audit",
"test",
"build-webui",
]);
});
test("rejects an explicit BASE that is not a commit", () => {
expect(() => resolveComparisonBase("not-a-real-commit", false)).toThrow("is not a commit");
});
test("falls back when a push base disappeared after a GitHub history rewrite", () => {
expect(resolveComparisonBase("not-a-real-commit", true)).toBeTruthy();
});
});
describe("publish manifest", () => {
test("rewrites nested Bun export conditions to built artifacts", () => {
const exports = {
".": { bun: "./src/index.ts", types: "./dist/index.d.ts", import: "./dist/index.js" },
"./events": { bun: "./src/events.ts", import: "./dist/events.js" },
};
const resolve = (target: string) => target.replace("./src/", "./dist/").replace(/\.ts$/, ".js");
expect(rewriteExportTargets(exports, resolve)).toEqual({
".": { bun: "./dist/index.js", types: "./dist/index.d.ts", import: "./dist/index.js" },
"./events": { bun: "./dist/events.js", import: "./dist/events.js" },
});
});
test("rejects missing or unpacked manifest targets", () => {
expect(() =>
assertPublishManifest({ files: ["dist"], exports: { bun: "./src/index.ts" } }, () => false, "fixture"),
).toThrow("does not exist");
expect(() =>
assertPublishManifest({ files: ["dist"], exports: { bun: "./src/index.ts" } }, () => true, "fixture"),
).toThrow("excluded by package.json files");
});
test("rewrites workspace protocols to publishable package versions", () => {
const manifest = {
dependencies: { "@openagentpack/sdk": "workspace:*" },
peerDependencies: { "@openagentpack/playbooks": "workspace:^" },
};
rewriteWorkspaceDependencies(
manifest,
new Map([
["@openagentpack/sdk", "1.0.1-beta.5"],
["@openagentpack/playbooks", "1.0.1-beta.3"],
]),
);
expect(manifest).toEqual({
dependencies: { "@openagentpack/sdk": "1.0.1-beta.5" },
peerDependencies: { "@openagentpack/playbooks": "^1.0.1-beta.3" },
});
});
test("rejects workspace protocols left in a published manifest", () => {
expect(() =>
assertPublishManifest({ dependencies: { "@openagentpack/sdk": "workspace:*" } }, () => true, "fixture"),
).toThrow("still uses 'workspace:*'");
});
});
describe("public dependency resolution", () => {
test("lockfile contains no private registry URLs", () => {
const lockfile = readFileSync(resolve(import.meta.dirname, "../bun.lock"), "utf8");
expect(lockfile).not.toContain(["registry", "anpm", "alibaba-inc", "com"].join("."));
});
});