Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci: drop the size-base job; Main keeps every component's sizes and pull requests read the merge base's record (#9164)

Cindy Zhangf0039ff70521
diff --git a/.github/scripts/analyze-pr.js b/.github/scripts/analyze-pr.js
index 1f74842db6..33eea3e118 100644
--- a/.github/scripts/analyze-pr.js
+++ b/.github/scripts/analyze-pr.js
@@ -1,14 +1,17 @@
#!/usr/bin/env node
// Copyright (c) Meta Platforms, Inc. and affiliates.
-
/**
* @description Analyzes PR changes to detect new/modified components and gather stats
- * @input --base <branch> --head <ref> --output <file> [--base-root <dir> [--base-only]] [--force-full]
+ * @input --base <branch> --head <ref> --output <file> [--base-record <file>] [--force-full]
+ * | --main-record --output <file>
* @output JSON file with component analysis; exits non-zero if the base...head diff fails (e.g. shallow clone without a merge base).
- * With --base-root (a built checkout of the merge base), the analysis also
- * records baseComponentStats and baseBundlePackages measured in that tree;
- * --base-only writes just those, with the head and base commits they belong to.
+ * With --base-record (the merge base's record, which Main keeps for each
+ * commit), the analysis also carries baseComponentStats, baseBundlePackages
+ * and baseComponentSizes read from it.
+ * --main-record writes that record for the current built tree: every public
+ * component's import and CSS size, the source modules its bundle reaches and
+ * its entry stats, and every component package's bundle stats.
* A changed module outside every component folder (a shared hook, the
* animator) owns the components whose bundle reaches it, so browser audits
* run for those reverse dependents; one no component reaches, or --force-full
@@ -17,7 +20,7 @@
const fs = require('node:fs');
const path = require('node:path');
-const { execSync } = require('node:child_process');
+const {execSync} = require('node:child_process');
const {
gzipBytes: gzipTextBytes,
measureComponentImport,
@@ -31,10 +34,10 @@ const {
flatPackageComponentNames,
nestedPackageComponentNames,
} = require('../../scripts/component-packages.cjs');
-const { isComponentSpecRecordPath } = require('./knowledge-paths.cjs');
+const {isComponentSpecRecordPath} = require('./knowledge-paths.cjs');
const args = process.argv.slice(2);
-const getArg = (name) => {
+const getArg = name => {
const idx = args.indexOf(`--${name}`);
return idx !== -1 ? args[idx + 1] : null;
};
@@ -42,13 +45,9 @@ const getArg = (name) => {
const baseBranch = getArg('base') || 'main';
const headRef = getArg('head') || 'HEAD';
const outputFile = getArg('output') || 'analysis.json';
-const baseRoot = getArg('base-root');
-const baseOnly = args.includes('--base-only');
+const baseRecordFile = getArg('base-record');
+const mainRecordMode = args.includes('--main-record');
const forceFull = args.includes('--force-full');
-if (baseOnly && !baseRoot) {
- console.error('::error::--base-only needs --base-root');
- process.exit(1);
-}
const STORYBOOK_STORIES = 'apps/storybook/stories';
@@ -62,8 +61,8 @@ const PACKAGES = COMPONENT_PACKAGES.map(pkg => ({
dir: path.dirname(pkg.src),
}));
-const pkgSrc = (pkg) => pkg.src;
-const pkgDist = (pkg) => `${pkg.dir}/dist`;
+const pkgSrc = pkg => pkg.src;
+const pkgDist = pkg => `${pkg.dir}/dist`;
// Get canonical direct public component names for a package. Nested family,
// context, and shared directories deliberately stay unresolved so audits widen.
@@ -75,14 +74,19 @@ function familyMembers(pkg, folder) {
if (!familyIndex.has(pkg.name)) {
familyIndex.set(pkg.name, {
canonical: new Set(nestedPackageComponentNames(process.cwd(), pkg)),
- exports: componentExportsFromBarrel(path.join(sourceDir, 'index.ts'), sourceDir),
+ exports: componentExportsFromBarrel(
+ path.join(sourceDir, 'index.ts'),
+ sourceDir,
+ ),
});
}
- const { canonical, exports } = familyIndex.get(pkg.name);
+ const {canonical, exports} = familyIndex.get(pkg.name);
const directory = path.join(sourceDir, folder);
try {
return documentedComponentNames(directory).filter(
- (name) => canonical.has(name) && exports.get(name)?.startsWith(`${directory}${path.sep}`),
+ name =>
+ canonical.has(name) &&
+ exports.get(name)?.startsWith(`${directory}${path.sep}`),
);
} catch {
return [];
@@ -105,14 +109,17 @@ function folderComponents(pkg, folder, repoRoot = process.cwd()) {
exports:
pkg.layout === 'flat'
? new Map()
- : componentExportsFromBarrel(path.join(sourceDir, 'index.ts'), sourceDir),
+ : componentExportsFromBarrel(
+ path.join(sourceDir, 'index.ts'),
+ sourceDir,
+ ),
});
}
- const { canonical, exports } = folderIndex.get(key);
+ const {canonical, exports} = folderIndex.get(key);
if (pkg.layout === 'flat') return canonical.has(folder) ? [folder] : [];
const directory = path.join(sourceDir, folder);
return [...canonical]
- .filter((name) => {
+ .filter(name => {
const file = exports.get(name);
return file === directory || file?.startsWith(`${directory}${path.sep}`);
})
@@ -192,14 +199,16 @@ function componentIndexRef(pkg, componentName) {
function getChangedFiles() {
const threeDot = `${baseBranch}...${headRef}`;
const tryThreeDot = () => {
- const output = execSync(`git diff --name-only ${threeDot}`, { encoding: 'utf8' });
+ const output = execSync(`git diff --name-only ${threeDot}`, {
+ encoding: 'utf8',
+ });
return output.trim().split('\n').filter(Boolean);
};
try {
- return { files: tryThreeDot(), diffMode: 'three-dot' };
+ return {files: tryThreeDot(), diffMode: 'three-dot'};
} catch (e) {
console.warn(
- `::warning::three-dot diff ${threeDot} failed - attempting to deepen the clone and retry`
+ `::warning::three-dot diff ${threeDot} failed - attempting to deepen the clone and retry`,
);
console.warn(diffErrorDetail(e));
}
@@ -215,12 +224,12 @@ function getChangedFiles() {
const baseName = baseBranch.replace(/^origin\//, '');
execSync(
`git fetch --deepen=200 origin ${baseName}:refs/remotes/origin/${baseName}`,
- { encoding: 'utf8', stdio: 'pipe' },
+ {encoding: 'utf8', stdio: 'pipe'},
);
- return { files: tryThreeDot(), diffMode: 'three-dot' };
+ return {files: tryThreeDot(), diffMode: 'three-dot'};
} catch (e) {
console.warn(
- `::warning::deepen failed (${diffErrorDetail(e)}) - falling back to two-dot diff`
+ `::warning::deepen failed (${diffErrorDetail(e)}) - falling back to two-dot diff`,
);
}
@@ -230,14 +239,21 @@ function getChangedFiles() {
// with diffMode: 'two-dot' for any consumer to caveat.
const twoDot = `${baseBranch}..${headRef}`;
try {
- const output = execSync(`git diff --name-only ${twoDot}`, { encoding: 'utf8' });
- return { files: output.trim().split('\n').filter(Boolean), diffMode: 'two-dot' };
+ const output = execSync(`git diff --name-only ${twoDot}`, {
+ encoding: 'utf8',
+ });
+ return {
+ files: output.trim().split('\n').filter(Boolean),
+ diffMode: 'two-dot',
+ };
} catch (e) {
// A failed diff (e.g. base ref missing on a too-shallow clone) is not the
// same as "no changes" — fail loudly instead of publishing an empty
// analysis report that looks legitimate.
console.error(`::error::git diff ${twoDot} failed: ${e.message}`);
- console.error('The clone is likely too shallow to contain the base ref (see fetch-depth in ci.yml).');
+ console.error(
+ 'The clone is likely too shallow to contain the base ref (see fetch-depth in ci.yml).',
+ );
process.exit(1);
}
}
@@ -252,10 +268,13 @@ function diffErrorDetail(e) {
// Check if a component exists in the base branch.
function componentExistsInBase(pkg, componentName) {
try {
- execSync(`git show ${baseBranch}:${componentIndexRef(pkg, componentName)}`, {
- encoding: 'utf8',
- stdio: 'pipe',
- });
+ execSync(
+ `git show ${baseBranch}:${componentIndexRef(pkg, componentName)}`,
+ {
+ encoding: 'utf8',
+ stdio: 'pipe',
+ },
+ );
return true;
} catch {
// A nested component folder without an index barrel still exists in base.
@@ -263,7 +282,7 @@ function componentExistsInBase(pkg, componentName) {
try {
const listing = execSync(
`git ls-tree --name-only ${baseBranch} -- ${pkgSrc(pkg)}/${componentName}/`,
- { encoding: 'utf8', stdio: 'pipe' },
+ {encoding: 'utf8', stdio: 'pipe'},
);
return listing.trim().length > 0;
} catch {
@@ -277,7 +296,7 @@ function parseExportsFromSource(content) {
const exports = [];
for (const match of exportMatches) {
const inner = match.replace(/export\s*{\s*/, '').replace(/\s*}/, '');
- exports.push(...inner.split(',').map((e) => e.trim().split(' ')[0]));
+ exports.push(...inner.split(',').map(e => e.trim().split(' ')[0]));
}
if (content.includes('export default')) {
exports.push('default');
@@ -290,7 +309,7 @@ function getBaseExports(pkg, componentName) {
try {
const content = execSync(
`git show ${baseBranch}:${componentIndexRef(pkg, componentName)}`,
- { encoding: 'utf8', stdio: 'pipe' }
+ {encoding: 'utf8', stdio: 'pipe'},
);
return parseExportsFromSource(content);
} catch {
@@ -324,7 +343,9 @@ function getFileSizeBytes(filePath) {
function getGzipBytes(filePath) {
if (!filePath || !fs.existsSync(filePath)) return null;
try {
- const output = execSync(`gzip -c "${filePath}" | wc -c`, { encoding: 'utf8' });
+ const output = execSync(`gzip -c "${filePath}" | wc -c`, {
+ encoding: 'utf8',
+ });
const bytes = parseInt(output.trim(), 10);
return Number.isFinite(bytes) && bytes > 0 ? bytes : null;
} catch {
@@ -355,7 +376,7 @@ function packageIsModule(pkg) {
// as `index.mjs` and CommonJS as `index.js`. `index.mjs`/`index.cjs` are ESM
// and CommonJS wherever they exist. A missing file is never measured.
function resolveEntries(distDir, pkg) {
- const existing = (name) => {
+ const existing = name => {
const file = path.join(distDir, name);
return fs.existsSync(file) ? file : null;
};
@@ -384,11 +405,13 @@ function getExports(pkg, componentName) {
function componentSourceFiles(pkg, componentName) {
if (pkg.layout === 'flat') {
const file = componentSrcPath(pkg, componentName);
- return fs.existsSync(file) ? [{ dir: path.dirname(file), name: path.basename(file) }] : [];
+ return fs.existsSync(file)
+ ? [{dir: path.dirname(file), name: path.basename(file)}]
+ : [];
}
const dir = componentSrcPath(pkg, componentName);
try {
- return fs.readdirSync(dir).map((name) => ({ dir, name }));
+ return fs.readdirSync(dir).map(name => ({dir, name}));
} catch {
return [];
}
@@ -399,11 +422,13 @@ function getPropsCount(pkg, componentName) {
const files = componentSourceFiles(pkg, componentName);
if (files.length === 0) return null;
// Prefer the file named after the component (bare or XDS-prefixed).
- const names = files.map((f) => f.name);
+ const names = files.map(f => f.name);
const mainName =
- [`XDS${componentName}.tsx`, `${componentName}.tsx`].find((f) => names.includes(f)) ||
+ [`XDS${componentName}.tsx`, `${componentName}.tsx`].find(f =>
+ names.includes(f),
+ ) ||
names.find(
- (f) =>
+ f =>
(/^XDS[A-Z]\w+\.tsx$/.test(f) || /^[A-Z]\w+\.tsx$/.test(f)) &&
!f.includes('.test.') &&
!f.includes('Context.'),
@@ -411,12 +436,14 @@ function getPropsCount(pkg, componentName) {
if (!mainName) return null;
try {
const content = fs.readFileSync(path.join(files[0].dir, mainName), 'utf8');
- const propsMatch = content.match(/(?:type|interface)\s+\w*Props\w*\s*=?\s*{([^}]+)}/);
+ const propsMatch = content.match(
+ /(?:type|interface)\s+\w*Props\w*\s*=?\s*{([^}]+)}/,
+ );
if (propsMatch) {
return propsMatch[1]
.split('\n')
.filter(
- (line) =>
+ line =>
line.trim() &&
!line.trim().startsWith('//') &&
!line.trim().startsWith('*') &&
@@ -432,7 +459,7 @@ function getPropsCount(pkg, componentName) {
// Check if component has tests
function hasTests(pkg, componentName) {
return componentSourceFiles(pkg, componentName).some(
- (f) => f.name.endsWith('.test.ts') || f.name.endsWith('.test.tsx'),
+ f => f.name.endsWith('.test.ts') || f.name.endsWith('.test.tsx'),
);
}
@@ -443,17 +470,20 @@ function hasStories(pkg, componentName) {
const files = fs.readdirSync(storiesDir);
if (
files.some(
- (f) =>
- f.toLowerCase().includes(componentName.toLowerCase()) && f.endsWith('.stories.tsx'),
+ f =>
+ f.toLowerCase().includes(componentName.toLowerCase()) &&
+ f.endsWith('.stories.tsx'),
)
)
return true;
const exports = getExports(pkg, componentName);
- const xdsComponents = exports.filter((e) => e.startsWith('XDS'));
- return xdsComponents.some((comp) => {
+ const xdsComponents = exports.filter(e => e.startsWith('XDS'));
+ return xdsComponents.some(comp => {
const name = comp.replace(/^XDS/, '');
return files.some(
- (f) => f.toLowerCase().includes(name.toLowerCase()) && f.endsWith('.stories.tsx'),
+ f =>
+ f.toLowerCase().includes(name.toLowerCase()) &&
+ f.endsWith('.stories.tsx'),
);
});
} catch {
@@ -469,23 +499,30 @@ function getStoryTitle(pkg, componentName) {
const exports = getExports(pkg, componentName);
const searchNames = [
componentName,
- ...exports.filter((e) => e.startsWith('XDS')).map((e) => e.replace(/^XDS/, '')),
+ ...exports
+ .filter(e => e.startsWith('XDS'))
+ .map(e => e.replace(/^XDS/, '')),
];
const storyFiles = files.filter(
- (f) =>
+ f =>
f.endsWith('.stories.tsx') &&
- searchNames.some((name) => f.toLowerCase().includes(name.toLowerCase())),
+ searchNames.some(name => f.toLowerCase().includes(name.toLowerCase())),
);
if (storyFiles.length === 0) return null;
- const exactMatch = storyFiles.find((f) =>
- searchNames.some((name) => f.toLowerCase() === `${name.toLowerCase()}.stories.tsx`),
+ const exactMatch = storyFiles.find(f =>
+ searchNames.some(
+ name => f.toLowerCase() === `${name.toLowerCase()}.stories.tsx`,
+ ),
);
const orderedFiles = exactMatch
- ? [exactMatch, ...storyFiles.filter((f) => f !== exactMatch)]
+ ? [exactMatch, ...storyFiles.filter(f => f !== exactMatch)]
: storyFiles;
const titles = orderedFiles
- .map((storyFile) => {
- const content = fs.readFileSync(path.join(storiesDir, storyFile), 'utf8');
+ .map(storyFile => {
+ const content = fs.readFileSync(
+ path.join(storiesDir, storyFile),
+ 'utf8',
+ );
const titleMatch = content.match(/title:\s*['"]([^'"]+)['"]/);
return titleMatch ? titleMatch[1] : null;
})
@@ -533,7 +570,7 @@ function getComponentLOC(pkg, componentName) {
totalLOC += countLOC(path.join(f.dir, f.name));
fileCount++;
}
- return { totalLOC, fileCount };
+ return {totalLOC, fileCount};
}
// Calculate cyclomatic complexity (simplified - counts decision points)
@@ -568,9 +605,9 @@ function getComplexity(pkg, componentName) {
else if (complexity <= 15) rating = 'Medium';
else if (complexity <= 30) rating = 'High';
else rating = 'Very High';
- return { score: complexity, rating };
+ return {score: complexity, rating};
} catch {
- return { score: 0, rating: 'Unknown' };
+ return {score: 0, rating: 'Unknown'};
}
}
@@ -579,7 +616,8 @@ const stylesheetCache = new Map();
function packageStylesheet(pkg) {
const file = packageStylesheetPath(path.join(process.cwd(), pkg.dir));
if (!file) return null;
- if (!stylesheetCache.has(file)) stylesheetCache.set(file, fs.readFileSync(file, 'utf8'));
+ if (!stylesheetCache.has(file))
+ stylesheetCache.set(file, fs.readFileSync(file, 'utf8'));
return stylesheetCache.get(file);
}
@@ -587,7 +625,7 @@ function packageStylesheet(pkg) {
// defines its export.
function packageTargets(pkg) {
if (pkg.layout === 'flat') {
- return getComponentNames(pkg).map((name) => ({
+ return getComponentNames(pkg).map(name => ({
key: `${pkg.packageName}/${name}`,
pkg,
name,
@@ -595,7 +633,10 @@ function packageTargets(pkg) {
}));
}
const sourceDir = path.join(process.cwd(), pkgSrc(pkg));
- const exports = componentExportsFromBarrel(path.join(sourceDir, 'index.ts'), sourceDir);
+ const exports = componentExportsFromBarrel(
+ path.join(sourceDir, 'index.ts'),
+ sourceDir,
+ );
const targets = [];
for (const name of nestedPackageComponentNames(process.cwd(), pkg)) {
const file = exports.get(name);
@@ -617,67 +658,94 @@ function packageTargets(pkg) {
// collects each changed source path some component reaches (its folder, or a
// module in its bundle) in `paths`, and in `measured` each package whose
// bundles could be read: there, a module no bundle holds reaches nothing.
-function sizeTargets(changedFiles, reached = null) {
- const withoutExtension = (file) => file.replace(/\.(tsx?|jsx?|mjs)$/, '');
- // Each package's changed modules, and its built dist to find them in: a
- // bundle in any package can reach them (Lab, Charts, Rich Text and Vega
- // import Core).
- const changed = [];
- for (const pkg of PACKAGES) {
- const prefix = pkgSrc(pkg) + '/';
- const changedModules = new Set(
- changedFiles
- .filter((file) => file.startsWith(prefix))
- .map((file) => withoutExtension(file.slice(prefix.length))),
- );
- if (changedModules.size === 0) continue;
+const withoutExtension = file => file.replace(/\.(tsx?|jsx?|mjs)$/, '');
+
+// Each package's dist by real path (esbuild reports bundle inputs by real
+// path), to map a bundle input back to its source module.
+function distRealPaths() {
+ return PACKAGES.map(pkg => {
const dist = path.join(process.cwd(), pkgDist(pkg));
- changed.push({
- pkg,
- prefix,
- changedModules,
- changedTops: new Set([...changedModules].map((file) => file.split('/')[0])),
- // esbuild reports inputs by real path.
- distReal: fs.existsSync(dist) ? fs.realpathSync(dist) : dist,
- });
+ return {pkg, distReal: fs.existsSync(dist) ? fs.realpathSync(dist) : dist};
+ });
+}
+
+// One package's public components in the current built tree, each with the
+// source modules (`src` paths without extension, any package) its bundle
+// reaches; `measured` says whether the package's bundles could be read.
+function componentReach(pkg, dists) {
+ const dist = path.join(process.cwd(), pkgDist(pkg));
+ const all = packageTargets(pkg);
+ const reach = bundleInputsByEntry(
+ all.map(target => path.join(dist, target.distModule)),
+ );
+ const sources = new Map();
+ for (const target of all) {
+ const reached = new Set();
+ for (const input of reach?.get(path.join(dist, target.distModule)) ?? []) {
+ for (const {pkg: owner, distReal} of dists) {
+ const relative = path.relative(distReal, input);
+ if (!relative.startsWith('..') && !path.isAbsolute(relative)) {
+ reached.add(pkgSrc(owner) + '/' + withoutExtension(relative));
+ }
+ }
+ }
+ sources.set(target.key, reached);
}
- if (changed.length === 0) return [];
+ return {all, sources, measured: reach != null && reach.size > 0};
+}
+
+// The one targeting rule for both trees (a built head here, the merge base's
+// record in recordTargets): a component is affected when its own folder or
+// file changed (`ownFolder`), or its bundle reaches a changed source module
+// (`reachedPaths`).
+function affectedBy(target, reachedSources, changedFiles) {
+ const prefix = pkgSrc(target.pkg) + '/';
+ const top = withoutExtension(target.distModule.split('/')[0]);
+ const ownFolder = changedFiles.some(
+ file =>
+ file.startsWith(prefix) &&
+ withoutExtension(file.slice(prefix.length)).split('/')[0] === top,
+ );
+ const changed = new Set(changedFiles.map(withoutExtension));
+ return {
+ ownFolder: ownFolder ? prefix + top : null,
+ reachedPaths: [...(reachedSources ?? [])].filter(source =>
+ changed.has(source),
+ ),
+ };
+}
+
+function sizeTargets(changedFiles, reached = null) {
+ const touches = pkg =>
+ changedFiles.some(file => file.startsWith(pkgSrc(pkg) + '/'));
+ if (!PACKAGES.some(touches)) return [];
+ const dists = distRealPaths();
const targets = [];
for (const pkg of PACKAGES) {
- const own = changed.find((entry) => entry.pkg === pkg) ?? null;
- const dist = path.join(process.cwd(), pkgDist(pkg));
- const all = packageTargets(pkg);
- const reach = bundleInputsByEntry(all.map((target) => path.join(dist, target.distModule)));
+ const {all, sources, measured} = componentReach(pkg, dists);
for (const target of all) {
- const top = withoutExtension(target.distModule.split('/')[0]);
- const inputs = reach?.get(path.join(dist, target.distModule)) ?? [];
- const reachedPaths = inputs.flatMap((input) =>
- changed.flatMap((entry) => {
- const relative = path.relative(entry.distReal, input);
- const module = withoutExtension(relative);
- return !relative.startsWith('..') && entry.changedModules.has(module)
- ? [entry.prefix + module]
- : [];
- }),
+ const {ownFolder, reachedPaths} = affectedBy(
+ target,
+ sources.get(target.key),
+ changedFiles,
);
- const isOwnFolder = own != null && own.changedTops.has(top);
- if (isOwnFolder || reachedPaths.length > 0) targets.push(target);
+ if (ownFolder || reachedPaths.length > 0) targets.push(target);
if (reached != null) {
for (const reachedPath of reachedPaths) reached.paths.add(reachedPath);
- if (isOwnFolder) reached.paths.add(own.prefix + top);
+ if (ownFolder) reached.paths.add(ownFolder);
}
}
- if (reached != null && own != null && reach != null && reach.size > 0) {
- reached.measured.add(own.prefix);
- }
+ if (reached != null && measured && touches(pkg))
+ reached.measured.add(pkgSrc(pkg) + '/');
}
return targets;
}
// Targets from either tree, once each by key.
function unionTargets(first, second) {
- const byKey = new Map(first.map((target) => [target.key, target]));
- for (const target of second) if (!byKey.has(target.key)) byKey.set(target.key, target);
+ const byKey = new Map(first.map(target => [target.key, target]));
+ for (const target of second)
+ if (!byKey.has(target.key)) byKey.set(target.key, target);
return [...byKey.values()];
}
@@ -720,7 +788,9 @@ function getComponentStats(pkg, componentName) {
pkg.layout === 'flat'
? null
: path.join(process.cwd(), pkgDist(pkg), componentName);
- const entries = distDir ? resolveEntries(distDir, pkg) : { esmPath: null, cjsPath: null };
+ const entries = distDir
+ ? resolveEntries(distDir, pkg)
+ : {esmPath: null, cjsPath: null};
const loc = getComponentLOC(pkg, componentName);
const complexity = getComplexity(pkg, componentName);
return {
@@ -744,7 +814,7 @@ function getComponentStats(pkg, componentName) {
// Get total bundle stats for a package's published entry.
function getPackageBundleStats(pkg) {
const distDir = path.join(process.cwd(), pkgDist(pkg));
- const { esmPath, cjsPath } = resolveEntries(distDir, pkg);
+ const {esmPath, cjsPath} = resolveEntries(distDir, pkg);
// Gzip the primary published entry: ESM when it exists, else CommonJS.
const gzipBytes = getGzipBytes(esmPath || cjsPath);
return {
@@ -765,11 +835,13 @@ function getPackageBundleStats(pkg) {
// Main analysis
function analyze() {
console.log(`Analyzing changes from ${baseBranch} to ${headRef}...`);
- const { files: changedFiles, diffMode } = getChangedFiles();
- console.log(`Found ${changedFiles.length} changed files (diff mode: ${diffMode})`);
+ const {files: changedFiles, diffMode} = getChangedFiles();
+ console.log(
+ `Found ${changedFiles.length} changed files (diff mode: ${diffMode})`,
+ );
if (diffMode === 'two-dot') {
console.warn(
- '::warning::using approximate two-dot diff - the file list may include base-only churn and may miss the PR\'s own changes when they also exist on base'
+ "::warning::using approximate two-dot diff - the file list may include base-only churn and may miss the PR's own changes when they also exist on base",
);
}
@@ -786,16 +858,26 @@ function analyze() {
// Stable theme packages are a visual surface of their own. They do not own
// component source dirs, so the component loop below cannot discover them;
// without this, changing a published theme silently skips pr-visual.
- const changedStableThemes = [...new Set(
- changedFiles.flatMap((file) => {
- const match = file.match(/^packages\/themes\/([^/]+)\/src\//);
- if (!match) return [];
- const manifest = path.join(process.cwd(), 'packages', 'themes', match[1], 'package.json');
- if (!fs.existsSync(manifest)) return [];
- const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
- return pkg.private === true || pkg.astryx?.canaryOnly === true ? [] : [match[1]];
- }),
- )].sort();
+ const changedStableThemes = [
+ ...new Set(
+ changedFiles.flatMap(file => {
+ const match = file.match(/^packages\/themes\/([^/]+)\/src\//);
+ if (!match) return [];
+ const manifest = path.join(
+ process.cwd(),
+ 'packages',
+ 'themes',
+ match[1],
+ 'package.json',
+ );
+ if (!fs.existsSync(manifest)) return [];
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
+ return pkg.private === true || pkg.astryx?.canaryOnly === true
+ ? []
+ : [match[1]];
+ }),
+ ),
+ ].sort();
for (const pkg of PACKAGES) {
const allComponents = getComponentNames(pkg);
@@ -816,7 +898,7 @@ function analyze() {
if (!allComponents.includes(componentName)) {
const source = `${pkg.packageName}/${componentName}`;
- unresolvedFiles.push({ source, file });
+ unresolvedFiles.push({source, file});
if (!unresolvedComponentSources.includes(source)) {
unresolvedComponentSources.push(source);
}
@@ -824,7 +906,9 @@ function analyze() {
}
const existsInBase = componentExistsInBase(pkg, componentName);
const owner = `${pkg.packageName}/${componentName}`;
- const owners = existsInBase ? modifiedComponentOwners : newComponentOwners;
+ const owners = existsInBase
+ ? modifiedComponentOwners
+ : newComponentOwners;
if (!owners.includes(owner)) owners.push(owner);
// Keep the legacy bare-name shape for existing report consumers. The
@@ -845,7 +929,9 @@ function analyze() {
console.log(`Changed packages: ${[...changedPackages].join(', ') || 'none'}`);
console.log(`New components: ${newComponents.join(', ') || 'none'}`);
- console.log(`Modified components: ${modifiedComponents.join(', ') || 'none'}`);
+ console.log(
+ `Modified components: ${modifiedComponents.join(', ') || 'none'}`,
+ );
console.log(
`Component owners: ${[...newComponentOwners, ...modifiedComponentOwners].join(', ') || 'none'}`,
);
@@ -854,56 +940,73 @@ function analyze() {
// brand-new exports alongside existing ones).
const newExports = [];
for (const key of modifiedComponents) {
- const pkg = PACKAGES.find((p) => p.name === componentStats[key].package);
+ const pkg = PACKAGES.find(p => p.name === componentStats[key].package);
const headExports = componentStats[key]?.exports || [];
const baseExports = getBaseExports(pkg, key);
- newExports.push(...headExports.filter((e) => e.startsWith('XDS') && !baseExports.includes(e)));
+ newExports.push(
+ ...headExports.filter(
+ e => e.startsWith('XDS') && !baseExports.includes(e),
+ ),
+ );
}
for (const key of newComponents) {
- newExports.push(...(componentStats[key]?.exports || []).filter((e) => e.startsWith('XDS')));
+ newExports.push(
+ ...(componentStats[key]?.exports || []).filter(e => e.startsWith('XDS')),
+ );
}
- if (newExports.length > 0) console.log(`New exports: ${newExports.join(', ')}`);
+ if (newExports.length > 0)
+ console.log(`New exports: ${newExports.join(', ')}`);
// Bundle sizes: report every package the PR actually touched. If none of the
// component packages changed (e.g. a docs- or tooling-only PR that still runs
// analysis), report no bundle rows rather than a stale, misattributed core row.
- const bundlePackages = PACKAGES.filter((p) => changedPackages.has(p.name)).map((p) =>
- getPackageBundleStats(p),
+ const bundlePackages = PACKAGES.filter(p => changedPackages.has(p.name)).map(
+ p => getPackageBundleStats(p),
);
- // Base measurements come from a built checkout of the merge base. Component
- // and package lists stay the head's; only the stats are read in the base tree.
+ // Base measurements come from the merge base's record, which Main keeps for
+ // each commit (writeMainRecord). Component and package lists stay the
+ // head's; only the stats are read from the record.
let baseComponentStats = null;
let baseBundlePackages = null;
- // Components a change can affect, by reach in the head build and, when the
- // merge base is built, in the base build too: CI's size-base job builds only
- // the base, and a module change can add or remove reach.
- const reachedSources = { paths: new Set(), measured: new Set() };
+ // Components a change can affect, by reach in the head build and, from the
+ // record, in the merge base's build too: a module change can add or remove
+ // reach.
+ const reachedSources = {paths: new Set(), measured: new Set()};
const headTargets = sizeTargets(changedFiles, reachedSources);
let targets = headTargets;
let baseComponentSizes = null;
- if (baseRoot) {
- const headDir = process.cwd();
- process.chdir(path.resolve(headDir, baseRoot));
- try {
- baseComponentStats = {};
- for (const key of modifiedComponents) {
- const pkg = PACKAGES.find((p) => p.name === componentStats[key].package);
- baseComponentStats[key] = getComponentStats(pkg, key);
- }
- baseBundlePackages = PACKAGES.filter((p) => changedPackages.has(p.name)).map((p) =>
- getPackageBundleStats(p),
- );
- // Each tree is measured through its own defining modules, so a renamed
- // module is not mistaken for a missing one.
- const baseTargets = sizeTargets(changedFiles);
- baseComponentSizes = measureSizes(unionTargets(baseTargets, headTargets));
- targets = unionTargets(headTargets, baseTargets);
- } finally {
- process.chdir(headDir);
+ const baseRecord = readBaseRecord();
+ if (baseRecord) {
+ baseComponentStats = {};
+ for (const key of modifiedComponents) {
+ const pkg = PACKAGES.find(p => p.name === componentStats[key].package);
+ const stats = baseRecord.componentStats?.[`${pkg.packageName}/${key}`];
+ if (stats) baseComponentStats[key] = stats;
+ }
+ baseBundlePackages = PACKAGES.filter(p => changedPackages.has(p.name)).map(
+ p =>
+ (baseRecord.bundlePackages || []).find(
+ entry => entry.package === p.name,
+ ) || {
+ package: p.name,
+ },
+ );
+ // Each tree is measured through its own defining modules, so a renamed
+ // module is not mistaken for a missing one.
+ const baseTargets = recordTargets(baseRecord, changedFiles);
+ targets = unionTargets(headTargets, baseTargets);
+ baseComponentSizes = {};
+ for (const target of unionTargets(baseTargets, headTargets)) {
+ const recorded = baseRecord.components?.[target.key];
+ baseComponentSizes[target.key] = {
+ package: target.pkg.name,
+ importGzipBytes: recorded?.importGzipBytes ?? null,
+ cssGzipBytes: recorded?.cssGzipBytes ?? null,
+ };
}
}
- const componentSizes = baseOnly ? null : measureSizes(targets);
+ const componentSizes = measureSizes(targets);
// Every changed module, inside a component folder or not (a shared hook,
// the animator, a family folder), adds the components whose head bundle
@@ -912,14 +1015,16 @@ function analyze() {
// In a package whose bundles were read, a module no bundle holds adds none.
// One outside every component folder in a package whose bundles could not
// be read stays unresolved and asks for full audits, as does --force-full.
- const isDecided = (file) =>
- [...reachedSources.measured].some((prefix) => file.startsWith(prefix)) ||
- [...reachedSources.paths].some((reachedPath) => {
+ const isDecided = file =>
+ [...reachedSources.measured].some(prefix => file.startsWith(prefix)) ||
+ [...reachedSources.paths].some(reachedPath => {
const module = file.replace(/\.(tsx?|jsx?|mjs)$/, '');
return module === reachedPath || module.startsWith(reachedPath + '/');
});
- const unreachedSources = unresolvedComponentSources.filter((source) =>
- unresolvedFiles.some((entry) => entry.source === source && !isDecided(entry.file)),
+ const unreachedSources = unresolvedComponentSources.filter(source =>
+ unresolvedFiles.some(
+ entry => entry.source === source && !isDecided(entry.file),
+ ),
);
// One affected set of component folders, which visual and RTL both audit
// (spec:AST-030 FR13): each reverse dependent's folder, and each changed
@@ -927,19 +1032,23 @@ function analyze() {
// folders (its stories are keyed by folder); RTL reads every component each
// folder implements (its routes are keyed by component: FieldLabel, not
// Field).
- const folderOf = (target) => target.distModule.split('/')[0].replace(/\.(tsx?|jsx?|mjs)$/, '');
+ const folderOf = target =>
+ target.distModule.split('/')[0].replace(/\.(tsx?|jsx?|mjs)$/, '');
const dependentComponentFolders = [];
const dependentComponentOwners = [];
- if (!baseOnly) {
- const touched = new Set([...newComponentOwners, ...modifiedComponentOwners]);
+ {
+ const touched = new Set([
+ ...newComponentOwners,
+ ...modifiedComponentOwners,
+ ]);
const addFolder = (pkg, folder) => {
const qualified = `${pkg.packageName}/${folder}`;
if (dependentComponentFolders.includes(qualified)) return;
const members = folderComponents(pkg, folder);
const owners = (members.length > 0 ? members : [folder]).map(
- (name) => `${pkg.packageName}/${name}`,
+ name => `${pkg.packageName}/${name}`,
);
- if (owners.every((owner) => touched.has(owner))) return;
+ if (owners.every(owner => touched.has(owner))) return;
dependentComponentFolders.push(qualified);
for (const owner of owners) {
if (!touched.has(owner) && !dependentComponentOwners.includes(owner)) {
@@ -950,26 +1059,20 @@ function analyze() {
for (const target of headTargets) addFolder(target.pkg, folderOf(target));
for (const source of unresolvedComponentSources) {
const [packageName, folder] = source.split('/');
- const pkg = PACKAGES.find((candidate) => candidate.packageName === packageName);
- if (pkg != null && pkg.layout !== 'flat' && familyMembers(pkg, folder).length > 0) {
+ const pkg = PACKAGES.find(
+ candidate => candidate.packageName === packageName,
+ );
+ if (
+ pkg != null &&
+ pkg.layout !== 'flat' &&
+ familyMembers(pkg, folder).length > 0
+ ) {
addFolder(pkg, folder);
}
}
- console.log(`Reverse dependents: ${dependentComponentOwners.join(', ') || 'none'}`);
- }
-
- if (baseOnly) {
- const baseResult = {
- headSha: execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim(),
- baseSha: execSync('git rev-parse HEAD', { cwd: baseRoot, encoding: 'utf8' }).trim(),
- baseComponentStats,
- baseBundlePackages,
- baseComponentSizes,
- analyzedAt: new Date().toISOString(),
- };
- fs.writeFileSync(outputFile, JSON.stringify(baseResult, null, 2));
- console.log(`Base stats written to ${outputFile}`);
- return baseResult;
+ console.log(
+ `Reverse dependents: ${dependentComponentOwners.join(', ') || 'none'}`,
+ );
}
const result = {
@@ -994,10 +1097,18 @@ function analyze() {
diffMode,
bundlePackages,
componentSizes,
- ...(baseRoot ? { baseComponentStats, baseBundlePackages, baseComponentSizes } : {}),
+ ...(baseRecord
+ ? {
+ baseSha: baseRecord.sha,
+ baseComponentStats,
+ baseBundlePackages,
+ baseComponentSizes,
+ }
+ : {}),
// Back-compat: keep totalBundle pointed at core when core changed, so any
// older consumer of this field still resolves.
- totalBundle: bundlePackages.find((b) => b.package === '@astryxdesign/core') || null,
+ totalBundle:
+ bundlePackages.find(b => b.package === '@astryxdesign/core') || null,
analyzedAt: new Date().toISOString(),
};
@@ -1006,6 +1117,107 @@ function analyze() {
return result;
}
-if (require.main === module) analyze();
+// The merge base's record, or null when none was given or it cannot be read
+// (Before and Delta then stay N/A).
+function readBaseRecord() {
+ if (!baseRecordFile) return null;
+ try {
+ const record = JSON.parse(fs.readFileSync(baseRecordFile, 'utf8'));
+ return record?.schema === 1 ? record : null;
+ } catch (e) {
+ console.warn(
+ `::warning::could not read the merge base's size record: ${e.message}`,
+ );
+ return null;
+ }
+}
+
+// The components a change can affect in the merge base's build, from its
+// record: as sizeTargets decides in a built tree, a component whose own folder
+// or file changed, or whose bundle reached a changed module of any package.
+function recordTargets(record, changedFiles) {
+ const targets = [];
+ for (const [key, component] of Object.entries(record.components || {})) {
+ const pkg = PACKAGES.find(
+ candidate => candidate.name === component.package,
+ );
+ if (!pkg) continue;
+ const target = {
+ key,
+ pkg,
+ name: component.name,
+ distModule: component.distModule,
+ };
+ const sources = new Set(
+ (component.reaches || []).map(index => record.modules[index]),
+ );
+ const {ownFolder, reachedPaths} = affectedBy(target, sources, changedFiles);
+ if (ownFolder || reachedPaths.length > 0) targets.push(target);
+ }
+ return targets;
+}
+
+// What a pull request needs from its merge base, measured once per main
+// commit in Main's build (deploy.yml) instead of in each pull request: every
+// public component's import and CSS size and the source modules its bundle
+// reaches (as `src` paths without extension, by index into `modules`), every
+// component folder's entry stats, and every component package's bundle stats.
+function writeMainRecord() {
+ const modules = [];
+ const moduleIndex = new Map();
+ const indexOf = source => {
+ if (!moduleIndex.has(source)) {
+ moduleIndex.set(source, modules.length);
+ modules.push(source);
+ }
+ return moduleIndex.get(source);
+ };
+ const dists = distRealPaths();
+ const components = {};
+ const componentStats = {};
+ for (const pkg of PACKAGES) {
+ const dist = path.join(process.cwd(), pkgDist(pkg));
+ if (!fs.existsSync(dist)) continue;
+ const {all, sources} = componentReach(pkg, dists);
+ const sizes = measureSizes(all);
+ for (const target of all) {
+ const reaches = new Set([...sources.get(target.key)].map(indexOf));
+ components[target.key] = {
+ package: pkg.name,
+ name: target.name,
+ distModule: target.distModule,
+ importGzipBytes: sizes[target.key].importGzipBytes,
+ cssGzipBytes: sizes[target.key].cssGzipBytes,
+ reaches: [...reaches].sort((a, b) => a - b),
+ };
+ }
+ for (const name of getComponentNames(pkg)) {
+ componentStats[`${pkg.packageName}/${name}`] = getComponentStats(
+ pkg,
+ name,
+ );
+ }
+ }
+ const record = {
+ schema: 1,
+ sha: execSync('git rev-parse HEAD', {encoding: 'utf8'}).trim(),
+ modules,
+ components,
+ componentStats,
+ bundlePackages: PACKAGES.filter(pkg =>
+ fs.existsSync(path.join(process.cwd(), pkgDist(pkg))),
+ ).map(pkg => getPackageBundleStats(pkg)),
+ };
+ fs.writeFileSync(outputFile, JSON.stringify(record));
+ console.log(
+ `Main record written to ${outputFile}: ${Object.keys(components).length} components.`,
+ );
+ return record;
+}
+
+if (require.main === module) {
+ if (mainRecordMode) writeMainRecord();
+ else analyze();
+}
-module.exports = { folderComponents };
+module.exports = {folderComponents};
diff --git a/.github/scripts/analyze-pr.test.mjs b/.github/scripts/analyze-pr.test.mjs
index 9f6ca82a09..6f08d6bf2d 100644
--- a/.github/scripts/analyze-pr.test.mjs
+++ b/.github/scripts/analyze-pr.test.mjs
@@ -49,6 +49,15 @@ function gitTry(dir, args) {
}
}
+/** Write the record Main keeps for a built tree, as deploy.yml does. */
+function mainRecord(root, output) {
+ execFileSync(process.execPath, [SCRIPT, '--main-record', '--output', output], {
+ cwd: root,
+ encoding: 'utf8',
+ });
+ return JSON.parse(fs.readFileSync(output, 'utf8'));
+}
+
/**
* Build the synthetic repo and return the shallow clone dir:
* upstream/: branch point, 60 churn commits on main, feature off the point
@@ -455,7 +464,7 @@ describe('analyze-pr base and head sizes', () => {
}
});
- it('decides reach in the merge-base build when only the base is built', () => {
+ it('decides reach from the merge base record when only the base is built', () => {
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-analyze-basereach-'));
const baseRoot = path.join(repo, '.size-base');
const write = (root, file, content) => {
@@ -483,18 +492,20 @@ describe('analyze-pr base and head sizes', () => {
git(repo, ['checkout', '-q', '-b', 'feature']);
write(repo, 'packages/core/src/hooks/useHold.ts', 'export function useHold() { return 2; }\n');
git(repo, ['commit', '-qam', 'touch the shared hook only']);
- // Only the merge base is built, as in the size-base job.
+ // Only the merge base is built, as on main, which keeps its record.
write(baseRoot, 'packages/core/dist/Card/Card.js', "import {useHold} from '../hooks/useHold.js';\nexport function Card() { return useHold(); }\n");
write(baseRoot, 'packages/core/dist/Badge/Badge.js', 'export function Badge() { return 0; }\n');
write(baseRoot, 'packages/core/dist/hooks/useHold.js', 'export function useHold() { return 1; }\n');
write(baseRoot, 'packages/core/dist/index.js', "export {Card} from './Card/Card.js';\nexport {Badge} from './Badge/Badge.js';\n");
+ mainRecord(baseRoot, path.join(repo, 'record.json.out'));
execFileSync(
process.execPath,
- [SCRIPT, '--base', 'main', '--head', 'HEAD', '--base-root', '.size-base', '--base-only', '--output', 'base.json'],
+ [SCRIPT, '--base', 'main', '--head', 'HEAD', '--base-record', 'record.json.out', '--output', 'base.json'],
{cwd: repo, encoding: 'utf8'},
);
const base = JSON.parse(fs.readFileSync(path.join(repo, 'base.json'), 'utf8'));
+ // Badge's bundle never reached the hook, so it stays out.
expect(Object.keys(base.baseComponentSizes)).toEqual(['core/Card']);
expect(base.baseComponentSizes['core/Card'].importGzipBytes).toBeGreaterThan(0);
} finally {
@@ -532,9 +543,10 @@ describe('analyze-pr base and head sizes', () => {
write(baseRoot, 'packages/core/dist/Card/Card.js', 'export function Card() { return 1; }\n');
write(baseRoot, 'packages/core/dist/index.js', 'export const other = 1;\n');
+ mainRecord(baseRoot, path.join(repo, 'record.json.out'));
execFileSync(
process.execPath,
- [SCRIPT, '--base', 'main', '--head', 'HEAD', '--base-root', '.size-base', '--base-only', '--output', 'base.json'],
+ [SCRIPT, '--base', 'main', '--head', 'HEAD', '--base-record', 'record.json.out', '--output', 'base.json'],
{cwd: repo, encoding: 'utf8'},
);
const base = JSON.parse(fs.readFileSync(path.join(repo, 'base.json'), 'utf8'));
@@ -544,7 +556,7 @@ describe('analyze-pr base and head sizes', () => {
}
});
- it('measures ESM entries by module type and reads base sizes from a merge-base build', () => {
+ it('measures ESM entries by module type and reads base sizes from the merge base record', () => {
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-analyze-size-'));
const baseRoot = path.join(repo, '.size-base');
const write = (root, file, content) => {
@@ -632,6 +644,7 @@ describe('analyze-pr base and head sizes', () => {
'export const head = 2;\n'.repeat(40),
);
+ mainRecord(baseRoot, path.join(repo, 'record.json.out'));
execFileSync(
process.execPath,
[
@@ -640,8 +653,8 @@ describe('analyze-pr base and head sizes', () => {
'main',
'--head',
'HEAD',
- '--base-root',
- '.size-base',
+ '--base-record',
+ 'record.json.out',
'--output',
'analysis.json',
],
@@ -672,30 +685,18 @@ describe('analyze-pr base and head sizes', () => {
expect(headBundle.gzipBytes).toBeGreaterThan(0);
expect(baseBundle.gzipBytes).toBeGreaterThan(0);
+ expect(analysis.baseSha).toBe(git(repo, ['rev-parse', 'main']));
+ expect(analysis.baseComponentSizes['core/Chat'].importGzipBytes).toBeGreaterThan(0);
+
+ // Without a readable record, Before stays empty rather than failing.
execFileSync(
process.execPath,
- [
- SCRIPT,
- '--base',
- 'main',
- '--head',
- 'HEAD',
- '--base-root',
- '.size-base',
- '--base-only',
- '--output',
- 'size-base.json',
- ],
+ [SCRIPT, '--base', 'main', '--head', 'HEAD', '--base-record', 'missing.json.out', '--output', 'analysis.json'],
{cwd: repo, encoding: 'utf8'},
);
- const baseOnly = JSON.parse(
- fs.readFileSync(path.join(repo, 'size-base.json'), 'utf8'),
- );
- expect(baseOnly.headSha).toBe(git(repo, ['rev-parse', 'HEAD']));
- expect(baseOnly.baseSha).toBe(git(repo, ['rev-parse', 'main']));
- expect(baseOnly.baseComponentStats.Card.esmBytes).toBe(100);
- expect(baseOnly.componentStats).toBeUndefined();
- expect(baseOnly.baseComponentSizes['core/Chat'].importGzipBytes).toBeGreaterThan(0);
+ const withoutRecord = JSON.parse(fs.readFileSync(path.join(repo, 'analysis.json'), 'utf8'));
+ expect(withoutRecord.baseComponentSizes).toBeUndefined();
+ expect(withoutRecord.componentSizes['core/Card'].importGzipBytes).toBeGreaterThan(0);
} finally {
fs.rmSync(repo, {recursive: true, force: true});
}
diff --git a/.github/scripts/ci-tooling-routing.test.mjs b/.github/scripts/ci-tooling-routing.test.mjs
index 38120f7f7a..e4f1b49e40 100644
--- a/.github/scripts/ci-tooling-routing.test.mjs
+++ b/.github/scripts/ci-tooling-routing.test.mjs
@@ -10,7 +10,9 @@
* @position Workflow contract for spec:AST-030's first implementation slice.
*/
+import {execFileSync} from 'node:child_process';
import fs from 'node:fs';
+import os from 'node:os';
import path from 'node:path';
import {describe, expect, it} from 'vitest';
@@ -130,11 +132,9 @@ describe('Node-tooling CI routing', () => {
]) {
expect(step(ci.jobs['test-build'], name).if).toBe(BROAD_ONLY);
}
- // The merge-base size build is heavy build work and stays off the
- // Node-tooling, docsite, and spec lanes.
- expect(step(ci.jobs['size-base'], 'Setup Node and pnpm').if).toContain(
- BROAD_ONLY,
- );
+ // No size-base job: Main keeps the merge base's sizes, and build-storybook
+ // builds the base only when Main kept no record.
+ expect(ci.jobs['size-base']).toBeUndefined();
expect(rootScripts['test:theme-family'].split(' && ')).toEqual([
'pnpm -F @astryxdesign/core build',
'pnpm -F @astryxdesign/sandbox generate:theme-family',
@@ -237,43 +237,114 @@ describe('Node-tooling CI routing', () => {
);
});
- it("measures the merge base from main's kept build, building it only without one", () => {
+ it("reads the merge base's sizes from main's kept records, building the base only without one", () => {
const main = load('.github/workflows/deploy.yml');
- const keep = step(
- main.jobs.typecheck,
- "Keep this commit's package builds for PR size reports",
- );
- expect(keep.with.name).toBe(
- 'dists-main-${{ needs.main-commit.outputs.sha }}',
+ expect(step(main.jobs.typecheck, 'Record component sizes').run).toBe(
+ 'node .github/scripts/analyze-pr.js --main-record --output component-size.json',
);
- const job = ci.jobs['size-base'];
- expect(job.permissions.actions).toBe('read');
expect(
- step(job, "Find main's build of the merge base")['continue-on-error'],
- ).toBe(true);
- const download = step(job, "Download main's build of the merge base");
+ step(
+ main.jobs.typecheck,
+ "Keep this commit's component sizes for PR size reports",
+ ).with.name,
+ ).toBe('component-size-main-${{ needs.main-commit.outputs.sha }}');
+ // Main no longer keeps whole package builds for pull requests.
+ expect(
+ step(
+ main.jobs.typecheck,
+ "Keep this commit's package builds for PR size reports",
+ ),
+ ).toBeUndefined();
+ const job = ci.jobs['build-storybook'];
+ expect(job.permissions.actions).toBe('read');
+ const find = step(job, "Find main's size records for the merge base");
+ expect(find['continue-on-error']).toBe(true);
+ const download = step(
+ job,
+ "Download main's component sizes for the merge base",
+ );
expect(download['continue-on-error']).toBe(true);
expect(download.with.name).toBe(
- 'dists-main-${{ steps.merge-base.outputs.sha }}',
+ 'component-size-main-${{ steps.merge-base.outputs.sha }}',
+ );
+ // The analysis reads the record only when it was downloaded.
+ const analyze = step(job, 'Analyze components').run;
+ expect(analyze).toContain(
+ 'if [ -f .component-size-base/component-size.json ]',
+ );
+ expect(analyze).toContain(
+ '--base-record .component-size-base/component-size.json',
+ );
+ // Only Main's own run on main for the merge-base commit counts, through
+ // the shared lookup helper (main-artifact.test.mjs).
+ expect(find.with.script).toContain('.github/scripts/lib/main-artifact.cjs');
+ expect(find.with.script).toContain('sha: process.env.BASE_SHA');
+ // The lookup and download come before the analysis that reads them.
+ const names = job.steps.map(entry => entry.name);
+ expect(
+ names.indexOf("Download main's component sizes for the merge base"),
+ ).toBeLessThan(names.indexOf('Analyze components'));
+ // Without a record the merge base builds beside the Storybook build, and
+ // the analysis waits for it, so every changed component keeps a before
+ // size (AST-080 FR8).
+ const start = step(job, 'Start building the merge base without a record');
+ // Main kept no record, or its download failed: either way the base builds.
+ expect(start.if).toContain("steps.component-download.outcome != 'success'");
+ expect(download.id).toBe('component-download');
+ expect(start.run).toContain(
+ 'node ../.github/scripts/analyze-pr.js --main-record --output ../.component-size-base/component-size.json',
);
- const build = step(job, "Build the merge base's component packages");
- expect(build.if).toContain("steps.download.outcome != 'success'");
- expect(build.run).not.toContain('pnpm install');
- // Measuring needs the base's dependencies on both paths.
- const install = step(job, "Install the merge base's dependencies");
- expect(install.run).toBe('pnpm install --frozen-lockfile');
- expect(install.if).not.toContain('steps.download');
- // Only Main's own run on main for the merge-base commit counts; both
- // merge-base lookups share one helper (main-artifact.test.mjs).
- const find = step(job, "Find main's build of the merge base").with.script;
- expect(find).toContain('.github/scripts/lib/main-artifact.cjs');
- expect(find).toContain('sha: process.env.BASE_SHA');
- const packageFind = step(
+ expect(start.run).toMatch(/\|\| touch base-build\.failed &$/m);
+ expect(
+ names.indexOf("Find main's size records for the merge base"),
+ ).toBeLessThan(
+ names.indexOf('Start building the merge base without a record'),
+ );
+ expect(
+ names.indexOf('Start building the merge base without a record'),
+ ).toBeLessThan(names.indexOf('Build packages and Storybook'));
+ const wait = step(job, "Wait for the merge base's sizes");
+ expect(wait.if).toContain("steps.base-build.outputs.started == 'true'");
+ expect(names.indexOf("Wait for the merge base's sizes")).toBeLessThan(
+ names.indexOf('Analyze components'),
+ );
+ });
+
+ it.each([
+ ['built', 'base-build.done', true, '::notice title=Merge base built::'],
+ [
+ 'failed',
+ 'base-build.failed',
+ false,
+ '::warning title=Merge base not built::',
+ ],
+ ])('collects a merge base that %s', (_label, marker, kept, message) => {
+ const wait = step(
ci.jobs['build-storybook'],
- "Find main's package size for the merge base",
- ).with.script;
- expect(packageFind).toContain('.github/scripts/lib/main-artifact.cjs');
- expect(packageFind).toContain('sha: process.env.BASE_SHA');
+ "Wait for the merge base's sizes",
+ );
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'base-build-'));
+ try {
+ fs.mkdirSync(path.join(root, '.component-size-base'));
+ fs.writeFileSync(
+ path.join(root, '.component-size-base/component-size.json'),
+ '{}',
+ );
+ fs.writeFileSync(path.join(root, 'base-build.log'), 'log\n');
+ fs.writeFileSync(path.join(root, marker), '');
+ const out = execFileSync('bash', ['-e', '-c', wait.run], {
+ cwd: root,
+ encoding: 'utf8',
+ });
+ expect(out).toContain(message);
+ expect(
+ fs.existsSync(
+ path.join(root, '.component-size-base/component-size.json'),
+ ),
+ ).toBe(kept);
+ } finally {
+ fs.rmSync(root, {recursive: true, force: true});
+ }
});
it('builds no Sandbox and builds Storybook once per pull-request run', () => {
diff --git a/.github/scripts/workflow-artifact-names.test.mjs b/.github/scripts/workflow-artifact-names.test.mjs
new file mode 100644
index 0000000000..d4822f6456
--- /dev/null
+++ b/.github/scripts/workflow-artifact-names.test.mjs
@@ -0,0 +1,39 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file workflow-artifact-names.test.mjs
+ * Contract: no job uploads two artifacts under one name. A second upload of a
+ * name fails the job, so a duplicated step (as a merge can leave behind) would
+ * fail every run of it.
+ */
+
+import fs from 'node:fs';
+import path from 'node:path';
+import {describe, expect, it} from 'vitest';
+import yaml from 'yaml';
+
+const dir = path.resolve(import.meta.dirname, '../workflows');
+const workflows = fs
+ .readdirSync(dir)
+ .filter(name => /\.ya?ml$/.test(name))
+ .map(name => [
+ name,
+ yaml.parse(fs.readFileSync(path.join(dir, name), 'utf8')),
+ ]);
+
+describe('artifact names', () => {
+ it.each(workflows)(
+ '%s uploads each artifact name once per job',
+ (_name, workflow) => {
+ for (const [id, job] of Object.entries(workflow.jobs || {})) {
+ const names = (job.steps || [])
+ .filter(step =>
+ String(step.uses || '').startsWith('actions/upload-artifact@'),
+ )
+ .map(step => step.with?.name)
+ .filter(Boolean);
+ expect(names, id).toEqual([...new Set(names)]);
+ }
+ },
+ );
+});
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a746f9e757..503ee4a4d6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -983,6 +983,83 @@ jobs:
if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: ./.github/actions/setup
+ # Main keeps each commit's size records for 14 days (deploy.yml): every
+ # public component's sizes and every published package's. The merge
+ # base is compared from them; it is built here only when Main kept no
+ # component record for it. The lookup runs before the Storybook build so
+ # that build can run beside it.
+ - name: Find the merge base
+ id: merge-base
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
+ env:
+ BASE_REF: ${{ github.base_ref }}
+ run: echo "sha=$(.github/scripts/merge-base.sh "$BASE_REF" 'the size comparisons' || true)" >> "$GITHUB_OUTPUT"
+
+ - name: Find main's size records for the merge base
+ id: size-records
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.merge-base.outputs.sha != ''
+ continue-on-error: true
+ uses: actions/github-script@v9
+ env:
+ BASE_SHA: ${{ steps.merge-base.outputs.sha }}
+ with:
+ retries: 3
+ script: |
+ const {mainArtifactRunId} = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/lib/main-artifact.cjs`);
+ for (const [output, prefix, missing] of [
+ ['component_run_id', 'component-size-main', 'the merge base is built here instead'],
+ ['package_run_id', 'package-size-main', 'package sizes are shown without a budget'],
+ ]) {
+ const name = `${prefix}-${process.env.BASE_SHA}`;
+ const runId = await mainArtifactRunId({github, ...context.repo, name, sha: process.env.BASE_SHA});
+ core.setOutput(output, runId ?? '');
+ core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; ${missing}.`);
+ }
+
+ - name: Download main's component sizes for the merge base
+ id: component-download
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.size-records.outputs.component_run_id != ''
+ continue-on-error: true
+ uses: actions/download-artifact@v8
+ with:
+ name: component-size-main-${{ steps.merge-base.outputs.sha }}
+ run-id: ${{ steps.size-records.outputs.component_run_id }}
+ github-token: ${{ github.token }}
+ path: .component-size-base
+
+ # No component record of this merge base was read (Main kept none, or
+ # its download failed): build the base beside
+ # the Storybook build and record its sizes with this head's analyzer, so
+ # every changed component still has a before size (AST-080 FR8). It runs
+ # in the background; the wait before the analysis collects it.
+ - name: Start building the merge base without a record
+ id: base-build
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.merge-base.outputs.sha != '' && steps.component-download.outcome != 'success'
+ env:
+ BASE_SHA: ${{ steps.merge-base.outputs.sha }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: |
+ git worktree add --detach .size-base "$BASE_SHA"
+ mkdir -p .component-size-base
+ # The inner script reads BASE_SHA and HEAD_SHA from this step's env.
+ # shellcheck disable=SC2016
+ nohup bash -c '
+ set -e
+ cd .size-base
+ pnpm install --frozen-lockfile
+ # Core and its build tooling always build: the other component
+ # packages depend on them. Another package builds only when the
+ # pull request changes its source.
+ pnpm -F @astryxdesign/build build
+ pnpm -F @astryxdesign/core build
+ for pkg in lab charts richtext vega; do
+ git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- "packages/$pkg/src" || pnpm -F "@astryxdesign/$pkg" build
+ done
+ node ../.github/scripts/analyze-pr.js --main-record --output ../.component-size-base/component-size.json
+ touch ../base-build.done
+ ' > base-build.log 2>&1 || touch base-build.failed &
+ echo "started=true" >> "$GITHUB_OUTPUT"
+
# The same steps as `pnpm build` and the Storybook build, overlapped: a
# package builds once its workspace dependencies have, and Storybook once
# the packages its story index records are built.
@@ -1061,6 +1138,25 @@ jobs:
packages/core/dist/
retention-days: 1
+ # The merge base built beside the Storybook build: its record, or a
+ # warning that Before and Delta stay empty. The wait is what it adds to
+ # this job.
+ - name: Wait for the merge base's sizes
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.base-build.outputs.started == 'true'
+ run: |
+ waited=0
+ while [ ! -f base-build.done ] && [ ! -f base-build.failed ] && [ "$waited" -lt 600 ]; do
+ sleep 1
+ waited=$((waited + 1))
+ done
+ tail -n 20 base-build.log || true
+ if [ -f base-build.done ]; then
+ echo "::notice title=Merge base built::Main kept no record of the merge base; it was built beside Storybook (waited ${waited}s after the build)."
+ else
+ rm -f .component-size-base/component-size.json
+ echo "::warning title=Merge base not built::Building the merge base failed or timed out; Before and Delta stay empty."
+ fi
+
- name: Analyze components
if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
env:
@@ -1070,10 +1166,15 @@ jobs:
# dependents, unless the change touches shared infrastructure.
FORCE_FULL=()
if [ "$FULL_SUITE" != false ]; then FORCE_FULL=(--force-full); fi
+ BASE_RECORD=()
+ if [ -f .component-size-base/component-size.json ]; then
+ BASE_RECORD=(--base-record .component-size-base/component-size.json)
+ fi
node .github/scripts/analyze-pr.js \
--base origin/${{ github.base_ref }} \
--head HEAD \
--output analysis.json \
+ "${BASE_RECORD[@]}" \
"${FORCE_FULL[@]}"
# Published package size: this head's packages are built above, and Main
@@ -1085,36 +1186,13 @@ jobs:
if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request' && (steps.scope.outputs.touches == 'true' || steps.scope.outputs.full_suite != 'false')
run: node .github/scripts/package-size.mjs measure --output package-size-head.json
- - name: Find the merge base for package size
- id: package-size-merge-base
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.package-size.outcome == 'success'
- env:
- BASE_REF: ${{ github.base_ref }}
- run: echo "sha=$(.github/scripts/merge-base.sh "$BASE_REF" 'the package-size comparison')" >> "$GITHUB_OUTPUT"
-
- - name: Find main's package size for the merge base
- id: package-size-cached
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.package-size-merge-base.outputs.sha != ''
- continue-on-error: true
- uses: actions/github-script@v9
- env:
- BASE_SHA: ${{ steps.package-size-merge-base.outputs.sha }}
- with:
- retries: 3
- script: |
- const {mainArtifactRunId} = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/lib/main-artifact.cjs`);
- const name = `package-size-main-${process.env.BASE_SHA}`;
- const runId = await mainArtifactRunId({github, ...context.repo, name, sha: process.env.BASE_SHA});
- core.setOutput('run_id', runId ?? '');
- core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; sizes are shown without a budget.`);
-
- name: Download main's package size for the merge base
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.package-size-cached.outputs.run_id != ''
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.package-size.outcome == 'success' && steps.size-records.outputs.package_run_id != ''
continue-on-error: true
uses: actions/download-artifact@v8
with:
- name: package-size-main-${{ steps.package-size-merge-base.outputs.sha }}
- run-id: ${{ steps.package-size-cached.outputs.run_id }}
+ name: package-size-main-${{ steps.merge-base.outputs.sha }}
+ run-id: ${{ steps.size-records.outputs.package_run_id }}
github-token: ${{ github.token }}
path: .package-size-base
@@ -1124,7 +1202,7 @@ jobs:
if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.package-size.outcome == 'success'
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
- BASE_SHA: ${{ steps.package-size-merge-base.outputs.sha }}
+ BASE_SHA: ${{ steps.merge-base.outputs.sha }}
run: |
# Without a base, the report names why: no merge base was found, or
# Main kept (or the lookup read) no measurement for it.
@@ -1168,139 +1246,6 @@ jobs:
package-size.json
retention-days: 1
- # Measures the PR's merge base so the PR comment can show component and
- # package sizes before and after. It runs beside build-storybook rather than
- # inside it, so no browser lane waits for the second build; the head sizes
- # still come from build-storybook's analysis.
- size-base:
- if: (github.event_name != 'pull_request' || !github.event.pull_request.draft && (github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run'))) && (github.event_name == 'pull_request')
- runs-on: ubuntu-latest
- timeout-minutes: 15
- permissions:
- actions: read
- contents: read
- pull-requests: read
- steps:
- # This job decides its own scope (no separate scope job): the step
- # reads the PR's file list and the base's trusted classifier, and
- # everything is in scope when it cannot decide.
- - name: Check out the scope action
- uses: actions/checkout@v7
- with:
- sparse-checkout: .github/actions/test-scope
- path: .test-scope
- persist-credentials: false
-
- - name: Decide this job's scope
- id: scope
- uses: ./.test-scope/.github/actions/test-scope
-
- - name: Checkout
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- uses: actions/checkout@v7
- with:
- ref: ${{ github.event.pull_request.head.sha }}
- fetch-depth: 50
-
- - name: Fetch base branch
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- run: git fetch origin ${{ github.base_ref }} --depth=50
-
- - name: Setup Node and pnpm
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- uses: ./.github/actions/setup
-
- # A branch far behind main may have no merge base within the fetched
- # history even after deepening. The report then keeps Before and Delta
- # as N/A rather than failing the run.
- - name: Check out the merge base
- if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- id: merge-base
- env:
- BASE_REF: ${{ github.base_ref }}
- run: |
- BASE_SHA=$(.github/scripts/merge-base.sh "$BASE_REF" 'base size measurement' || true)
- if [ -z "$BASE_SHA" ]; then
- echo "found=false" >> "$GITHUB_OUTPUT"
- exit 0
- fi
- git worktree add --detach .size-base "$BASE_SHA"
- echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
- echo "found=true" >> "$GITHUB_OUTPUT"
-
- # The merge base's dependencies install either way: measuring bundles
- # each base component with esbuild, which resolves its imports there.
- - name: Install the merge base's dependencies
- if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- working-directory: .size-base
- run: pnpm install --frozen-lockfile
-
- # Main keeps each commit's package builds for 14 days. A merge base on
- # main within that window is measured from them, with no build.
- - name: Find main's build of the merge base
- id: cached
- continue-on-error: true
- if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- uses: actions/github-script@v9
- env:
- BASE_SHA: ${{ steps.merge-base.outputs.sha }}
- with:
- retries: 3
- script: |
- const {mainArtifactRunId} = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/lib/main-artifact.cjs`);
- const name = `dists-main-${process.env.BASE_SHA}`;
- const runId = await mainArtifactRunId({github, ...context.repo, name, sha: process.env.BASE_SHA});
- core.setOutput('run_id', runId ?? '');
- core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; building the merge base.`);
-
- - name: Download main's build of the merge base
- id: download
- if: steps.cached.outputs.run_id != ''
- continue-on-error: true
- uses: actions/download-artifact@v8
- with:
- name: dists-main-${{ steps.merge-base.outputs.sha }}
- run-id: ${{ steps.cached.outputs.run_id }}
- github-token: ${{ github.token }}
- path: .size-base/packages
-
- # Without a kept build: core and its build tooling always build, because
- # the other component packages depend on them; another package builds
- # only when the PR changes its source.
- - name: Build the merge base's component packages
- if: (steps.merge-base.outputs.found == 'true') && steps.download.outcome != 'success' && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- working-directory: .size-base
- env:
- BASE_SHA: ${{ steps.merge-base.outputs.sha }}
- HEAD_SHA: ${{ github.event.pull_request.head.sha }}
- run: |
- pnpm -F @astryxdesign/build build
- pnpm -F @astryxdesign/core build
- for pkg in lab charts richtext vega; do
- if git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- "packages/$pkg/src"; then
- continue
- fi
- pnpm -F "@astryxdesign/$pkg" build
- done
-
- - name: Measure the merge base
- if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- run: |
- node .github/scripts/analyze-pr.js \
- --base origin/${{ github.base_ref }} \
- --head HEAD \
- --base-root .size-base \
- --base-only \
- --output size-base.json
-
- - name: Upload base size stats
- if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- uses: actions/upload-artifact@v7
- with:
- name: pr-size-base
- path: size-base.json
- retention-days: 1
-
# Typechecks run beside build-storybook instead of before its Storybook
# build, so the browser checks that wait on the Storybook artifact start
# ~1.5 minutes sooner. The build and release-check joins require this job,
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index a65af1395c..837cd88555 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -131,15 +131,16 @@ jobs:
- run: pnpm build
- # A pull request measures its merge base's component sizes from this
- # build instead of building the base again (ci.yml size-base).
- - name: Keep this commit's package builds for PR size reports
+ # A pull request reads its merge base's component sizes from this record
+ # instead of building the base (ci.yml build-storybook).
+ - name: Record component sizes
+ run: node .github/scripts/analyze-pr.js --main-record --output component-size.json
+
+ - name: Keep this commit's component sizes for PR size reports
uses: actions/upload-artifact@v7
with:
- name: dists-main-${{ needs.main-commit.outputs.sha }}
- path: |
- packages/*/dist/
- packages/themes/*/dist/
+ name: component-size-main-${{ needs.main-commit.outputs.sha }}
+ path: component-size.json
retention-days: 14
# A pull request compares its published package sizes with its merge