Skip to content

Commit f5250d8

Browse files
chore(deps-dev): bump verdaccio to 5.13.0 (#3731)
* chore(deps-dev): bump verdaccio to 5.13.0 * chore(local-publish): reduce publish concurrency to fix socket timeout * chore(size-benchmark): verdaccio allow more connections * test(size): attempt to reduce size benchmark runner concurrency * test(size): increase verdaccio rate limit to 20K * test(size): remove unused auth config, update dependencies * chore(size-benchmark): refactor to use esm because p-map is only esm * chore(deps-dev): bump ts-node and yargs * chore: add space in error message Co-authored-by: Trivikram Kamat <[email protected]>
1 parent 7658b79 commit f5250d8

File tree

23 files changed

+807
-931
lines changed

23 files changed

+807
-931
lines changed

clients/client-s3/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const webpack = require("webpack");
33
module.exports = function (config) {
44
config.set({
55
basePath: "",
6-
frameworks: ["mocha", "chai"],
6+
frameworks: ["mocha", "chai", "webpack"],
77
files: ["test/e2e/**/*.ispec.ts"],
88
preprocessors: {
99
"test/e2e/**/*.ispec.ts": ["webpack", "sourcemap", "credentials", "env"],

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"test:integration:legacy:since:release": "./tests/integ-legacy/index.js",
3535
"test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-protocoltests-*'",
3636
"test:server-protocols": "yarn build:server-protocols && lerna run test --scope '@aws-sdk/*-server'",
37-
"test:size": "cd scripts/benchmark-size/runner && yarn && ./cli.ts",
37+
"test:size": "cd scripts/benchmark-size/runner && yarn && ts-node ./cli.ts",
3838
"test:unit": "jest --config jest.config.js",
3939
"test:versions": "jest --config tests/versions/jest.config.js tests/versions/index.spec.ts",
4040
"update:versions:default": "node --es-module-specifier-resolution=node ./scripts/update-versions/default.mjs",
@@ -51,7 +51,7 @@
5151
"license": "UNLICENSED",
5252
"dependencies": {
5353
"glob": "^7.1.6",
54-
"yargs": "^15.1.0"
54+
"yargs": "17.5.1"
5555
},
5656
"devDependencies": {
5757
"@commitlint/cli": "17.0.2",
@@ -106,11 +106,11 @@
106106
"ts-jest": "28.0.5",
107107
"ts-loader": "^7.0.5",
108108
"ts-mocha": "10.0.0",
109-
"ts-node": "^10.4.0",
109+
"ts-node": "10.8.1",
110110
"typedoc": "0.19.2",
111111
"typedoc-plugin-lerna-packages": "0.3.1",
112112
"typescript": "~4.6.2",
113-
"verdaccio": "4.13.2",
113+
"verdaccio": "5.13.0",
114114
"webpack": "5.73.0",
115115
"webpack-cli": "4.10.0",
116116
"yarn": "1.22.10"

scripts/benchmark-size/runner/calculate-size/bundlers-size.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import commonjsPlugin from "@rollup/plugin-commonjs";
22
import jsonPlugin from "@rollup/plugin-json";
33
import resolvePlugin from "@rollup/plugin-node-resolve";
44
import { build as esbuild } from "esbuild";
5-
import { lstat } from "fs-extra";
5+
import fsExtra from "fs-extra";
66
import { join } from "path";
77
import { rollup } from "rollup";
88
import { terser as terserPlugin } from "rollup-plugin-terser";
@@ -11,6 +11,8 @@ import webpack from "webpack";
1111

1212
import type { SizeReportContext } from "../index";
1313

14+
const { lstat } = fsExtra;
15+
1416
export interface BundlerSizeReportContext extends SizeReportContext {
1517
projectDir: string;
1618
entryPoint: string;

scripts/benchmark-size/runner/calculate-size/generate-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import exec from "execa";
1+
import { execa as exec } from "execa";
22
import { promises as fsPromise } from "fs";
33
import { join } from "path";
44
import prettier from "prettier";
Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { promises as fsPromise } from "fs";
2-
import { ListrContext, ListrTaskWrapper } from "listr2";
32
import { join } from "path";
43

54
import { SizeReportContext } from "../index";
65
import { PackageContext } from "../load-test-scope";
7-
import { getEsbuildSize, getRollupSize, getWebpackSize } from "./bundlers-size";
8-
import { generateProject } from "./generate-project";
9-
import { calculateNpmSize } from "./npm-size";
6+
import { getEsbuildSize, getRollupSize, getWebpackSize } from "./bundlers-size.js";
7+
import { generateProject } from "./generate-project.js";
8+
import { calculateNpmSize } from "./npm-size.js";
109

1110
export interface PackageSizeReportOptions extends SizeReportContext {
1211
packageName: string;
@@ -23,48 +22,48 @@ export interface PackageSizeReportOutput {
2322
rollupSize: number | undefined;
2423
}
2524

26-
export const getPackageSizeReportRunner =
27-
(options: PackageSizeReportOptions) => async (context: ListrContext, task: ListrTaskWrapper<ListrContext, any>) => {
28-
try {
29-
task.output = "preparing...";
30-
const projectDir = join(options.tmpDir, options.packageName.replace("/", "_"));
31-
await fsPromise.mkdir(projectDir);
32-
const entryPoint = join(projectDir, "index.js");
33-
const bundlersContext = { ...options, entryPoint, projectDir };
25+
export const generatePackageSizeReport = async (options: PackageSizeReportOptions) => {
26+
const { packageName } = options;
27+
try {
28+
console.info(`[${packageName}] preparing...`);
29+
const projectDir = join(options.tmpDir, options.packageName.replace("/", "_"));
30+
await fsPromise.mkdir(projectDir);
31+
const entryPoint = join(projectDir, "index.js");
32+
const bundlersContext = { ...options, entryPoint, projectDir };
3433

35-
task.output = "generating project and installing dependencies";
36-
await generateProject(projectDir, options);
34+
console.info(`[${packageName}] generating project and installing dependencies`);
35+
await generateProject(projectDir, options);
3736

38-
task.output = "calculating npm size";
39-
const npmSizeResult = calculateNpmSize(projectDir, options.packageName);
37+
console.info(`[${packageName}] calculating npm size`);
38+
const npmSizeResult = calculateNpmSize(projectDir, options.packageName);
4039

41-
const skipBundlerTests = bundlersContext.packageContext.skipBundlerTests;
40+
const skipBundlerTests = bundlersContext.packageContext.skipBundlerTests;
4241

43-
task.output = "calculating webpack 5 full bundle size";
44-
const webpackSize = skipBundlerTests ? undefined : await getWebpackSize(bundlersContext);
42+
console.info(`[${packageName}] calculating webpack 5 full bundle size`);
43+
const webpackSize = skipBundlerTests ? undefined : await getWebpackSize(bundlersContext);
4544

46-
task.output = "calculating rollup full bundle size";
47-
const rollupSize = skipBundlerTests ? undefined : await getRollupSize(bundlersContext);
45+
console.info(`[${packageName}] calculating rollup full bundle size`);
46+
const rollupSize = skipBundlerTests ? undefined : await getRollupSize(bundlersContext);
4847

49-
task.output = "calculating esbuild full bundle size";
50-
const esbuildSize = skipBundlerTests ? undefined : await getEsbuildSize(bundlersContext);
48+
console.info(`[${packageName}] calculating esbuild full bundle size`);
49+
const esbuildSize = skipBundlerTests ? undefined : await getEsbuildSize(bundlersContext);
5150

52-
task.output = "output results";
53-
const packageVersion = JSON.parse(
54-
await fsPromise.readFile(
55-
join(options.workspacePackages.filter((pkg) => pkg.name === options.packageName)[0].location, "package.json"),
56-
"utf8"
57-
)
58-
).version;
59-
options.output.push({
60-
name: options.packageName,
61-
version: packageVersion,
62-
...npmSizeResult,
63-
webpackSize,
64-
esbuildSize,
65-
rollupSize,
66-
});
67-
} catch (e) {
68-
e.message = `[${options.packageName}]` + e.message;
69-
}
70-
};
51+
console.info(`[${packageName}] output results`);
52+
const packageVersion = JSON.parse(
53+
await fsPromise.readFile(
54+
join(options.workspacePackages.filter((pkg) => pkg.name === options.packageName)[0].location, "package.json"),
55+
"utf8"
56+
)
57+
).version;
58+
options.output.push({
59+
name: options.packageName,
60+
version: packageVersion,
61+
...npmSizeResult,
62+
webpackSize,
63+
esbuildSize,
64+
rollupSize,
65+
});
66+
} catch (e) {
67+
e.message = `[${options.packageName}] ` + e.message;
68+
}
69+
};

scripts/benchmark-size/runner/cli.ts

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,51 @@
1-
#!/usr/bin/env ts-node
21
import yargs from "yargs";
32

43
import {
54
DEFAULT_LIMIT_CONFIG_PATH,
65
DEFAULT_RAW_OUTPUT_PATH,
76
DEFAULT_REPORT_PATH,
87
DEFAULT_TEST_SCOPE,
9-
} from "./constants";
10-
import { sizeReport, SizeReportOptions } from "./index";
8+
} from "./constants.js";
9+
import { sizeReport, SizeReportOptions } from "./index.js";
1110

12-
(async () => {
13-
const args = yargs
14-
.option("since", {
15-
type: "string",
16-
choices: ["all", "last_release", "main"],
17-
default: "all",
18-
description: "Run the size benchmark on changed package since last release or main branch",
19-
})
20-
.option("scopeConfigPath", {
21-
type: "string",
22-
default: DEFAULT_TEST_SCOPE,
23-
})
24-
.option("limitConfigPath", {
25-
type: "string",
26-
default: DEFAULT_LIMIT_CONFIG_PATH,
27-
})
28-
.option("skipLocalPublish", {
29-
type: "boolean",
30-
default: false,
31-
describe:
32-
"Skip publishing the packages locally. You can skip it if you didn't change any packages since last execution",
33-
})
34-
.option("rawOutputPath", {
35-
type: "string",
36-
default: DEFAULT_RAW_OUTPUT_PATH,
37-
})
38-
.option("reportPath", {
39-
type: "string",
40-
default: DEFAULT_REPORT_PATH,
41-
})
42-
.option("skipRawOutput", {
43-
type: "boolean",
44-
default: false,
45-
describe: "Whether to generate the raw benchmark data to configured path",
46-
})
47-
.help().argv;
48-
try {
49-
await sizeReport(args as SizeReportOptions);
50-
} catch (e) {
51-
console.error(e);
52-
process.exit(1);
53-
}
54-
})();
11+
const args = yargs(process.argv.slice(2))
12+
.option("since", {
13+
type: "string",
14+
choices: ["all", "last_release", "main"],
15+
default: "all",
16+
description: "Run the size benchmark on changed package since last release or main branch",
17+
})
18+
.option("scopeConfigPath", {
19+
type: "string",
20+
default: DEFAULT_TEST_SCOPE,
21+
})
22+
.option("limitConfigPath", {
23+
type: "string",
24+
default: DEFAULT_LIMIT_CONFIG_PATH,
25+
})
26+
.option("skipLocalPublish", {
27+
type: "boolean",
28+
default: false,
29+
describe:
30+
"Skip publishing the packages locally. You can skip it if you didn't change any packages since last execution",
31+
})
32+
.option("rawOutputPath", {
33+
type: "string",
34+
default: DEFAULT_RAW_OUTPUT_PATH,
35+
})
36+
.option("reportPath", {
37+
type: "string",
38+
default: DEFAULT_REPORT_PATH,
39+
})
40+
.option("skipRawOutput", {
41+
type: "boolean",
42+
default: false,
43+
describe: "Whether to generate the raw benchmark data to configured path",
44+
})
45+
.help().argv;
46+
try {
47+
await sizeReport(args as SizeReportOptions);
48+
} catch (e) {
49+
console.error(e);
50+
process.exit(1);
51+
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { join } from "path";
1+
import { dirname, join } from "path";
2+
import { fileURLToPath } from "url";
23

3-
export const DEFAULT_TEST_SCOPE = join(__dirname, "..", "scope.json");
4-
export const DEFAULT_BUNDLERS_CONFIG = join(__dirname, "..", "bundlers.json");
5-
export const PROJECT_TEMPLATES_DIR = join(__dirname, "templates");
6-
export const PROJECT_ROOT = join(__dirname, "..", "..", "..");
4+
const dir = dirname(fileURLToPath(import.meta.url));
5+
export const DEFAULT_TEST_SCOPE = join(dir, "..", "scope.json");
6+
export const DEFAULT_BUNDLERS_CONFIG = join(dir, "..", "bundlers.json");
7+
export const PROJECT_TEMPLATES_DIR = join(dir, "templates");
8+
export const PROJECT_ROOT = join(dir, "..", "..", "..");
79
export const DEFAULT_RAW_OUTPUT_PATH = join(PROJECT_ROOT, "benchmark", "size", "raw");
810
export const DEFAULT_REPORT_PATH = join(PROJECT_ROOT, "benchmark", "size", "report.md");
9-
export const DEFAULT_LIMIT_CONFIG_PATH = join(__dirname, "..", "limit.json");
11+
export const DEFAULT_LIMIT_CONFIG_PATH = join(dir, "..", "limit.json");
1012
export const PORT = 4873;

scripts/benchmark-size/runner/index.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { appendFileSync, mkdirSync, promises as fsPromise, readFileSync, rmdirSync } from "fs";
22
import { ensureDirSync, ensureFile } from "fs-extra";
33
import hbs from "handlebars";
4-
import { Listr } from "listr2";
54
import { tmpdir } from "os";
5+
import map from "p-map";
66
import { join } from "path";
77

8-
import { getPackageSizeReportRunner, PackageSizeReportOutput } from "./calculate-size";
8+
import { generatePackageSizeReport, PackageSizeReportOutput } from "./calculate-size/index.js";
99
import {
1010
DEFAULT_LIMIT_CONFIG_PATH,
1111
DEFAULT_RAW_OUTPUT_PATH,
1212
DEFAULT_REPORT_PATH,
1313
PORT,
1414
PROJECT_TEMPLATES_DIR,
15-
} from "./constants";
16-
import { loadPackageContext } from "./load-test-scope";
17-
import { localPublishChangedPackages, spawnLocalRegistry } from "./local-registry";
18-
import { updateReport } from "./reporter";
19-
import { sleep, validateRuntime } from "./utils";
20-
import { loadWorkspacePackages, SinceOption, validatePackagesAlreadyBuilt, WorkspacePackage } from "./workspace";
15+
} from "./constants.js";
16+
import { loadPackageContext } from "./load-test-scope.js";
17+
import { localPublishChangedPackages, spawnLocalRegistry } from "./local-registry.js";
18+
import { updateReport } from "./reporter/index.js";
19+
import { sleep, validateRuntime } from "./utils.js";
20+
import { loadWorkspacePackages, SinceOption, validatePackagesAlreadyBuilt, WorkspacePackage } from "./workspace.js";
2121

2222
export interface SizeReportContext {
2323
localRegistry: string;
@@ -91,19 +91,18 @@ export const sizeReport = async (options: SizeReportOptions) => {
9191
// Wait for the register to spin up.
9292
await sleep(1000);
9393
const sizeReportContext = await getSizeReportContext({ port: PORT });
94-
const tasks = new Listr(
95-
packageContextToTest.map((packageContext) => ({
96-
title: packageContext.package,
97-
task: getPackageSizeReportRunner({
98-
...sizeReportContext,
99-
packageName: packageContext.package,
100-
packageContext,
101-
}),
102-
})),
103-
{ concurrent: 10 }
104-
);
10594
try {
106-
await tasks.run();
95+
await map(
96+
packageContextToTest,
97+
async (packageContext) => {
98+
await generatePackageSizeReport({
99+
...sizeReportContext,
100+
packageName: packageContext.package,
101+
packageContext,
102+
});
103+
},
104+
{ concurrency: 10 }
105+
);
107106
} finally {
108107
localRegistryProcess.kill();
109108
rmdirSync(sizeReportContext.tmpDir, { recursive: true });

scripts/benchmark-size/runner/load-test-scope.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFileSync } from "fs";
22

3-
import { DEFAULT_TEST_SCOPE } from "./constants";
4-
import { loadWorkspacePackages } from "./workspace";
3+
import { DEFAULT_TEST_SCOPE } from "./constants.js";
4+
import { loadWorkspacePackages } from "./workspace.js";
55

66
export type PackageContext = {
77
package: string;

scripts/benchmark-size/runner/local-registry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import exec from "execa";
1+
import { execa as exec } from "execa";
22
import { readdirSync } from "fs";
33
import { join } from "path";
44

5-
import { PROJECT_ROOT } from "./constants";
5+
import { PROJECT_ROOT } from "./constants.js";
66

77
/**
88
* Publish the changed packages locally using Verdaccio. Return the path containing
@@ -25,4 +25,5 @@ export const localPublishChangedPackages = async (): Promise<string> => {
2525
export const spawnLocalRegistry = (port: number) =>
2626
exec("npx", ["verdaccio", "-c", "verdaccio/config.yaml", "-l", "" + port], {
2727
cwd: PROJECT_ROOT,
28+
stdio: "inherit",
2829
});

0 commit comments

Comments
 (0)