Skip to content
Draft
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
75 changes: 69 additions & 6 deletions .github/workflows/vp-binary-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,35 @@ jobs:
TARGET: ${{ matrix.settings.target }}
run: |
node <<'NODE'
const { existsSync, readFileSync, writeFileSync } = require('node:fs');
const { existsSync, readFileSync, readdirSync, writeFileSync } = require('node:fs');
const { gzipSync } = require('node:zlib');

function includeAllFiles() {
return true;
}

function includeNonNodeFiles(file) {
return !file.endsWith('.node');
}

function measureDirectory(directory, includeFile = includeAllFiles) {
let files = 0;
let raw = 0;
function visit(currentDirectory) {
for (const entry of readdirSync(currentDirectory, { withFileTypes: true })) {
const entryPath = `${currentDirectory}/${entry.name}`;
if (entry.isDirectory()) {
visit(entryPath);
} else if (entry.isFile() && includeFile(entryPath)) {
files += 1;
raw += readFileSync(entryPath).length;
}
}
}
visit(directory);
return { path: directory, files, raw };
}

const target = process.env.TARGET;
const paths =
process.env.PLATFORM === 'linux'
Expand Down Expand Up @@ -187,6 +213,17 @@ jobs:
gzip: gzipSync(contents, { level: 9 }).length,
};
}
if (process.env.PLATFORM === 'linux') {
const cliDistDirectory = 'packages/cli/dist';
const coreDistDirectory = 'packages/core/dist';
for (const directory of [cliDistDirectory, coreDistDirectory]) {
if (!existsSync(directory)) {
throw new Error(`Expected final dist package at ${directory}`);
}
}
artifacts.cliDist = measureDirectory(cliDistDirectory);
artifacts.coreDist = measureDirectory(coreDistDirectory, includeNonNodeFiles);
}

const result = {
source: process.env.SOURCE,
Expand Down Expand Up @@ -351,16 +388,42 @@ jobs:
};

const shortSha = process.env.HEAD_SHA.slice(0, 7);
const rows = artifacts.flatMap((artifact) => [
`| ${artifact.name} | Binary | ${formatSize(artifact.baseRaw)} | ${formatSize(artifact.headRaw)} | ${formatDelta(artifact.baseRaw, artifact.headRaw)} |`,
`| ${artifact.name} | gzip -9 | ${formatSize(artifact.baseGzip)} | ${formatSize(artifact.headGzip)} | ${formatDelta(artifact.baseGzip, artifact.headGzip)} |`,
]);
const distArtifacts = [
{
name: '`packages/cli/dist`',
baseRaw: baseLinux.artifacts.cliDist.raw,
headRaw: headLinux.artifacts.cliDist.raw,
},
{
name: '`packages/core/dist`',
baseRaw: baseLinux.artifacts.coreDist.raw,
headRaw: headLinux.artifacts.coreDist.raw,
},
{
name: 'Combined package dist',
baseRaw:
baseLinux.artifacts.cliDist.raw + baseLinux.artifacts.coreDist.raw,
headRaw:
headLinux.artifacts.cliDist.raw + headLinux.artifacts.coreDist.raw,
},
];
const rows = [
...distArtifacts.map(
(artifact) =>
`| ${artifact.name} | Directory total | ${formatSize(artifact.baseRaw)} | ${formatSize(artifact.headRaw)} | ${formatDelta(artifact.baseRaw, artifact.headRaw)} |`,
),
...artifacts.flatMap((artifact) => [
`| ${artifact.name} | Binary | ${formatSize(artifact.baseRaw)} | ${formatSize(artifact.headRaw)} | ${formatDelta(artifact.baseRaw, artifact.headRaw)} |`,
`| ${artifact.name} | gzip -9 | ${formatSize(artifact.baseGzip)} | ${formatSize(artifact.headGzip)} | ${formatDelta(artifact.baseGzip, artifact.headGzip)} |`,
]),
];
const body = [
marker,
'',
`### Native binary sizes (\`${shortSha}\`)`,
`### CLI artifact sizes (\`${shortSha}\`)`,
'',
'Final release artifacts built by the canonical `build-upstream` and `build-windows-cli` actions.',
'The dist rows use the Linux build. The core total excludes `.node` files to match the release artifact.',
'',
'| Artifact | Format | Base | PR | Change |',
'| --- | --- | ---: | ---: | ---: |',
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ url = "2.5.4"
uuid = "1.17.0"
vfs = "0.13.0"
vp_command = { path = "crates/vp_command" }
vp_cli_help = { path = "crates/vp_cli_help" }
vp_error = { path = "crates/vp_error" }
vp_js_runtime = { path = "crates/vp_js_runtime" }
vp_migration = { path = "crates/vp_migration" }
Expand Down
17 changes: 17 additions & 0 deletions crates/vp_cli_help/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "vp_cli_help"
version = "0.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
publish = false
rust-version.workspace = true

[dependencies]
clap = { workspace = true }
owo-colors = { workspace = true }
terminal_size = { workspace = true }
vp_shared = { workspace = true }

[lints]
workspace = true
Loading
Loading