File tree Expand file tree Collapse file tree 6 files changed +73
-0
lines changed Expand file tree Collapse file tree 6 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ jobs:
273273 - run : yarn -s ng-dev format changed $CI_GIT_BASE_REVISION --check
274274 - run : yarn -s ts-circular-deps:check
275275 - run : yarn -s ng-dev pullapprove verify
276+ - run : yarn -s ng-dev ngbot verify
276277 - run : yarn -s ng-dev commit-message validate-range --range $CI_COMMIT_RANGE
277278
278279 test :
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ ts_library(
1111 "//dev-infra/caretaker" ,
1212 "//dev-infra/commit-message" ,
1313 "//dev-infra/format" ,
14+ "//dev-infra/ngbot" ,
1415 "//dev-infra/pr" ,
1516 "//dev-infra/pullapprove" ,
1617 "//dev-infra/release" ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {buildReleaseParser} from './release/cli';
1515import { buildPrParser } from './pr/cli' ;
1616import { captureLogOutputForCommand } from './utils/console' ;
1717import { buildCaretakerParser } from './caretaker/cli' ;
18+ import { buildNgbotParser } from './ngbot/cli' ;
1819
1920yargs . scriptName ( 'ng-dev' )
2021 . middleware ( captureLogOutputForCommand )
@@ -27,6 +28,7 @@ yargs.scriptName('ng-dev')
2728 . command ( 'release <command>' , '' , buildReleaseParser )
2829 . command ( 'ts-circular-deps <command>' , '' , tsCircularDependenciesBuilder )
2930 . command ( 'caretaker <command>' , '' , buildCaretakerParser )
31+ . command ( 'ngbot <command>' , false , buildNgbotParser )
3032 . wrap ( 120 )
3133 . strict ( )
3234 . parse ( ) ;
Original file line number Diff line number Diff line change 1+ load ("@npm_bazel_typescript//:index.bzl" , "ts_library" )
2+
3+ ts_library (
4+ name = "ngbot" ,
5+ srcs = [
6+ "cli.ts" ,
7+ "verify.ts" ,
8+ ],
9+ module_name = "@angular/dev-infra-private/ngbot" ,
10+ visibility = ["//dev-infra:__subpackages__" ],
11+ deps = [
12+ "//dev-infra/utils" ,
13+ "@npm//@types/node" ,
14+ "@npm//@types/yaml" ,
15+ "@npm//@types/yargs" ,
16+ "@npm//yaml" ,
17+ "@npm//yargs" ,
18+ ],
19+ )
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google LLC 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 * as yargs from 'yargs' ;
9+ import { verify } from './verify' ;
10+
11+ /** Build the parser for the NgBot commands. */
12+ export function buildNgbotParser ( localYargs : yargs . Argv ) {
13+ return localYargs . help ( ) . strict ( ) . demandCommand ( ) . command (
14+ 'verify' , 'Verify the NgBot config' , { } , ( ) => verify ( ) ) ;
15+ }
16+
17+ if ( require . main === module ) {
18+ buildNgbotParser ( yargs ) . parse ( ) ;
19+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google LLC 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 { readFileSync } from 'fs' ;
9+ import { resolve } from 'path' ;
10+ import { parse as parseYaml } from 'yaml' ;
11+
12+ import { getRepoBaseDir } from '../utils/config' ;
13+ import { error , green , info , red } from '../utils/console' ;
14+
15+ export function verify ( ) {
16+ /** Full path to NgBot config file */
17+ const NGBOT_CONFIG_YAML_PATH = resolve ( getRepoBaseDir ( ) , '.github/angular-robot.yml' ) ;
18+
19+ /** The NgBot config file */
20+ const ngBotYaml = readFileSync ( NGBOT_CONFIG_YAML_PATH , 'utf8' ) ;
21+
22+ try {
23+ // Try parsing the config file to verify that the syntax is correct.
24+ parseYaml ( ngBotYaml ) ;
25+ info ( `${ green ( '√' ) } Valid NgBot YAML config` ) ;
26+ } catch ( e ) {
27+ error ( `${ red ( '!' ) } Invalid NgBot YAML config` ) ;
28+ error ( e ) ;
29+ process . exitCode = 1 ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments