From eff5a81d738984333c8c5113f26c9dc99cff9d05 Mon Sep 17 00:00:00 2001 From: Mike Wrighton Date: Wed, 27 Sep 2023 18:10:01 -0400 Subject: [PATCH 1/2] Include lint commands in build timing info. --- tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts | 2 +- tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts | 11 +++++++++-- tools/@aws-cdk/cdk-build-tools/lib/lint.ts | 14 +++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts b/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts index 2a250ac14b810..0507b33126ff2 100644 --- a/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts +++ b/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts @@ -57,7 +57,7 @@ async function main() { const overrides: CompilerOverrides = { eslint: args.eslint, jsii: args.jsii, tsc: args.tsc }; await compileCurrentPackage(options, timers, overrides); if (!args['skip-lint']) { - await lintCurrentPackage(options, { ...overrides, fix: args.fix }); + await lintCurrentPackage(options, timers, { ...overrides, fix: args.fix }); } if (options.post) { diff --git a/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts b/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts index 25fc45c33944b..dff27d27a3fbc 100644 --- a/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts +++ b/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts @@ -1,6 +1,7 @@ import * as yargs from 'yargs'; import { lintCurrentPackage } from '../lib/lint'; -import { cdkBuildOptions } from '../lib/package-info'; +import { cdkBuildOptions, currentPackageJson } from '../lib/package-info'; +import { Timers } from '../lib/timer'; async function main() { const args = yargs @@ -19,11 +20,17 @@ async function main() { const options = cdkBuildOptions(); - await lintCurrentPackage(options, { eslint: args.eslint, fix: args.fix }); + await lintCurrentPackage(options, timers, { eslint: args.eslint, fix: args.fix }); } +const timers = new Timers(); +const buildTimer = timers.start('Total time'); + main().catch(e => { process.stderr.write(`${e.toString()}\n`); process.stderr.write('Linting failed.\n'); process.exit(1); +}).finally(() => { + buildTimer.end(); + process.stdout.write(`Build times for ${currentPackageJson().name}: ${timers.display()}\n`); }); diff --git a/tools/@aws-cdk/cdk-build-tools/lib/lint.ts b/tools/@aws-cdk/cdk-build-tools/lib/lint.ts index b9a174c04eda2..912f3da6cbe9e 100644 --- a/tools/@aws-cdk/cdk-build-tools/lib/lint.ts +++ b/tools/@aws-cdk/cdk-build-tools/lib/lint.ts @@ -3,8 +3,12 @@ import * as process from 'process'; import * as fs from 'fs-extra'; import { shell, escape } from './os'; import { CDKBuildOptions, CompilerOverrides } from './package-info'; +import { Timers } from './timer'; -export async function lintCurrentPackage(options: CDKBuildOptions, compilers: CompilerOverrides & { fix?: boolean } = {}): Promise { +export async function lintCurrentPackage( + options: CDKBuildOptions, + timers: Timers, + compilers: CompilerOverrides & { fix?: boolean } = {}): Promise { const env = options.env; const fixOption = compilers.fix ? ['--fix'] : []; @@ -15,14 +19,14 @@ export async function lintCurrentPackage(options: CDKBuildOptions, compilers: Co '--ext=.ts', `--resolve-plugins-relative-to=${__dirname}`, ...fixOption, - ], { env }); + ], { timers, env }); } if (!options.pkglint?.disable) { await shell([ 'pkglint', ...fixOption, - ], { env }); + ], { timers, env }); } if (await fs.pathExists('README.md')) { @@ -34,8 +38,8 @@ export async function lintCurrentPackage(options: CDKBuildOptions, compilers: Co '--config', path.resolve(__dirname, '..', 'config', 'markdownlint.json'), ...fixOption, 'README.md', - ]); + ], { timers }); } - await shell([path.join(__dirname, '..', 'bin', 'cdk-awslint')], { env }); + await shell([path.join(__dirname, '..', 'bin', 'cdk-awslint')], { timers, env }); } From b652f3b9ac6aa318056c7d3d50c7789e42da8af2 Mon Sep 17 00:00:00 2001 From: mikewrighton Date: Thu, 28 Sep 2023 09:45:25 -0400 Subject: [PATCH 2/2] Update tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts Co-authored-by: Momo Kornher --- tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts b/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts index dff27d27a3fbc..5d451b9085b38 100644 --- a/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts +++ b/tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts @@ -32,5 +32,5 @@ main().catch(e => { process.exit(1); }).finally(() => { buildTimer.end(); - process.stdout.write(`Build times for ${currentPackageJson().name}: ${timers.display()}\n`); + process.stdout.write(`Lint times for ${currentPackageJson().name}: ${timers.display()}\n`); });