2020-08-26 16:49:43 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2020-10-01 19:06:56 -04:00
|
|
|
import {GitClient} from '../../utils/git/index';
|
2020-08-26 16:49:43 -04:00
|
|
|
import {getCaretakerConfig} from '../config';
|
|
|
|
|
2020-09-14 14:24:15 -04:00
|
|
|
import {CiModule} from './ci';
|
|
|
|
import {G3Module} from './g3';
|
|
|
|
import {GithubQueriesModule} from './github';
|
|
|
|
import {ServicesModule} from './services';
|
2020-08-26 16:49:43 -04:00
|
|
|
|
2020-09-14 14:24:15 -04:00
|
|
|
/** List of modules checked for the caretaker check command. */
|
|
|
|
const moduleList = [
|
|
|
|
GithubQueriesModule,
|
|
|
|
ServicesModule,
|
|
|
|
CiModule,
|
|
|
|
G3Module,
|
|
|
|
];
|
2020-08-26 16:49:43 -04:00
|
|
|
|
|
|
|
/** Check the status of services which Angular caretakers need to monitor. */
|
|
|
|
export async function checkServiceStatuses(githubToken: string) {
|
|
|
|
/** The configuration for the caretaker commands. */
|
|
|
|
const config = getCaretakerConfig();
|
|
|
|
/** The GitClient for interacting with git and Github. */
|
|
|
|
const git = new GitClient(githubToken, config);
|
2020-10-28 13:22:15 -04:00
|
|
|
// Prevent logging of the git commands being executed during the check.
|
|
|
|
GitClient.LOG_COMMANDS = false;
|
2020-09-14 14:24:15 -04:00
|
|
|
/** List of instances of Caretaker Check modules */
|
|
|
|
const caretakerCheckModules = moduleList.map(module => new module(git, config));
|
2020-08-26 16:49:43 -04:00
|
|
|
|
2020-09-14 14:24:15 -04:00
|
|
|
// Module's `data` is casted as Promise<unknown> because the data types of the `module`'s `data`
|
|
|
|
// promises do not match typings, however our usage here is only to determine when the promise
|
|
|
|
// resolves.
|
|
|
|
await Promise.all(caretakerCheckModules.map(module => module.data as Promise<unknown>));
|
|
|
|
|
|
|
|
for (const module of caretakerCheckModules) {
|
|
|
|
await module.printToTerminal();
|
|
|
|
}
|
2020-08-26 16:49:43 -04:00
|
|
|
}
|