Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/size-history-ci-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
44 changes: 44 additions & 0 deletions docs/src/content/docs/guides/performance-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,50 @@ bun run --filter @sheetwrite/bench bench:formula
<p class="size-history__intro">Registry measurements for every published release. Each delta is measured against the release immediately before it.</p>
<details class="size-history__release" data-current="true" open>
<summary class="size-history__release-head">
<span class="size-history__version-step"><span>v0.3.0</span><svg class="size-history__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9M9 4.5 12.5 8 9 11.5"/></svg><strong>v0.3.1</strong></span>
<time datetime="2026-07-23T17:11:35.485Z">Measured Jul 23, 2026</time>
<svg class="size-history__fold" viewBox="0 0 16 16" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg>
</summary>
<div class="size-history__table-wrap">
<table class="size-history__table">
<thead><tr><th scope="col">Package</th><th scope="col">Tarball</th><th scope="col">Installed</th></tr></thead>
<tbody>
<tr>
<th scope="row"><code>@sheetwrite/wasm</code></th>
<td>287.6 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
<td>795.6 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
</tr>
<tr>
<th scope="row"><code>@sheetwrite/core</code></th>
<td>517.4 KiB<small data-direction="increase"><span>+11 B</span><span>+0.0%</span></small></td>
<td>2.71 MiB<small data-direction="increase"><span>+24 B</span><span>+0.0%</span></small></td>
</tr>
<tr>
<th scope="row"><code>@sheetwrite/xlsx</code></th>
<td>85.5 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
<td>429.6 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
</tr>
<tr>
<th scope="row"><code>@sheetwrite/react</code></th>
<td>9.2 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
<td>31.9 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
</tr>
<tr>
<th scope="row"><code>@sheetwrite/vue</code></th>
<td>10.1 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
<td>35.7 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
</tr>
<tr>
<th scope="row"><code>@sheetwrite/svelte</code></th>
<td>6.2 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
<td>18.5 KiB<small data-direction="flat"><span>0 B</span><span>+0.0%</span></small></td>
</tr>
</tbody>
</table>
</div>
</details>
<details class="size-history__release">
<summary class="size-history__release-head">
<span class="size-history__version-step"><span>v0.2.0</span><svg class="size-history__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9M9 4.5 12.5 8 9 11.5"/></svg><strong>v0.3.0</strong></span>
<time datetime="2026-07-23T15:20:59.199Z">Measured Jul 23, 2026</time>
<svg class="size-history__fold" viewBox="0 0 16 16" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg>
Expand Down
55 changes: 55 additions & 0 deletions scripts/changeset-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,52 @@ import { PUBLISHABLE_PACKAGE_ORDER } from "./workspace-tooling.js";

const STABLE_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
const REPOSITORY_ROOT = resolve(import.meta.dir, "..");
const PACKAGE_SIZE_HISTORY_PREFIX = "automation/package-size-history-";
const REQUIRED_PACKAGE_SIZE_HISTORY_FILES = new Set([
"docs/src/content/docs/guides/performance-resources.md",
"scripts/size-history.json",
]);
const ALLOWED_PACKAGE_SIZE_HISTORY_FILES = new Set([
...REQUIRED_PACKAGE_SIZE_HISTORY_FILES,
"docs/src/generated/docs-contract.json",
]);

export function releaseVersionFromHeadRef(headRef: string | undefined): string | undefined {
return headRef !== undefined && STABLE_VERSION.test(headRef) ? headRef : undefined;
}
export function packageSizeHistoryVersionFromHeadRef(
headRef: string | undefined,
): string | undefined {
if (headRef === undefined || !headRef.startsWith(PACKAGE_SIZE_HISTORY_PREFIX)) return undefined;
const version = headRef.slice(PACKAGE_SIZE_HISTORY_PREFIX.length);
return STABLE_VERSION.test(version) ? version : undefined;
}
export function isGeneratedPackageSizeHistoryChange(paths: readonly string[]): boolean {
const uniquePaths = new Set(paths);
return (
uniquePaths.size === paths.length &&
[...REQUIRED_PACKAGE_SIZE_HISTORY_FILES].every((path) => uniquePaths.has(path)) &&
paths.every((path) => ALLOWED_PACKAGE_SIZE_HISTORY_FILES.has(path))
);
}

async function changedFilesSinceDevelop(): Promise<string[]> {
const child = Bun.spawn(["git", "diff", "--name-only", "origin/develop...HEAD"], {
cwd: REPOSITORY_ROOT,
stdout: "pipe",
stderr: "pipe",
});
const [stdout, stderr, exitCode] = await Promise.all([
new Response(child.stdout).text(),
new Response(child.stderr).text(),
child.exited,
]);
if (exitCode !== 0) throw new Error(`Unable to inspect package size history diff: ${stderr}`);
return stdout
.split("\n")
.map((path) => path.trim())
.filter((path) => path.length > 0);
}

