From 1c81c38e2fc2641d73887d8221b1825af3182a1a Mon Sep 17 00:00:00 2001 From: TESTELIN Geoffrey Date: Fri, 8 Oct 2021 20:18:01 +0200 Subject: [PATCH] feat: remove the any-of-labels option BREAKING CHANGE: The option any-of-labels was removed --- README.md | 30 +- __tests__/any-of-labels.spec.ts | 1680 +++++++------------- action.yml | 8 +- dist/index.js | 19 +- src/classes/issue.spec.ts | 1 - src/classes/issues-processor.ts | 14 +- src/enums/option.ts | 3 +- src/interfaces/issues-processor-options.ts | 1 - src/main.ts | 1 - 9 files changed, 562 insertions(+), 1195 deletions(-) diff --git a/README.md b/README.md index 11fbd0a8..9191b5da 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,8 @@ Every argument is optional. | [only-labels](#only-labels) | Only issues/PRs with ALL these labels are checked | | | [only-issue-labels](#only-issue-labels) | Override [only-labels](#only-labels) for issues only | | | [only-pr-labels](#only-pr-labels) | Override [only-labels](#only-labels) for PRs only | | -| [any-of-labels](#any-of-labels) | Only issues/PRs with ANY of these labels are checked | | -| [any-of-issue-labels](#any-of-issue-labels) | Override [any-of-labels](#any-of-labels) for issues only | | -| [any-of-pr-labels](#any-of-pr-labels) | Override [any-of-labels](#any-of-labels) for PRs only | | +| [any-of-issue-labels](#any-of-issue-labels) | Only issues with ANY of these labels are checked | | +| [any-of-pr-labels](#any-of-pr-labels) | Only PRs with ANY of these labels are checked | | | [operations-per-run](#operations-per-run) | Max number of operations per run | `30` | | [remove-stale-when-updated](#remove-stale-when-updated) | Remove stale label from issues/PRs on updates | `true` | | [remove-issue-stale-when-updated](#remove-issue-stale-when-updated) | Remove stale label from issues on updates/comments | | @@ -117,7 +116,8 @@ You can fine tune which issues or pull requests should be marked as stale based - [exempt-issue-labels](#exempt-issue-labels) - [exempt-pr-labels](#exempt-pr-labels) - [only-labels](#only-labels) -- [any-of-labels](#any-of-labels) +- [any-of-issue-labels](#any-of-issue-labels) +- [any-of-pr-labels](#any-of-pr-labels) - [start-date](#start-date) - [exempt-issue-milestones](#exempt-issue-milestones) - [exempt-pr-milestones](#exempt-pr-milestones) @@ -260,7 +260,7 @@ It can be a comma separated list of labels (e.g: `answered,needs-rebase`). If unset (or an empty string), this option will not alter the stale workflow. -If you wish to only check that the issues or the pull requests contain one of these label(s), use instead [any-of-labels](#any-of-labels). +If you wish to only check that the issues or the pull requests contain one of these label(s), use instead [any-of-issue-labels](#any-of-issue-labels) and [any-of-pr-labels](#any-of-pr-labels). Default value: unset @@ -276,9 +276,9 @@ Override [only-labels](#only-labels) but only to process the pull requests that Default value: unset -#### any-of-labels +#### any-of-issue-labels -An allow-list of label(s) to only process the issues or the pull requests that contain one of these label(s). +An allow-list of label(s) to only process the issues that contain one of these label(s). It can be a comma separated list of labels (e.g: `answered,needs-rebase`). If unset (or an empty string), this option will not alter the stale workflow. @@ -287,15 +287,14 @@ If you wish to only check that the issues or the pull requests contain all these Default value: unset -#### any-of-issue-labels - -Override [any-of-labels](#any-of-labels) but only to process the issues that contain one of these label(s). - -Default value: unset - #### any-of-pr-labels -Override [any-of-labels](#any-of-labels) but only to process the pull requests that contain one of these label(s). +An allow-list of label(s) to only process the pull requests that contain one of these label(s). +It can be a comma separated list of labels (e.g: `answered,needs-rebase`). + +If unset (or an empty string), this option will not alter the stale workflow. + +If you wish to only check that the issues or the pull requests contain all these label(s), use instead [only-labels](#only-labels). Default value: unset @@ -667,7 +666,8 @@ jobs: steps: - uses: actions/stale@v4 with: - any-of-labels: 'needs-more-info,needs-demo' + any-of-issue-labels: 'needs-more-info,needs-demo' + any-of-pr-labels: 'needs-more-info,needs-demo' # You can opt for 'only-labels' instead if your use-case requires all labels # to be present in the issue/PR ``` diff --git a/__tests__/any-of-labels.spec.ts b/__tests__/any-of-labels.spec.ts index ba3ba501..a1f2fd7a 100644 --- a/__tests__/any-of-labels.spec.ts +++ b/__tests__/any-of-labels.spec.ts @@ -1,1147 +1,533 @@ -import {Issue} from '../src/classes/issue'; -import {IIssue} from '../src/interfaces/issue'; -import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options'; -import {IssuesProcessorMock} from './classes/issues-processor-mock'; -import {DefaultProcessorOptions} from './constants/default-processor-options'; -import {generateIssue} from './functions/generate-issue'; - -let issuesProcessorBuilder: IssuesProcessorBuilder; -let issuesProcessor: IssuesProcessorMock; - -describe('any-of-labels options', (): void => { - beforeEach((): void => { - issuesProcessorBuilder = new IssuesProcessorBuilder(); - }); - - test('should stale when not set even if the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfLabels() - .issuesOrPrs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when not set even if the issue has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfLabels() - .issuesOrPrs([{labels: [{name: 'label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should not stale when set and the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfLabels('dummy-label') - .issuesOrPrs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfLabels('dummy-label') - .issuesOrPrs([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfLabels('dummy-label') - .issuesOrPrs([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the issue has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfLabels('dummy-label') - .issuesOrPrs([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfLabels('dummy-label-1,dummy-label-2') - .issuesOrPrs([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfLabels('dummy-label-1,dummy-label-2') - .issuesOrPrs([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); -}); - -describe('any-of-issue-labels option', (): void => { - beforeEach((): void => { - issuesProcessorBuilder = new IssuesProcessorBuilder(); - }); - - describe('when the any-of-labels options is not set', (): void => { - beforeEach((): void => { - issuesProcessorBuilder.emptyAnyOfLabels(); - }); - - test('should stale when not set even if the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfIssueLabels() - .issues([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when not set even if the issue has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfIssueLabels() - .issues([{labels: [{name: 'dummy-label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should not stale when set and the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the issue has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label-1,dummy-label-2') - .issues([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label-1,dummy-label-2') - .issues([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - }); - - describe('when the any-of-labels options is set (same as any-of-issue-labels)', (): void => { - beforeEach((): void => { - issuesProcessorBuilder.anyOfLabels('dummy-label'); - }); - - test('should not stale when not set even if the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfIssueLabels() - .issues([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when not set even if the issue has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfIssueLabels() - .issues([{labels: [{name: 'label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the issue has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label-1,dummy-label-2') - .issues([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label-1,dummy-label-2') - .issues([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - }); - - describe('when the any-of-labels options is set (different than any-of-issue-labels)', (): void => { - beforeEach((): void => { - issuesProcessorBuilder.anyOfLabels('dummy-any-of-label'); - }); - - test('should not stale when not set even if the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfIssueLabels() - .issues([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when not set even if the issue has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfIssueLabels() - .issues([{labels: [{name: 'label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the issue has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the issue has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label') - .issues([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label-1,dummy-label-2') - .issues([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the issue has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfIssueLabels('dummy-label-1,dummy-label-2') - .issues([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - }); -}); - -describe('any-of-pr-labels option', (): void => { - beforeEach((): void => { - issuesProcessorBuilder = new IssuesProcessorBuilder(); - }); - - describe('when the any-of-labels options is not set', (): void => { - beforeEach((): void => { - issuesProcessorBuilder.emptyAnyOfLabels(); - }); - - test('should stale when not set even if the pr has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfPrLabels() - .prs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when not set even if the pr has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfPrLabels() - .prs([{labels: [{name: 'dummy-label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should not stale when set and the pr has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the pr has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the pr has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label-1,dummy-label-2') - .prs([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the pr has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label-1,dummy-label-2') - .prs([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - }); - - describe('when the any-of-labels options is set (same as any-of-pr-labels)', (): void => { - beforeEach((): void => { - issuesProcessorBuilder.anyOfLabels('dummy-label'); - }); - - test('should not stale when not set even if the pr has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfPrLabels() - .prs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when not set even if the pr has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfPrLabels() - .prs([{labels: [{name: 'label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the pr has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the pr has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label-1,dummy-label-2') - .prs([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the pr has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label-1,dummy-label-2') - .prs([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - }); - - describe('when the any-of-labels options is set (different than any-of-pr-labels)', (): void => { - beforeEach((): void => { - issuesProcessorBuilder.anyOfLabels('dummy-any-of-label'); - }); - - test('should not stale when not set even if the pr has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfPrLabels() - .prs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when not set even if the pr has a label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .emptyAnyOfPrLabels() - .prs([{labels: [{name: 'label'}]}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has no label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([{labels: []}]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has a different label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should not stale when set and the pr has different labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'label-1' - }, - { - name: 'label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(0); - }); - - test('should stale when set and the pr has the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label') - .prs([ - { - labels: [ - { - name: 'dummy-label' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the pr has only one of the same label', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label-1,dummy-label-2') - .prs([ - { - labels: [ - { - name: 'dummy-label-1' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - - test('should stale when set and the pr has all the same labels', async (): Promise => { - expect.assertions(1); - issuesProcessor = issuesProcessorBuilder - .anyOfPrLabels('dummy-label-1,dummy-label-2') - .prs([ - { - labels: [ - { - name: 'dummy-label-1' - }, - { - name: 'dummy-label-2' - } - ] - } - ]) - .build(); - - await issuesProcessor.processIssues(); - - expect(issuesProcessor.staleIssues).toHaveLength(1); - }); - }); -}); - -class IssuesProcessorBuilder { - private _options: IIssuesProcessorOptions = { - ...DefaultProcessorOptions, - daysBeforeStale: 0 - }; - private _issues: Issue[] = []; - - anyOfLabels(labels: string): IssuesProcessorBuilder { - this._options.anyOfLabels = labels; - - return this; - } - - anyOfIssueLabels(labels: string): IssuesProcessorBuilder { - this._options.anyOfIssueLabels = labels; - - return this; - } - - anyOfPrLabels(labels: string): IssuesProcessorBuilder { - this._options.anyOfPrLabels = labels; - - return this; - } - - emptyAnyOfLabels(): IssuesProcessorBuilder { - return this.anyOfLabels(''); - } - - emptyAnyOfIssueLabels(): IssuesProcessorBuilder { - return this.anyOfIssueLabels(''); - } - - emptyAnyOfPrLabels(): IssuesProcessorBuilder { - return this.anyOfPrLabels(''); - } - - issuesOrPrs(issues: Partial[]): IssuesProcessorBuilder { - this._issues = issues.map( - (issue: Readonly>, index: Readonly): Issue => - generateIssue( - this._options, - index, - issue.title ?? 'dummy-title', - issue.updated_at ?? new Date().toDateString(), - issue.created_at ?? new Date().toDateString(), - !!issue.pull_request, - issue.labels ? issue.labels.map(label => label.name) : [] - ) - ); - - return this; - } - - issues(issues: Partial[]): IssuesProcessorBuilder { - this.issuesOrPrs( - issues.map((issue: Readonly>): Partial => { - return { - ...issue, - pull_request: null - }; - }) - ); - - return this; - } - - prs(issues: Partial[]): IssuesProcessorBuilder { - this.issuesOrPrs( - issues.map((issue: Readonly>): Partial => { - return { - ...issue, - pull_request: {key: 'value'} - }; - }) - ); - - return this; - } - - build(): IssuesProcessorMock { - return new IssuesProcessorMock( - this._options, - async p => (p === 1 ? this._issues : []), - async () => [], - async () => new Date().toDateString() - ); - } -} +import {Issue} from '../src/classes/issue'; +import {IIssue} from '../src/interfaces/issue'; +import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options'; +import {IssuesProcessorMock} from './classes/issues-processor-mock'; +import {DefaultProcessorOptions} from './constants/default-processor-options'; +import {generateIssue} from './functions/generate-issue'; + +let issuesProcessorBuilder: IssuesProcessorBuilder; +let issuesProcessor: IssuesProcessorMock; + +describe('any-of-labels options', (): void => { + beforeEach((): void => { + issuesProcessorBuilder = new IssuesProcessorBuilder(); + }); + + test('should stale when not set even if the issue has no label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .emptyAnyOfIssueLabels() + .issuesOrPrs([{labels: []}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when not set even if the issue has a label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .emptyAnyOfIssueLabels() + .issuesOrPrs([{labels: [{name: 'label'}]}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should not stale when set and the issue has no label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issuesOrPrs([{labels: []}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should not stale when set and the issue has a different label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issuesOrPrs([ + { + labels: [ + { + name: 'label' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should not stale when set and the issue has different labels', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issuesOrPrs([ + { + labels: [ + { + name: 'label-1' + }, + { + name: 'label-2' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should stale when set and the issue has the same label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issuesOrPrs([ + { + labels: [ + { + name: 'dummy-label' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when set and the issue has only one of the same label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label-1,dummy-label-2') + .issuesOrPrs([ + { + labels: [ + { + name: 'dummy-label-1' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when set and the issue has all the same labels', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label-1,dummy-label-2') + .issuesOrPrs([ + { + labels: [ + { + name: 'dummy-label-1' + }, + { + name: 'dummy-label-2' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); +}); + +describe('any-of-issue-labels option', (): void => { + beforeEach((): void => { + issuesProcessorBuilder = new IssuesProcessorBuilder(); + }); + + test('should stale when not set even if the issue has no label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .emptyAnyOfIssueLabels() + .issues([{labels: []}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when not set even if the issue has a label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .emptyAnyOfIssueLabels() + .issues([{labels: [{name: 'dummy-label'}]}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should not stale when set and the issue has no label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issues([{labels: []}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should not stale when set and the issue has a different label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issues([ + { + labels: [ + { + name: 'label' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should not stale when set and the issue has different labels', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issues([ + { + labels: [ + { + name: 'label-1' + }, + { + name: 'label-2' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should stale when set and the issue has the same label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label') + .issues([ + { + labels: [ + { + name: 'dummy-label' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when set and the issue has only one of the same label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label-1,dummy-label-2') + .issues([ + { + labels: [ + { + name: 'dummy-label-1' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when set and the issue has all the same labels', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfIssueLabels('dummy-label-1,dummy-label-2') + .issues([ + { + labels: [ + { + name: 'dummy-label-1' + }, + { + name: 'dummy-label-2' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); +}); + +describe('any-of-pr-labels option', (): void => { + beforeEach((): void => { + issuesProcessorBuilder = new IssuesProcessorBuilder(); + }); + + test('should stale when not set even if the pr has no label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .emptyAnyOfPrLabels() + .prs([{labels: []}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when not set even if the pr has a label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .emptyAnyOfPrLabels() + .prs([{labels: [{name: 'dummy-label'}]}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should not stale when set and the pr has no label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfPrLabels('dummy-label') + .prs([{labels: []}]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should not stale when set and the pr has a different label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfPrLabels('dummy-label') + .prs([ + { + labels: [ + { + name: 'label' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should not stale when set and the pr has different labels', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfPrLabels('dummy-label') + .prs([ + { + labels: [ + { + name: 'label-1' + }, + { + name: 'label-2' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(0); + }); + + test('should stale when set and the pr has the same label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfPrLabels('dummy-label') + .prs([ + { + labels: [ + { + name: 'dummy-label' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when set and the pr has only one of the same label', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfPrLabels('dummy-label-1,dummy-label-2') + .prs([ + { + labels: [ + { + name: 'dummy-label-1' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); + + test('should stale when set and the pr has all the same labels', async (): Promise => { + expect.assertions(1); + issuesProcessor = issuesProcessorBuilder + .anyOfPrLabels('dummy-label-1,dummy-label-2') + .prs([ + { + labels: [ + { + name: 'dummy-label-1' + }, + { + name: 'dummy-label-2' + } + ] + } + ]) + .build(); + + await issuesProcessor.processIssues(); + + expect(issuesProcessor.staleIssues).toHaveLength(1); + }); +}); + +class IssuesProcessorBuilder { + private _options: IIssuesProcessorOptions = { + ...DefaultProcessorOptions, + daysBeforeStale: 0 + }; + private _issues: Issue[] = []; + + anyOfIssueLabels(labels: string): IssuesProcessorBuilder { + this._options.anyOfIssueLabels = labels; + + return this; + } + + anyOfPrLabels(labels: string): IssuesProcessorBuilder { + this._options.anyOfPrLabels = labels; + + return this; + } + + emptyAnyOfIssueLabels(): IssuesProcessorBuilder { + return this.anyOfIssueLabels(''); + } + + emptyAnyOfPrLabels(): IssuesProcessorBuilder { + return this.anyOfPrLabels(''); + } + + issuesOrPrs(issues: Partial[]): IssuesProcessorBuilder { + this._issues = issues.map( + (issue: Readonly>, index: Readonly): Issue => + generateIssue( + this._options, + index, + issue.title ?? 'dummy-title', + issue.updated_at ?? new Date().toDateString(), + issue.created_at ?? new Date().toDateString(), + !!issue.pull_request, + issue.labels ? issue.labels.map(label => label.name) : [] + ) + ); + + return this; + } + + issues(issues: Partial[]): IssuesProcessorBuilder { + this.issuesOrPrs( + issues.map((issue: Readonly>): Partial => { + return { + ...issue, + pull_request: null + }; + }) + ); + + return this; + } + + prs(issues: Partial[]): IssuesProcessorBuilder { + this.issuesOrPrs( + issues.map((issue: Readonly>): Partial => { + return { + ...issue, + pull_request: {key: 'value'} + }; + }) + ); + + return this; + } + + build(): IssuesProcessorMock { + return new IssuesProcessorMock( + this._options, + async p => (p === 1 ? this._issues : []), + async () => [], + async () => new Date().toDateString() + ); + } +} diff --git a/action.yml b/action.yml index 96ff223c..3b229059 100644 --- a/action.yml +++ b/action.yml @@ -80,16 +80,12 @@ 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 at least one of these labels are checked if stale. Defaults to `` (disabled) and can be a comma-separated list of labels.' - default: '' - required: false any-of-issue-labels: - description: 'Only issues with at least one of these labels are checked if stale. Defaults to `` (disabled) and can be a comma-separated list of labels. Override "any-of-labels" option regarding only the issues.' + description: 'Only issues with at least one of these labels are checked if stale. Defaults to `` (disabled) and can be a comma-separated list of labels.' default: '' required: false any-of-pr-labels: - description: 'Only pull requests with at least one of these labels are checked if stale. Defaults to `` (disabled) and can be a comma-separated list of labels. Override "any-of-labels" option regarding only the pull requests.' + description: 'Only pull requests with at least one of these labels are checked if stale. Defaults to `` (disabled) and can be a comma-separated list of labels.' default: '' required: false only-issue-labels: diff --git a/dist/index.js b/dist/index.js index c2a96a10..7729abd8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -482,7 +482,7 @@ class IssuesProcessor { } const anyOfLabels = words_to_list_1.wordsToList(this._getAnyOfLabels(issue)); if (anyOfLabels.length > 0) { - issueLogger.info(`The option ${issueLogger.createOptionLink(option_1.Option.AnyOfLabels)} was specified to only process the issues and pull requests with one of those labels (${logger_service_1.LoggerService.cyan(anyOfLabels.length)})`); + issueLogger.info(`The option ${issueLogger.createOptionLink(issue.isPullRequest ? option_1.Option.AnyOfPrLabels : option_1.Option.AnyOfIssueLabels)} was specified to only process the issues and pull requests with one of those labels (${logger_service_1.LoggerService.cyan(anyOfLabels.length)})`); const hasOneOfWhitelistedLabels = anyOfLabels.some((label) => { return is_labeled_1.isLabeled(issue, label); }); @@ -497,7 +497,7 @@ class IssuesProcessor { } } else { - issueLogger.info(`The option ${issueLogger.createOptionLink(option_1.Option.AnyOfLabels)} was not specified`); + issueLogger.info(`The option ${issueLogger.createOptionLink(issue.isPullRequest ? option_1.Option.AnyOfPrLabels : option_1.Option.AnyOfIssueLabels)} was not specified`); issueLogger.info(logger_service_1.LoggerService.white('└──'), `Continuing the process for this $$type`); } const milestones = new milestones_1.Milestones(this.options, issue); @@ -925,16 +925,9 @@ class IssuesProcessor { } _getAnyOfLabels(issue) { if (issue.isPullRequest) { - if (this.options.anyOfPrLabels !== '') { - return this.options.anyOfPrLabels; - } + return this.options.anyOfPrLabels; } - else { - if (this.options.anyOfIssueLabels !== '') { - return this.options.anyOfIssueLabels; - } - } - return this.options.anyOfLabels; + return this.options.anyOfIssueLabels; } _shouldRemoveStaleWhenUpdated(issue) { if (issue.isPullRequest) { @@ -1774,7 +1767,8 @@ var Option; Option["OnlyLabels"] = "only-labels"; Option["OnlyIssueLabels"] = "only-issue-labels"; Option["OnlyPrLabels"] = "only-pr-labels"; - Option["AnyOfLabels"] = "any-of-labels"; + Option["AnyOfIssueLabels"] = "any-of-issue-labels"; + Option["AnyOfPrLabels"] = "any-of-pr-labels"; Option["OperationsPerRun"] = "operations-per-run"; Option["RemoveStaleWhenUpdated"] = "remove-stale-when-updated"; Option["RemoveIssueStaleWhenUpdated"] = "remove-issue-stale-when-updated"; @@ -2076,7 +2070,6 @@ function _getAndValidateArgs() { onlyLabels: core.getInput('only-labels'), onlyIssueLabels: core.getInput('only-issue-labels'), onlyPrLabels: core.getInput('only-pr-labels'), - anyOfLabels: core.getInput('any-of-labels'), anyOfIssueLabels: core.getInput('any-of-issue-labels'), anyOfPrLabels: core.getInput('any-of-pr-labels'), operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })), diff --git a/src/classes/issue.spec.ts b/src/classes/issue.spec.ts index 03426c2b..b89a3427 100644 --- a/src/classes/issue.spec.ts +++ b/src/classes/issue.spec.ts @@ -30,7 +30,6 @@ describe('Issue', (): void => { onlyLabels: '', onlyIssueLabels: '', onlyPrLabels: '', - anyOfLabels: '', anyOfIssueLabels: '', anyOfPrLabels: '', operationsPerRun: 0, diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 708bafa4..5109f026 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -345,7 +345,7 @@ export class IssuesProcessor { if (anyOfLabels.length > 0) { issueLogger.info( `The option ${issueLogger.createOptionLink( - Option.AnyOfLabels + issue.isPullRequest ? Option.AnyOfPrLabels : Option.AnyOfIssueLabels )} was specified to only process the issues and pull requests with one of those labels (${LoggerService.cyan( anyOfLabels.length )})` @@ -377,7 +377,7 @@ export class IssuesProcessor { } else { issueLogger.info( `The option ${issueLogger.createOptionLink( - Option.AnyOfLabels + issue.isPullRequest ? Option.AnyOfPrLabels : Option.AnyOfIssueLabels )} was not specified` ); issueLogger.info( @@ -997,16 +997,10 @@ export class IssuesProcessor { private _getAnyOfLabels(issue: Issue): string { if (issue.isPullRequest) { - if (this.options.anyOfPrLabels !== '') { - return this.options.anyOfPrLabels; - } - } else { - if (this.options.anyOfIssueLabels !== '') { - return this.options.anyOfIssueLabels; - } + return this.options.anyOfPrLabels; } - return this.options.anyOfLabels; + return this.options.anyOfIssueLabels; } private _shouldRemoveStaleWhenUpdated(issue: Issue): boolean { diff --git a/src/enums/option.ts b/src/enums/option.ts index 69b4c409..ec28e937 100644 --- a/src/enums/option.ts +++ b/src/enums/option.ts @@ -19,7 +19,8 @@ export enum Option { OnlyLabels = 'only-labels', OnlyIssueLabels = 'only-issue-labels', OnlyPrLabels = 'only-pr-labels', - AnyOfLabels = 'any-of-labels', + AnyOfIssueLabels = 'any-of-issue-labels', + AnyOfPrLabels = 'any-of-pr-labels', OperationsPerRun = 'operations-per-run', RemoveStaleWhenUpdated = 'remove-stale-when-updated', RemoveIssueStaleWhenUpdated = 'remove-issue-stale-when-updated', diff --git a/src/interfaces/issues-processor-options.ts b/src/interfaces/issues-processor-options.ts index 4032edd3..fdc7138d 100644 --- a/src/interfaces/issues-processor-options.ts +++ b/src/interfaces/issues-processor-options.ts @@ -21,7 +21,6 @@ export interface IIssuesProcessorOptions { onlyLabels: string; onlyIssueLabels: string; onlyPrLabels: string; - anyOfLabels: string; anyOfIssueLabels: string; anyOfPrLabels: string; operationsPerRun: number; diff --git a/src/main.ts b/src/main.ts index 35212c60..1fb6bf39 100644 --- a/src/main.ts +++ b/src/main.ts @@ -47,7 +47,6 @@ function _getAndValidateArgs(): IIssuesProcessorOptions { onlyLabels: core.getInput('only-labels'), onlyIssueLabels: core.getInput('only-issue-labels'), onlyPrLabels: core.getInput('only-pr-labels'), - anyOfLabels: core.getInput('any-of-labels'), anyOfIssueLabels: core.getInput('any-of-issue-labels'), anyOfPrLabels: core.getInput('any-of-pr-labels'), operationsPerRun: parseInt(