Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add any-of-labels option #319

Merged
merged 10 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/constants/default-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
closePrLabel: '',
exemptPrLabels: '',
onlyLabels: '',
anyOfLabels: '',
operationsPerRun: 100,
debugOnly: true,
removeStaleWhenUpdated: false,
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ inputs:
description: 'Only issues or pull requests with all of these labels are checked if stale. Defaults to `[]` (disabled) and can be a comma-separated list of labels.'
default: ''
required: false
any-of-labels:
description: 'Only issues or pull requests with one of these labels are checked if stale. Defaults to `[]` (disabled) and can be a comma-separated list of labels.'
joeveiga marked this conversation as resolved.
Show resolved Hide resolved
default: ''
required: false
operations-per-run:
description: 'The maximum number of operations per run, used to control rate limiting (GitHub API CRUD related).'
default: '30'
Expand Down
7 changes: 7 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ class IssuesProcessor {
issueLogger.info(`Skipping ${issueType} because it has an exempt label`);
continue; // don't process exempt issues
}
const anyOfLabels = words_to_list_1.wordsToList(this.options.anyOfLabels);
if (anyOfLabels.length &&
!anyOfLabels.some((label) => is_labeled_1.isLabeled(issue, label))) {
issueLogger.info(`Skipping ${issueType} because it does not have any of the required labels`);
continue; // don't process issues without any of the required labels
}
const milestones = new milestones_1.Milestones(this.options, issue);
if (milestones.shouldExemptMilestones()) {
issueLogger.info(`Skipping ${issueType} because it has an exempt milestone`);
Expand Down Expand Up @@ -987,6 +993,7 @@ function _getAndValidateArgs() {
closePrLabel: core.getInput('close-pr-label'),
exemptPrLabels: core.getInput('exempt-pr-labels'),
onlyLabels: core.getInput('only-labels'),
anyOfLabels: core.getInput('any-of-labels'),
operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })),
removeStaleWhenUpdated: !(core.getInput('remove-stale-when-updated') === 'false'),
debugOnly: core.getInput('debug-only') === 'true',
Expand Down
1 change: 1 addition & 0 deletions src/classes/issue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Issue', (): void => {
exemptPrLabels: '',
exemptPrMilestones: '',
onlyLabels: '',
anyOfLabels: '',
operationsPerRun: 0,
removeStaleWhenUpdated: false,
repoToken: '',
Expand Down
13 changes: 13 additions & 0 deletions src/classes/issues-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ export class IssuesProcessor {
continue; // don't process exempt issues
}

const anyOfLabels: string[] = wordsToList(this.options.anyOfLabels);
if (
anyOfLabels.length &&
!anyOfLabels.some((label: Readonly<string>): boolean =>
isLabeled(issue, label)
)
) {
joeveiga marked this conversation as resolved.
Show resolved Hide resolved
issueLogger.info(
`Skipping ${issueType} because it does not have any of the required labels`
);
continue; // don't process issues without any of the required labels
}

const milestones: Milestones = new Milestones(this.options, issue);

if (milestones.shouldExemptMilestones()) {
Expand Down
1 change: 1 addition & 0 deletions src/classes/milestones.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('Milestones', (): void => {
exemptIssueLabels: '',
exemptPrLabels: '',
onlyLabels: '',
anyOfLabels: '',
operationsPerRun: 0,
removeStaleWhenUpdated: false,
repoToken: '',
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/issues-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface IIssuesProcessorOptions {
closePrLabel: string;
exemptPrLabels: string;
onlyLabels: string;
anyOfLabels: string;
operationsPerRun: number;
removeStaleWhenUpdated: boolean;
debugOnly: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
closePrLabel: core.getInput('close-pr-label'),
exemptPrLabels: core.getInput('exempt-pr-labels'),
onlyLabels: core.getInput('only-labels'),
anyOfLabels: core.getInput('any-of-labels'),
operationsPerRun: parseInt(
core.getInput('operations-per-run', {required: true})
),
Expand Down