feat(dev-infra): add support for new global approvers in pullapprove (#36324)
Pullapprove as added a few new features to allow for us to better execute our expectation for global approvals. We need to allow for an expectation that our global approver groups are not in the list of approved groups. Additionally, since approval groups apply to all files in the repo, the global approval groups also do not have conditions defined for them, which means pullapprove verification need to allow for no conditions need to be defined. PR Close #36324
This commit is contained in:
parent
fe2b6923ba
commit
719224bffd
|
@ -34,6 +34,7 @@ const CONDITION_TYPES = {
|
||||||
INCLUDE_GLOBS: /^contains_any_globs/,
|
INCLUDE_GLOBS: /^contains_any_globs/,
|
||||||
EXCLUDE_GLOBS: /^not contains_any_globs/,
|
EXCLUDE_GLOBS: /^not contains_any_globs/,
|
||||||
ATTR_LENGTH: /^len\(.*\)/,
|
ATTR_LENGTH: /^len\(.*\)/,
|
||||||
|
GLOBAL_APPROVAL: /^global-(docs-)?approvers not in groups.approved$/,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A PullApprove group to be able to test files against. */
|
/** A PullApprove group to be able to test files against. */
|
||||||
|
@ -48,6 +49,7 @@ export class PullApproveGroup {
|
||||||
public hasMatchers = false;
|
public hasMatchers = false;
|
||||||
|
|
||||||
constructor(public groupName: string, group: PullApproveGroupConfig) {
|
constructor(public groupName: string, group: PullApproveGroupConfig) {
|
||||||
|
if (group.conditions) {
|
||||||
for (let condition of group.conditions) {
|
for (let condition of group.conditions) {
|
||||||
condition = condition.trim();
|
condition = condition.trim();
|
||||||
|
|
||||||
|
@ -71,6 +73,8 @@ export class PullApproveGroup {
|
||||||
this.hasMatchers = true;
|
this.hasMatchers = true;
|
||||||
} else if (condition.match(CONDITION_TYPES.ATTR_LENGTH)) {
|
} else if (condition.match(CONDITION_TYPES.ATTR_LENGTH)) {
|
||||||
// Currently a noop as we do not take any action on this condition type.
|
// Currently a noop as we do not take any action on this condition type.
|
||||||
|
} else if (condition.match(CONDITION_TYPES.GLOBAL_APPROVAL)) {
|
||||||
|
// Currently a noop as we don't take any action for global approval conditions.
|
||||||
} else {
|
} else {
|
||||||
const errMessage =
|
const errMessage =
|
||||||
`Unrecognized condition found, unable to parse the following condition: \n\n` +
|
`Unrecognized condition found, unable to parse the following condition: \n\n` +
|
||||||
|
@ -88,6 +92,7 @@ export class PullApproveGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Retrieve all of the lines which were not able to be parsed. */
|
/** Retrieve all of the lines which were not able to be parsed. */
|
||||||
getBadLines(): string[] { return this.misconfiguredLines; }
|
getBadLines(): string[] { return this.misconfiguredLines; }
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
import {parse as parseYaml} from 'yaml';
|
import {parse as parseYaml} from 'yaml';
|
||||||
|
|
||||||
export interface PullApproveGroupConfig {
|
export interface PullApproveGroupConfig {
|
||||||
conditions: string;
|
conditions?: string;
|
||||||
reviewers: {
|
reviewers: {
|
||||||
users: string[],
|
users: string[],
|
||||||
|
teams?: string[],
|
||||||
|
}|{
|
||||||
teams: string[],
|
teams: string[],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue