diff --git a/README.md b/README.md index 5e1644ae..11fbd0a8 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ You can find more information about the required permissions under the correspon Every argument is optional. | Input | Description | Default | -| ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- | ------- | +| ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- | | [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` | | [days-before-stale](#days-before-stale) | Idle number of days before marking issues/PRs stale | `60` | | [days-before-issue-stale](#days-before-issue-stale) | Override [days-before-stale](#days-before-stale) for issues only | | @@ -63,11 +63,10 @@ Every argument is optional. | [ascending](#ascending) | Order to get issues/PRs | `false` | | [start-date](#start-date) | Skip stale action for issues/PRs created before it | | | [delete-branch](#delete-branch) | Delete branch after closing a stale PR | `false` | -| [exempt-milestones](#exempt-milestones) | Milestones on issues/PRs exempted from stale | | -| [exempt-issue-milestones](#exempt-issue-milestones) | Override [exempt-milestones](#exempt-milestones) for issues only | | -| [exempt-pr-milestones](#exempt-pr-milestones) | Override [exempt-milestones](#exempt-milestones) for PRs only | | -| [exempt-all-issue-milestones](#exempt-all-issue-milestones) | Exempt all issues with milestones from stale | | `false` | -| [exempt-all-pr-milestones](#exempt-all-pr-milestones) | Exempt all PRs with milestones from stale | | `false` | +| [exempt-issue-milestones](#exempt-issue-milestones) | Milestones on issues exempted from stale | | +| [exempt-pr-milestones](#exempt-pr-milestones) | Milestones on PRs exempted from stale | | +| [exempt-all-issue-milestones](#exempt-all-issue-milestones) | Exempt all issues with milestones from stale | `false` | +| [exempt-all-pr-milestones](#exempt-all-pr-milestones) | Exempt all PRs with milestones from stale | `false` | | [exempt-issue-assignees](#exempt-issue-assignees) | Assignees on issues exempted from stale | | | [exempt-pr-assignees](#exempt-pr-assignees) | Assignees on PRs exempted from stale | | | [exempt-all-issue-assignees](#exempt-all-issue-assignees) | Exempt all issues with assignees from stale | `false` | @@ -120,7 +119,8 @@ You can fine tune which issues or pull requests should be marked as stale based - [only-labels](#only-labels) - [any-of-labels](#any-of-labels) - [start-date](#start-date) -- [exempt-milestones](#exempt-milestones) +- [exempt-issue-milestones](#exempt-issue-milestones) +- [exempt-pr-milestones](#exempt-pr-milestones) - [exempt-all-issue-milestones](#exempt-all-issue-milestones) - [exempt-all-pr-milestones](#exempt-all-pr-milestones) - [exempt-issue-assignees](#exempt-issue-assignees) @@ -391,24 +391,21 @@ If set to `true`, the stale workflow will automatically delete the GitHub branch Default value: `false` Required Permission: `pull-requests: write` -#### exempt-milestones +#### exempt-issue-milestones -A white-list of milestone(s) to only process the issues or the pull requests that does not contain one of these milestone(s). +A white-list of milestone(s) to only process the issues that does not contain one of these milestone(s). It can be a comma separated list of milestones (e.g: `V1,next`). If unset (or an empty string), this option will not alter the stale workflow. Default value: unset -#### exempt-issue-milestones - -Override [exempt-milestones](#exempt-milestones) but only to process the issues that does not contain one of these milestone(s). - -Default value: unset - #### exempt-pr-milestones -Override [exempt-milestones](#exempt-milestones) but only to process the pull requests that does not contain one of these milestone(s). +A white-list of milestone(s) to only process the pull requests that does not contain one of these milestone(s). +It can be a comma separated list of milestones (e.g: `V1,next`). + +If unset (or an empty string), this option will not alter the stale workflow. Default value: unset @@ -416,7 +413,7 @@ Default value: unset If set to `true`, the issues with a milestone will not be marked as stale automatically. -Priority over [exempt-milestones](#exempt-milestones). +Priority over [exempt-issue-milestones](#exempt-issue-milestones). Default value: `false` @@ -424,7 +421,7 @@ Default value: `false` If set to `true`, the pull requests with a milestone will not be marked as stale automatically. -Priority over [exempt-milestones](#exempt-milestones). +Priority over [exempt-pr-milestones](#exempt-pr-milestones). Default value: `false` diff --git a/__tests__/constants/default-processor-options.ts b/__tests__/constants/default-processor-options.ts index 0939ec10..e202a451 100644 --- a/__tests__/constants/default-processor-options.ts +++ b/__tests__/constants/default-processor-options.ts @@ -32,7 +32,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({ ascending: false, deleteBranch: false, startDate: '', - exemptMilestones: '', exemptIssueMilestones: '', exemptPrMilestones: '', exemptAllIssueMilestones: false, diff --git a/__tests__/main.spec.ts b/__tests__/main.spec.ts index 2abb5ee4..4153432e 100644 --- a/__tests__/main.spec.ts +++ b/__tests__/main.spec.ts @@ -1689,7 +1689,7 @@ test('an issue without a milestone will be marked as stale', async () => { test('an issue without an exempted milestone will be marked as stale', async () => { expect.assertions(3); const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1'; + opts.exemptIssueMilestones = 'Milestone1'; const TestIssueList: Issue[] = [ generateIssue( opts, @@ -1722,7 +1722,7 @@ test('an issue without an exempted milestone will be marked as stale', async () test('an issue with an exempted milestone will not be marked as stale', async () => { expect.assertions(3); const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1'; + opts.exemptIssueMilestones = 'Milestone1'; const TestIssueList: Issue[] = [ generateIssue( opts, @@ -1755,7 +1755,7 @@ test('an issue with an exempted milestone will not be marked as stale', async () test('an issue with an exempted milestone will not be marked as stale (multi milestones with spaces)', async () => { expect.assertions(3); const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1, Milestone2'; + opts.exemptIssueMilestones = 'Milestone1, Milestone2'; const TestIssueList: Issue[] = [ generateIssue( opts, @@ -1788,7 +1788,7 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil test('an issue with an exempted milestone will not be marked as stale (multi milestones without spaces)', async () => { expect.assertions(3); const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1,Milestone2'; + opts.exemptIssueMilestones = 'Milestone1,Milestone2'; const TestIssueList: Issue[] = [ generateIssue( opts, @@ -1818,108 +1818,6 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil expect(processor.removedLabelIssues.length).toStrictEqual(0); }); -test('an issue with an exempted milestone but without an exempted issue milestone will not be marked as stale', async () => { - expect.assertions(3); - const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1'; - opts.exemptIssueMilestones = ''; - const TestIssueList: Issue[] = [ - generateIssue( - opts, - 1, - 'My first issue', - '2020-01-01T17:00:00Z', - '2020-01-01T17:00:00Z', - false, - undefined, - undefined, - undefined, - 'Milestone1' - ) - ]; - const processor = new IssuesProcessorMock( - opts, - async p => (p === 1 ? TestIssueList : []), - async () => [], - async () => new Date().toDateString() - ); - - // process our fake issue list - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual(0); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); -}); - -test('an issue with an exempted milestone but with another exempted issue milestone will be marked as stale', async () => { - expect.assertions(3); - const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1'; - opts.exemptIssueMilestones = 'Milestone2'; - const TestIssueList: Issue[] = [ - generateIssue( - opts, - 1, - 'My first issue', - '2020-01-01T17:00:00Z', - '2020-01-01T17:00:00Z', - false, - undefined, - undefined, - undefined, - 'Milestone1' - ) - ]; - const processor = new IssuesProcessorMock( - opts, - async p => (p === 1 ? TestIssueList : []), - async () => [], - async () => new Date().toDateString() - ); - - // process our fake issue list - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual(1); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); -}); - -test('an issue with an exempted milestone and with an exempted issue milestone will not be marked as stale', async () => { - expect.assertions(3); - const opts = {...DefaultProcessorOptions}; - opts.exemptMilestones = 'Milestone1'; - opts.exemptIssueMilestones = 'Milestone1'; - const TestIssueList: Issue[] = [ - generateIssue( - opts, - 1, - 'My first issue', - '2020-01-01T17:00:00Z', - '2020-01-01T17:00:00Z', - false, - undefined, - undefined, - undefined, - 'Milestone1' - ) - ]; - const processor = new IssuesProcessorMock( - opts, - async p => (p === 1 ? TestIssueList : []), - async () => [], - async () => new Date().toDateString() - ); - - // process our fake issue list - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual(0); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); -}); - test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 3 will not make it stale', async () => { expect.assertions(2); const opts: IIssuesProcessorOptions = { diff --git a/__tests__/milestones.spec.ts b/__tests__/milestones.spec.ts index b94a793e..bc209ce1 100644 --- a/__tests__/milestones.spec.ts +++ b/__tests__/milestones.spec.ts @@ -84,19 +84,19 @@ describe('milestones options', (): void => { } ); - describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => { + describe('when all the issues milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone'; + opts.exemptIssueMilestones = 'dummy-issue-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${true} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${true} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} + ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} + ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -120,101 +120,21 @@ describe('milestones options', (): void => { }); } ); - - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = 'dummy-issue-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} - ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${true} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); - - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = 'dummy-pull-request-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${true} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); }); - describe('when all the issues and pull requests milestones should exempt some milestones', (): void => { + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone1, dummy-milestone2'; + opts.exemptPrMilestones = 'dummy-pull-request-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${true} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${true} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -238,88 +158,84 @@ describe('milestones options', (): void => { }); } ); + }); - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = - 'dummy-issue-milestone1, dummy-issue-milestone2'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} - ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${true} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the issues milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptIssueMilestones = + 'dummy-issue-milestone1, dummy-issue-milestone2'; }); - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = - 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; - }); + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} + ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} + ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${true} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); + await processor.processIssues(1); - await processor.processIssues(1); + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); + }); - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptPrMilestones = + 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; }); + + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); + + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); + + await processor.processIssues(1); + + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); }); }); @@ -358,19 +274,19 @@ describe('milestones options', (): void => { } ); - describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => { + describe('when all the issues milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone'; + opts.exemptIssueMilestones = 'dummy-issue-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${false} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${true} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${false} + ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} + ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -394,101 +310,21 @@ describe('milestones options', (): void => { }); } ); - - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = 'dummy-issue-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); - - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = 'dummy-pull-request-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${false} - ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${false} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${true} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); }); - describe('when all the issues and pull requests milestones should exempt some milestones', (): void => { + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone1, dummy-milestone2'; + opts.exemptPrMilestones = 'dummy-pull-request-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${false} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${true} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${false} + ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -512,88 +348,84 @@ describe('milestones options', (): void => { }); } ); + }); - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = - 'dummy-issue-milestone1, dummy-issue-milestone2'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the issues milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptIssueMilestones = + 'dummy-issue-milestone1, dummy-issue-milestone2'; }); - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = - 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; - }); + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${false} + ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} + ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${false} - ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${false} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${true} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); + await processor.processIssues(1); - await processor.processIssues(1); + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); + }); - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptPrMilestones = + 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; }); + + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${false} + ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); + + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); + + await processor.processIssues(1); + + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); }); }); @@ -632,19 +464,19 @@ describe('milestones options', (): void => { } ); - describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => { + describe('when all the issues milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone'; + opts.exemptIssueMilestones = 'dummy-issue-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${true} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${true} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} + ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} + ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -668,101 +500,21 @@ describe('milestones options', (): void => { }); } ); - - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = 'dummy-issue-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} - ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${true} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); - - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = 'dummy-pull-request-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${true} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); }); - describe('when all the issues and pull requests milestones should exempt some milestones', (): void => { + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone1, dummy-milestone2'; + opts.exemptPrMilestones = 'dummy-pull-request-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${true} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${true} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -786,88 +538,84 @@ describe('milestones options', (): void => { }); } ); + }); - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = - 'dummy-issue-milestone1, dummy-issue-milestone2'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} - ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${true} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the issues milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptIssueMilestones = + 'dummy-issue-milestone1, dummy-issue-milestone2'; }); - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = - 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; - }); + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} + ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${true} + ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${true} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${true} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); + await processor.processIssues(1); - await processor.processIssues(1); + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); + }); - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptPrMilestones = + 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; }); + + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); + + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); + + await processor.processIssues(1); + + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); }); }); @@ -906,19 +654,19 @@ describe('milestones options', (): void => { } ); - describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => { + describe('when all the issues milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone'; + opts.exemptIssueMilestones = 'dummy-issue-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${true} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${false} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} + ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${false} + ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${false} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -942,101 +690,21 @@ describe('milestones options', (): void => { }); } ); - - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = 'dummy-issue-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} - ${false} | ${'dummy-issue-milestone'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${true} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${false} - ${true} | ${'dummy-issue-milestone'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${false} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); - - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = 'dummy-pull-request-milestone'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-milestone'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); - }); }); - describe('when all the issues and pull requests milestones should exempt some milestones', (): void => { + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { beforeEach((): void => { - opts.exemptMilestones = 'dummy-milestone1, dummy-milestone2'; + opts.exemptPrMilestones = 'dummy-pull-request-milestone'; }); describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific exempted one'} | ${true} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific exempted one'} | ${false} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${false} | ${'dummy-pull-request-milestone'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${false} + ${true} | ${'dummy-pull-request-milestone'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} `( 'when $name', ({isPullRequest, milestone, shouldStale}: ITestData): void => { @@ -1060,88 +728,84 @@ describe('milestones options', (): void => { }); } ); + }); - describe('when all the issues milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptIssueMilestones = - 'dummy-issue-milestone1, dummy-issue-milestone2'; - }); - - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} - ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${true} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${false} - ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${false} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); - - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); - - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the issues milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptIssueMilestones = + 'dummy-issue-milestone1, dummy-issue-milestone2'; }); - describe('when all the pull requests milestones should exempt a specific milestone', (): void => { - beforeEach((): void => { - opts.exemptPrMilestones = - 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; - }); + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific issue exempted one'} | ${true} + ${false} | ${'dummy-issue-milestone2'} | ${'the issue does have a milestone matching the specific issue exempted one'} | ${false} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific issue exempted one'} | ${false} + ${true} | ${'dummy-issue-milestone2'} | ${'the PR does have a milestone matching the specific issue exempted one'} | ${false} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); - describe.each` - isPullRequest | milestone | name | shouldStale - ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} - ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} - ${false} | ${'dummy-milestone2'} | ${'the issue does have a milestone matching the specific exempted one'} | ${false} - ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} - ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} - ${true} | ${'dummy-milestone2'} | ${'the PR does have a milestone matching the specific exempted one'} | ${false} - `( - 'when $name', - ({isPullRequest, milestone, shouldStale}: ITestData): void => { - beforeEach((): void => { - setTestIssueList(isPullRequest, milestone); - setProcessor(); - }); + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); - test(`should${ - shouldStale ? '' : ' not' - } be marked as stale`, async () => { - expect.assertions(3); + await processor.processIssues(1); - await processor.processIssues(1); + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); + }); - expect(processor.staleIssues.length).toStrictEqual( - shouldStale ? 1 : 0 - ); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(0); - }); - } - ); + describe('when all the pull requests milestones should exempt a specific milestone', (): void => { + beforeEach((): void => { + opts.exemptPrMilestones = + 'dummy-pull-request-milestone1, dummy-pull-request-milestone2'; }); + + describe.each` + isPullRequest | milestone | name | shouldStale + ${false} | ${''} | ${'the issue does not have a milestone'} | ${true} + ${false} | ${'dummy-milestone-not-exempted'} | ${'the issue does have a milestone but not matching the specific pull request exempted one'} | ${true} + ${false} | ${'dummy-pull-request-milestone2'} | ${'the issue does have a milestone matching the specific pull request exempted one'} | ${true} + ${true} | ${''} | ${'the PR does not have a milestone'} | ${true} + ${true} | ${'dummy-milestone-not-exempted'} | ${'the PR does have a milestone but not matching the specific pull request exempted one'} | ${false} + ${true} | ${'dummy-pull-request-milestone2'} | ${'the PR does have a milestone matching the specific pull request exempted one'} | ${false} + `( + 'when $name', + ({isPullRequest, milestone, shouldStale}: ITestData): void => { + beforeEach((): void => { + setTestIssueList(isPullRequest, milestone); + setProcessor(); + }); + + test(`should${ + shouldStale ? '' : ' not' + } be marked as stale`, async () => { + expect.assertions(3); + + await processor.processIssues(1); + + expect(processor.staleIssues.length).toStrictEqual( + shouldStale ? 1 : 0 + ); + expect(processor.closedIssues.length).toStrictEqual(0); + expect(processor.removedLabelIssues.length).toStrictEqual(0); + }); + } + ); }); }); }); diff --git a/action.yml b/action.yml index 336357b9..96ff223c 100644 --- a/action.yml +++ b/action.yml @@ -60,16 +60,12 @@ inputs: description: 'The labels that mean a pull request is exempt from being marked as stale. Separate multiple labels with commas (eg. "label1,label2").' default: '' required: false - exempt-milestones: - description: 'The milestones that mean an issue or a pull request is exempt from being marked as stale. Separate multiple milestones with commas (eg. "milestone1,milestone2").' - default: '' - required: false exempt-issue-milestones: - description: 'The milestones that mean an issue is exempt from being marked as stale. Separate multiple milestones with commas (eg. "milestone1,milestone2"). Override "exempt-milestones" option regarding only the issues.' + description: 'The milestones that mean an issue is exempt from being marked as stale. Separate multiple milestones with commas (eg. "milestone1,milestone2").' default: '' required: false exempt-pr-milestones: - description: 'The milestones that mean a pull request is exempt from being marked as stale. Separate multiple milestones with commas (eg. "milestone1,milestone2"). Override "exempt-milestones" option regarding only the pull requests.' + description: 'The milestones that mean a pull request is exempt from being marked as stale. Separate multiple milestones with commas (eg. "milestone1,milestone2").' default: '' required: false exempt-all-issue-milestones: diff --git a/dist/index.js b/dist/index.js index 6ec6a080..c2a96a10 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1267,13 +1267,7 @@ class Milestones { _getExemptIssueMilestones() { if (this._options.exemptIssueMilestones === '') { this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptIssueMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`); - if (this._options.exemptMilestones === '') { - this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`); - return []; - } - const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptMilestones); - this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is set. ${logger_service_1.LoggerService.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`); - return exemptMilestones; + return []; } const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptIssueMilestones); this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptIssueMilestones)} is set. ${logger_service_1.LoggerService.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`); @@ -1282,13 +1276,7 @@ class Milestones { _getExemptPullRequestMilestones() { if (this._options.exemptPrMilestones === '') { this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptPrMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`); - if (this._options.exemptMilestones === '') { - this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`); - return []; - } - const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptMilestones); - this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is set. ${logger_service_1.LoggerService.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`); - return exemptMilestones; + return []; } const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptPrMilestones); this._issueLogger.info(logger_service_1.LoggerService.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptPrMilestones)} is set. ${logger_service_1.LoggerService.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`); @@ -1795,7 +1783,6 @@ var Option; Option["Ascending"] = "ascending"; Option["DeleteBranch"] = "delete-branch"; Option["StartDate"] = "start-date"; - Option["ExemptMilestones"] = "exempt-milestones"; Option["ExemptIssueMilestones"] = "exempt-issue-milestones"; Option["ExemptPrMilestones"] = "exempt-pr-milestones"; Option["ExemptAllIssueMilestones"] = "exempt-all-issue-milestones"; @@ -2102,7 +2089,6 @@ function _getAndValidateArgs() { startDate: core.getInput('start-date') !== '' ? core.getInput('start-date') : undefined, - exemptMilestones: core.getInput('exempt-milestones'), exemptIssueMilestones: core.getInput('exempt-issue-milestones'), exemptPrMilestones: core.getInput('exempt-pr-milestones'), exemptAllIssueMilestones: core.getInput('exempt-all-issue-milestones') === 'true', diff --git a/src/classes/issue.spec.ts b/src/classes/issue.spec.ts index b95a1e82..03426c2b 100644 --- a/src/classes/issue.spec.ts +++ b/src/classes/issue.spec.ts @@ -43,7 +43,6 @@ describe('Issue', (): void => { startDate: undefined, stalePrLabel: 'dummy-stale-pr-label', staleIssueLabel: 'dummy-stale-issue-label', - exemptMilestones: '', exemptIssueMilestones: '', exemptPrMilestones: '', exemptAllIssueMilestones: false, diff --git a/src/classes/milestones.spec.ts b/src/classes/milestones.spec.ts index 1f6fa58b..9a31b7f4 100644 --- a/src/classes/milestones.spec.ts +++ b/src/classes/milestones.spec.ts @@ -26,266 +26,200 @@ describe('Milestones', (): void => { issueInterface.pull_request = undefined; }); - describe('when the given options are not configured to exempt a milestone', (): void => { + describe('when the given options are not configured to exempt an issue milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptMilestones = ''; + optionsInterface.exemptIssueMilestones = ''; }); - describe('when the given options are not configured to exempt an issue milestone', (): void => { + describe('when the given issue does not have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptIssueMilestones = ''; + issueInterface.milestone = undefined; }); - describe('when the given issue does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given issue does have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); - - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); + expect(result).toStrictEqual(false); }); }); - describe('when the given options are configured to exempt an issue milestone', (): void => { + describe('when the given issue does have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptIssueMilestones = - 'dummy-exempt-issue-milestone'; + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given issue does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given issue does have a milestone different than the exempt issue milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); - - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given issue does have a milestone equaling the exempt issue milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-issue-milestone' - }; - }); - - it('should return true', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(true); - }); + expect(result).toStrictEqual(false); }); }); }); - describe('when the given options are configured to exempt a milestone', (): void => { + describe('when the given options are configured to exempt an issue milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptMilestones = 'dummy-exempt-milestone'; + optionsInterface.exemptIssueMilestones = + 'dummy-exempt-issue-milestone'; }); - describe('when the given options are not configured to exempt an issue milestone', (): void => { + describe('when the given issue does not have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptIssueMilestones = ''; + issueInterface.milestone = undefined; }); - describe('when the given issue does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given issue does have a milestone different than the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); - - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given issue does have a milestone equaling the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-milestone' - }; - }); - - it('should return true', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(true); - }); + expect(result).toStrictEqual(false); }); }); - describe('when the given options are configured to exempt an issue milestone', (): void => { + describe('when the given issue does have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptIssueMilestones = - 'dummy-exempt-issue-milestone'; + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given issue does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given options are not configured to exempt an issue milestone', (): void => { + beforeEach((): void => { + optionsInterface.exemptIssueMilestones = ''; + }); + + describe('when the given issue does not have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = undefined; }); - describe('when the given issue does have a milestone different than the exempt issue milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given issue does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given issue does have a milestone equaling the exempt issue milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-issue-milestone' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return true', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); + }); - expect(result).toStrictEqual(true); - }); + describe('when the given options are configured to exempt an issue milestone', (): void => { + beforeEach((): void => { + optionsInterface.exemptIssueMilestones = + 'dummy-exempt-issue-milestone'; + }); + + describe('when the given issue does not have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = undefined; }); - describe('when the given issue does have a milestone different than the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given issue does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given issue does have a milestone equaling the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-milestone' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given issue does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-title' + }; + }); + + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); + + const result = milestones.shouldExemptMilestones(); + + expect(result).toStrictEqual(false); + }); + }); + + describe('when the given issue does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-exempt-milestone' + }; + }); + + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); + + const result = milestones.shouldExemptMilestones(); + + expect(result).toStrictEqual(false); }); }); }); @@ -376,264 +310,198 @@ describe('Milestones', (): void => { issueInterface.pull_request = {}; }); - describe('when the given options are not configured to exempt a milestone', (): void => { + describe('when the given options are not configured to exempt a pull request milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptMilestones = ''; + optionsInterface.exemptPrMilestones = ''; }); - describe('when the given options are not configured to exempt a pull request milestone', (): void => { + describe('when the given pull request does not have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptPrMilestones = ''; + issueInterface.milestone = undefined; }); - describe('when the given pull request does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given pull request does have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); - - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); + expect(result).toStrictEqual(false); }); }); - describe('when the given options are configured to exempt a pull request milestone', (): void => { + describe('when the given pull request does have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptPrMilestones = 'dummy-exempt-pr-milestone'; + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given pull request does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given pull request does have a milestone different than the exempt pull request milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); - - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given pull request does have a milestone equaling the exempt pull request milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-pr-milestone' - }; - }); - - it('should return true', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(true); - }); + expect(result).toStrictEqual(false); }); }); }); - describe('when the given options are configured to exempt a milestone', (): void => { + describe('when the given options are configured to exempt a pull request milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptMilestones = 'dummy-exempt-milestone'; + optionsInterface.exemptPrMilestones = 'dummy-exempt-pr-milestone'; }); - describe('when the given options are not configured to exempt a pull request milestone', (): void => { + describe('when the given pull request does not have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptPrMilestones = ''; + issueInterface.milestone = undefined; }); - describe('when the given pull request does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given pull request does have a milestone different than the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); - - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(false); - }); - }); - - describe('when the given pull request does have a milestone equaling the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-milestone' - }; - }); - - it('should return true', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); - - const result = milestones.shouldExemptMilestones(); - - expect(result).toStrictEqual(true); - }); + expect(result).toStrictEqual(false); }); }); - describe('when the given options are configured to exempt a pull request milestone', (): void => { + describe('when the given pull request does have a milestone', (): void => { beforeEach((): void => { - optionsInterface.exemptPrMilestones = 'dummy-exempt-pr-milestone'; + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given pull request does not have a milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = undefined; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given options are not configured to exempt a pull request milestone', (): void => { + beforeEach((): void => { + optionsInterface.exemptPrMilestones = ''; + }); + + describe('when the given pull request does not have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = undefined; }); - describe('when the given pull request does have a milestone different than the exempt pull request milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given pull request does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given pull request does have a milestone equaling the exempt pull request milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-pr-milestone' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return true', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); + }); - expect(result).toStrictEqual(true); - }); + describe('when the given options are configured to exempt a pull request milestone', (): void => { + beforeEach((): void => { + optionsInterface.exemptPrMilestones = 'dummy-exempt-pr-milestone'; + }); + + describe('when the given pull request does not have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = undefined; }); - describe('when the given pull request does have a milestone different than the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-title' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given pull request does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-title' + }; }); - describe('when the given pull request does have a milestone equaling the exempt milestone', (): void => { - beforeEach((): void => { - issueInterface.milestone = { - title: 'dummy-exempt-milestone' - }; - }); + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); - it('should return false', (): void => { - expect.assertions(1); - issue = new Issue(optionsInterface, issueInterface); - milestones = new Milestones(optionsInterface, issue); + const result = milestones.shouldExemptMilestones(); - const result = milestones.shouldExemptMilestones(); + expect(result).toStrictEqual(false); + }); + }); - expect(result).toStrictEqual(false); - }); + describe('when the given pull request does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-exempt-pr-milestone' + }; + }); + + it('should return true', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); + + const result = milestones.shouldExemptMilestones(); + + expect(result).toStrictEqual(true); + }); + }); + + describe('when the given pull request does have a milestone', (): void => { + beforeEach((): void => { + issueInterface.milestone = { + title: 'dummy-title' + }; + }); + + it('should return false', (): void => { + expect.assertions(1); + issue = new Issue(optionsInterface, issueInterface); + milestones = new Milestones(optionsInterface, issue); + + const result = milestones.shouldExemptMilestones(); + + expect(result).toStrictEqual(false); }); }); }); diff --git a/src/classes/milestones.ts b/src/classes/milestones.ts index 05122b68..bc6464e4 100644 --- a/src/classes/milestones.ts +++ b/src/classes/milestones.ts @@ -95,31 +95,7 @@ export class Milestones { )} is disabled. No specific milestone can skip the stale process for this $$type` ); - if (this._options.exemptMilestones === '') { - this._issueLogger.info( - LoggerService.white('├──'), - `The option ${this._issueLogger.createOptionLink( - Option.ExemptMilestones - )} is disabled. No specific milestone can skip the stale process for this $$type` - ); - - return []; - } - - const exemptMilestones: string[] = wordsToList( - this._options.exemptMilestones - ); - - this._issueLogger.info( - LoggerService.white('├──'), - `The option ${this._issueLogger.createOptionLink( - Option.ExemptMilestones - )} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${ - exemptMilestones.length === 1 ? '' : 's' - } can skip the stale process for this $$type` - ); - - return exemptMilestones; + return []; } const exemptMilestones: string[] = wordsToList( @@ -147,31 +123,7 @@ export class Milestones { )} is disabled. No specific milestone can skip the stale process for this $$type` ); - if (this._options.exemptMilestones === '') { - this._issueLogger.info( - LoggerService.white('├──'), - `The option ${this._issueLogger.createOptionLink( - Option.ExemptMilestones - )} is disabled. No specific milestone can skip the stale process for this $$type` - ); - - return []; - } - - const exemptMilestones: string[] = wordsToList( - this._options.exemptMilestones - ); - - this._issueLogger.info( - LoggerService.white('├──'), - `The option ${this._issueLogger.createOptionLink( - Option.ExemptMilestones - )} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${ - exemptMilestones.length === 1 ? '' : 's' - } can skip the stale process for this $$type` - ); - - return exemptMilestones; + return []; } const exemptMilestones: string[] = wordsToList( diff --git a/src/enums/option.ts b/src/enums/option.ts index 3f957409..69b4c409 100644 --- a/src/enums/option.ts +++ b/src/enums/option.ts @@ -28,7 +28,6 @@ export enum Option { Ascending = 'ascending', DeleteBranch = 'delete-branch', StartDate = 'start-date', - ExemptMilestones = 'exempt-milestones', ExemptIssueMilestones = 'exempt-issue-milestones', ExemptPrMilestones = 'exempt-pr-milestones', ExemptAllIssueMilestones = 'exempt-all-issue-milestones', diff --git a/src/interfaces/issues-processor-options.ts b/src/interfaces/issues-processor-options.ts index b44804e9..4032edd3 100644 --- a/src/interfaces/issues-processor-options.ts +++ b/src/interfaces/issues-processor-options.ts @@ -32,7 +32,6 @@ export interface IIssuesProcessorOptions { ascending: boolean; deleteBranch: boolean; startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822 - exemptMilestones: string; exemptIssueMilestones: string; exemptPrMilestones: string; exemptAllIssueMilestones: boolean; diff --git a/src/main.ts b/src/main.ts index 469bdebe..35212c60 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,7 +69,6 @@ function _getAndValidateArgs(): IIssuesProcessorOptions { core.getInput('start-date') !== '' ? core.getInput('start-date') : undefined, - exemptMilestones: core.getInput('exempt-milestones'), exemptIssueMilestones: core.getInput('exempt-issue-milestones'), exemptPrMilestones: core.getInput('exempt-pr-milestones'), exemptAllIssueMilestones: