Skip to content

Commit 6dbfc4d

Browse files
committed
ci: validate that every package have a BUILD file
1 parent 4c7fce5 commit 6dbfc4d

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

packages/angular/pwa/BUILD

Whitespace-only changes.

scripts/validate-build-files.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
// tslint:disable:no-implicit-dependencies
9+
import { logging, tags } from '@angular-devkit/core';
10+
import { existsSync } from 'fs';
11+
import { join } from 'path';
12+
import { packages } from '../lib/packages';
13+
14+
export default function (_options: {}, logger: logging.Logger) {
15+
let error = false;
16+
17+
for (const pkgName of Object.keys(packages)) {
18+
const pkg = packages[pkgName];
19+
20+
if (pkg.packageJson.private) {
21+
// Ignore private packages.
22+
continue;
23+
}
24+
25+
// There should be at least one BUILD file next to each package.json.
26+
if (!existsSync(join(pkg.root, 'BUILD'))) {
27+
logger.error(tags.oneLine`
28+
The package ${JSON.stringify(pkgName)} does not have a BUILD file associated to it. You
29+
must either set an exception or make sure it can be built using Bazel.
30+
`);
31+
error = true;
32+
}
33+
}
34+
35+
// TODO: enable this to break
36+
if (error) {
37+
// process.exit(1);
38+
logger.warn('Found some BUILD files missing, which will be breaking your PR soon.');
39+
}
40+
}

scripts/validate.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { logging, tags } from '@angular-devkit/core';
1010
import { execSync } from 'child_process';
1111
import templates from './templates';
12+
import validateBuildFiles from './validate-build-files';
1213
import validateCommits from './validate-commits';
1314
import validateLicenses from './validate-licenses';
1415

@@ -45,6 +46,10 @@ export default function (options: { verbose: boolean }, logger: logging.Logger)
4546
logger.info('Running license validation...');
4647
validateLicenses({}, logger.createChild('validate-commits'));
4748

49+
logger.info('');
50+
logger.info('Running BUILD files validation...');
51+
validateBuildFiles({}, logger.createChild('validate-build-files'));
52+
4853
if (error) {
4954
process.exit(101);
5055
}

0 commit comments

Comments
 (0)