refactor(dev-infra): Add support for groups in the conditions evaluator (#38164)
Conditions can refer to the groups array that is a list of the preceding groups. This commit adds support to the verification for those conditions. This commit also adds some tests to the parsing and condition matching to ensure everything works as expected. PR Close #38164
This commit is contained in:

committed by
Michael Prentice

parent
06356d806a
commit
1d46ef38d2
@ -6,6 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {parse as parseYaml} from 'yaml';
|
||||
import {PullApproveGroup} from './group';
|
||||
|
||||
export interface PullApproveGroupConfig {
|
||||
conditions?: string[];
|
||||
@ -33,3 +34,12 @@ export interface PullApproveConfig {
|
||||
export function parsePullApproveYaml(rawYaml: string): PullApproveConfig {
|
||||
return parseYaml(rawYaml, {merge: true}) as PullApproveConfig;
|
||||
}
|
||||
|
||||
/** Parses all of the groups defined in the pullapprove yaml. */
|
||||
export function getGroupsFromYaml(pullApproveYamlRaw: string): PullApproveGroup[] {
|
||||
/** JSON representation of the pullapprove yaml file. */
|
||||
const pullApprove = parsePullApproveYaml(pullApproveYamlRaw);
|
||||
return Object.entries(pullApprove.groups).reduce((groups, [groupName, group]) => {
|
||||
return groups.concat(new PullApproveGroup(groupName, group, groups));
|
||||
}, [] as PullApproveGroup[]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user