Skip to content

Commit bc26c27

Browse files
committed
build: validate that templates are updated before submitting
1 parent 3bf3295 commit bc26c27

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
- run: npm install --quiet
2121
- run: npm run lint
2222

23-
commits:
23+
validate:
2424
<<: *defaults
2525
steps:
2626
- checkout
2727
- restore_cache:
2828
key: angular_devkit-{{ checksum "package-lock.json" }}
2929

3030
- run: npm install --quiet
31-
- run: npm run validate-commits
31+
- run: npm run validate
3232

3333
test:
3434
<<: *defaults
@@ -87,7 +87,7 @@ workflows:
8787
default_workflow:
8888
jobs:
8989
- lint
90-
- commits
90+
- validate
9191
- build
9292
- test
9393
- integration

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
"build-tsc": "tsc -p tsconfig.json",
1919
"fix": "npm run admin -- lint --fix",
2020
"lint": "npm run admin -- lint",
21+
"templates": "node ./bin/devkit-admin templates",
2122
"test": "node ./bin/devkit-admin test",
2223
"test:watch": "nodemon --watch packages -e ts ./bin/devkit-admin test",
24+
"validate": "node ./bin/devkit-admin validate",
2325
"validate-commits": "./bin/devkit-admin validate-commits",
2426
"integration": "npm run build && npm run integration:build-optimizer",
2527
"integration:build-optimizer": "npm run integration:build-optimizer:simple && npm run integration:build-optimizer:aio",

scripts/validate.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
import { Logger, tags } from '@angular-devkit/core';
9+
import { execSync } from 'child_process';
10+
import templates from './templates';
11+
import validateCommits from './validate-commits';
12+
13+
export default function (_: {}, logger: Logger) {
14+
logger.info('Running templates validation...');
15+
16+
if (execSync(`git status --porcelain`).toString()) {
17+
logger.fatal('There are local changes...');
18+
process.exit(1);
19+
}
20+
templates({}, logger.createChild('templates'));
21+
if (execSync(`git status --porcelain`).toString()) {
22+
logger.fatal(tags.oneLine`
23+
Running templates updated files... Please run "devkit-admin templates" before submitting
24+
a PR.
25+
`);
26+
process.exit(2);
27+
}
28+
29+
logger.info('Running commit validation...');
30+
validateCommits({}, logger.createChild('validate-commits'));
31+
}

0 commit comments

Comments
 (0)