Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(cdk-build): Include lint commands in build timing info. #27326

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 9 additions & 2 deletions tools/@aws-cdk/cdk-build-tools/bin/cdk-lint.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(`Lint times for ${currentPackageJson().name}: ${timers.display()}\n`);
});
14 changes: 9 additions & 5 deletions tools/@aws-cdk/cdk-build-tools/lib/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function lintCurrentPackage(
options: CDKBuildOptions,
timers: Timers,
compilers: CompilerOverrides & { fix?: boolean } = {}): Promise<void> {
const env = options.env;
const fixOption = compilers.fix ? ['--fix'] : [];

Expand All @@ -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')) {
Expand All @@ -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 });
}
Loading