export function validateReleasePackageVersions(version: string, root = REPOSITORY_ROOT): void {
for (const name of PUBLISHABLE_PACKAGE_ORDER) {
Expand All @@ -30,6 +72,19 @@ async function main(): Promise<void> {
console.log(`Release package versions match branch ${releaseVersion}`);
return;
}
const packageSizeHistoryVersion = packageSizeHistoryVersionFromHeadRef(
process.env.GITHUB_HEAD_REF,
);
if (packageSizeHistoryVersion !== undefined) {
validateReleasePackageVersions(packageSizeHistoryVersion);
if (isGeneratedPackageSizeHistoryChange(await changedFilesSinceDevelop())) {
console.log(`Package size history versions match branch ${packageSizeHistoryVersion}`);
return;
}
console.log(
"Package size history branch contains non-generated changes; requiring a changeset",
);
}
const child = Bun.spawn(["bun", "run", "changeset:status", "--", "--since=origin/develop"], {
cwd: REPOSITORY_ROOT,
stdin: "inherit",
Expand Down
79 changes: 79 additions & 0 deletions scripts/size-history.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,85 @@
"unit": "count"
}
}
},
{
"version": "0.3.1",
"capturedAt": "2026-07-23T17:11:35.485Z",
"source": "npm registry published artifacts",
"metrics": {
"package.@sheetwrite/wasm.tarballBytes": {
"actual": 294455,
"unit": "bytes"
},
"package.@sheetwrite/wasm.unpackedBytes": {
"actual": 814645,
"unit": "bytes"
},
"package.@sheetwrite/wasm.fileCount": {
"actual": 12,
"unit": "count"
},
"package.@sheetwrite/core.tarballBytes": {
"actual": 529843,
"unit": "bytes"
},
"package.@sheetwrite/core.unpackedBytes": {
"actual": 2846784,
"unit": "bytes"
},
"package.@sheetwrite/core.fileCount": {
"actual": 335,
"unit": "count"
},
"package.@sheetwrite/xlsx.tarballBytes": {
"actual": 87523,
"unit": "bytes"
},
"package.@sheetwrite/xlsx.unpackedBytes": {
"actual": 439871,
"unit": "bytes"
},
"package.@sheetwrite/xlsx.fileCount": {
"actual": 59,
"unit": "count"
},
"package.@sheetwrite/react.tarballBytes": {
"actual": 9398,
"unit": "bytes"
},
"package.@sheetwrite/react.unpackedBytes": {
"actual": 32679,
"unit": "bytes"
},
"package.@sheetwrite/react.fileCount": {
"actual": 8,
"unit": "count"
},
"package.@sheetwrite/vue.tarballBytes": {
"actual": 10354,
"unit": "bytes"
},
"package.@sheetwrite/vue.unpackedBytes": {
"actual": 36578,
"unit": "bytes"
},
"package.@sheetwrite/vue.fileCount": {
"actual": 8,
"unit": "count"
},
"package.@sheetwrite/svelte.tarballBytes": {
"actual": 6354,
"unit": "bytes"
},
"package.@sheetwrite/svelte.unpackedBytes": {
"actual": 18919,
"unit": "bytes"
},
"package.@sheetwrite/svelte.fileCount": {
"actual": 10,
"unit": "count"
}
}
}
]
}
41 changes: 40 additions & 1 deletion scripts/workspace-tooling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { afterEach, describe, expect, it } from "bun:test";
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { releaseVersionFromHeadRef, validateReleasePackageVersions } from "./changeset-ci.js";
import {
isGeneratedPackageSizeHistoryChange,
packageSizeHistoryVersionFromHeadRef,
releaseVersionFromHeadRef,
validateReleasePackageVersions,
} from "./changeset-ci.js";
import {
assertUniqueOrderedNodes,
PACKAGE_BUILD_NODES,
Expand Down Expand Up @@ -246,6 +251,40 @@ describe("changeset workspace contract", () => {
it("runs the release-aware Changesets status command", () => {
expect(releaseVersionFromHeadRef("0.3.1")).toBe("0.3.1");
expect(releaseVersionFromHeadRef("feature/docs")).toBeUndefined();
expect(packageSizeHistoryVersionFromHeadRef("automation/package-size-history-0.3.1")).toBe(
"0.3.1",
);
expect(packageSizeHistoryVersionFromHeadRef("automation/package-size-history-next")).toBe(
undefined,
);
expect(
isGeneratedPackageSizeHistoryChange([
"docs/src/content/docs/guides/performance-resources.md",
"scripts/size-history.json",
]),
).toBeTrue();
expect(
isGeneratedPackageSizeHistoryChange([
"docs/src/content/docs/guides/performance-resources.md",
"docs/src/generated/docs-contract.json",
"scripts/size-history.json",
]),
).toBeTrue();
expect(
isGeneratedPackageSizeHistoryChange([
"docs/src/content/docs/guides/performance-resources.md",
"scripts/changeset-ci.ts",
"scripts/size-history.json",
]),
).toBeFalse();
expect(isGeneratedPackageSizeHistoryChange(["scripts/size-history.json"])).toBeFalse();
expect(
isGeneratedPackageSizeHistoryChange([
"docs/src/content/docs/guides/performance-resources.md",
"scripts/size-history.json",
"scripts/size-history.json",
]),
).toBeFalse();
expect(() => validateReleasePackageVersions("0.3.1")).not.toThrow();
expect(() => validateReleasePackageVersions("0.3.2")).toThrow(
"Release branch 0.3.2 requires @sheetwrite/wasm@0.3.2",
Expand Down
Loading