feat: remove the exempt-milestones option

BREAKING CHANGE:
The option exempt-milestones was removed
This commit is contained in:
TESTELIN Geoffrey 2021-10-08 19:48:38 +02:00
parent 315391885d
commit f6a70aa856
No known key found for this signature in database
GPG Key ID: 05D28E8D8E8E52DA
12 changed files with 649 additions and 1293 deletions

View File

@ -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`

View File

@ -32,7 +32,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
ascending: false,
deleteBranch: false,
startDate: '',
exemptMilestones: '',
exemptIssueMilestones: '',
exemptPrMilestones: '',
exemptAllIssueMilestones: false,

View File

@ -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 = {

View File

@ -84,43 +84,6 @@ describe('milestones options', (): void => {
}
);
describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-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}
`(
'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-milestone';
@ -131,11 +94,9 @@ describe('milestones options', (): void => {
${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 => {
@ -171,11 +132,9 @@ describe('milestones options', (): void => {
${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 => {
@ -200,44 +159,6 @@ describe('milestones options', (): void => {
}
);
});
});
describe('when all the issues and pull requests milestones should exempt some milestones', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-milestone1, dummy-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 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}
`(
'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 => {
@ -250,11 +171,9 @@ describe('milestones options', (): void => {
${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 => {
@ -291,11 +210,9 @@ describe('milestones options', (): void => {
${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 => {
@ -321,7 +238,6 @@ describe('milestones options', (): void => {
);
});
});
});
describe('when all the issues milestones should exempt', (): void => {
beforeEach((): void => {
@ -358,43 +274,6 @@ describe('milestones options', (): void => {
}
);
describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-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}
`(
'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-milestone';
@ -405,11 +284,9 @@ describe('milestones options', (): void => {
${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 => {
@ -445,11 +322,9 @@ describe('milestones options', (): void => {
${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 => {
@ -474,44 +349,6 @@ describe('milestones options', (): void => {
}
);
});
});
describe('when all the issues and pull requests milestones should exempt some milestones', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-milestone1, dummy-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 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}
`(
'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 => {
@ -524,11 +361,9 @@ describe('milestones options', (): void => {
${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 => {
@ -565,11 +400,9 @@ describe('milestones options', (): void => {
${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 => {
@ -595,7 +428,6 @@ describe('milestones options', (): void => {
);
});
});
});
describe('when all the pull requests milestones should not exempt', (): void => {
beforeEach((): void => {
@ -632,43 +464,6 @@ describe('milestones options', (): void => {
}
);
describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-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}
`(
'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-milestone';
@ -679,11 +474,9 @@ describe('milestones options', (): void => {
${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 => {
@ -719,11 +512,9 @@ describe('milestones options', (): void => {
${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 => {
@ -748,44 +539,6 @@ describe('milestones options', (): void => {
}
);
});
});
describe('when all the issues and pull requests milestones should exempt some milestones', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-milestone1, dummy-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 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}
`(
'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 => {
@ -798,11 +551,9 @@ describe('milestones options', (): void => {
${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 => {
@ -839,11 +590,9 @@ describe('milestones options', (): void => {
${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 => {
@ -869,7 +618,6 @@ describe('milestones options', (): void => {
);
});
});
});
describe('when all the pull requests milestones should exempt', (): void => {
beforeEach((): void => {
@ -906,43 +654,6 @@ describe('milestones options', (): void => {
}
);
describe('when all the issues and pull requests milestones should exempt a specific milestone', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-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}
`(
'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-milestone';
@ -953,11 +664,9 @@ describe('milestones options', (): void => {
${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 => {
@ -993,11 +702,9 @@ describe('milestones options', (): void => {
${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 => {
@ -1022,44 +729,6 @@ describe('milestones options', (): void => {
}
);
});
});
describe('when all the issues and pull requests milestones should exempt some milestones', (): void => {
beforeEach((): void => {
opts.exemptMilestones = 'dummy-milestone1, dummy-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 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}
`(
'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 => {
@ -1072,11 +741,9 @@ describe('milestones options', (): void => {
${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 => {
@ -1113,11 +780,9 @@ describe('milestones options', (): void => {
${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 => {
@ -1144,4 +809,3 @@ describe('milestones options', (): void => {
});
});
});
});

View File

@ -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:

14
dist/index.js vendored
View File

@ -1267,14 +1267,8 @@ 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;
}
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`);
return exemptMilestones;
@ -1282,14 +1276,8 @@ 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;
}
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`);
return exemptMilestones;
@ -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',

View File

@ -43,7 +43,6 @@ describe('Issue', (): void => {
startDate: undefined,
stalePrLabel: 'dummy-stale-pr-label',
staleIssueLabel: 'dummy-stale-issue-label',
exemptMilestones: '',
exemptIssueMilestones: '',
exemptPrMilestones: '',
exemptAllIssueMilestones: false,

View File

@ -26,11 +26,6 @@ describe('Milestones', (): void => {
issueInterface.pull_request = undefined;
});
describe('when the given options are not configured to exempt a milestone', (): void => {
beforeEach((): void => {
optionsInterface.exemptMilestones = '';
});
describe('when the given options are not configured to exempt an issue milestone', (): void => {
beforeEach((): void => {
optionsInterface.exemptIssueMilestones = '';
@ -93,7 +88,7 @@ describe('Milestones', (): void => {
});
});
describe('when the given issue does have a milestone different than the exempt issue milestone', (): void => {
describe('when the given issue does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-title'
@ -110,30 +105,6 @@ describe('Milestones', (): void => {
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);
});
});
});
});
describe('when the given options are configured to exempt a milestone', (): void => {
beforeEach((): void => {
optionsInterface.exemptMilestones = 'dummy-exempt-milestone';
});
describe('when the given options are not configured to exempt an issue milestone', (): void => {
@ -157,7 +128,7 @@ describe('Milestones', (): void => {
});
});
describe('when the given issue does have a milestone different than the exempt milestone', (): void => {
describe('when the given issue does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-title'
@ -174,24 +145,6 @@ describe('Milestones', (): void => {
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);
});
});
});
describe('when the given options are configured to exempt an issue milestone', (): void => {
@ -216,7 +169,7 @@ describe('Milestones', (): void => {
});
});
describe('when the given issue does have a milestone different than the exempt issue milestone', (): void => {
describe('when the given issue does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-title'
@ -234,25 +187,7 @@ describe('Milestones', (): void => {
});
});
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);
});
});
describe('when the given issue does have a milestone different than the exempt milestone', (): void => {
describe('when the given issue does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-title'
@ -270,7 +205,7 @@ describe('Milestones', (): void => {
});
});
describe('when the given issue does have a milestone equaling the exempt milestone', (): void => {
describe('when the given issue does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-exempt-milestone'
@ -288,7 +223,6 @@ describe('Milestones', (): void => {
});
});
});
});
describe('when the given options are not configured to exempt all issue milestones', (): void => {
beforeEach((): void => {
@ -376,9 +310,84 @@ 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 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);
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);
});
});
});
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;
});
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', (): 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 options are not configured to exempt a pull request milestone', (): void => {
@ -442,7 +451,7 @@ describe('Milestones', (): void => {
});
});
describe('when the given pull request does have a milestone different than the exempt pull request milestone', (): void => {
describe('when the given pull request does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-title'
@ -460,129 +469,7 @@ describe('Milestones', (): void => {
});
});
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);
});
});
});
});
describe('when the given options are configured to exempt a milestone', (): void => {
beforeEach((): void => {
optionsInterface.exemptMilestones = 'dummy-exempt-milestone';
});
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;
});
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 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);
});
});
});
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;
});
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 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 => {
describe('when the given pull request does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-exempt-pr-milestone'
@ -600,7 +487,7 @@ describe('Milestones', (): void => {
});
});
describe('when the given pull request does have a milestone different than the exempt milestone', (): void => {
describe('when the given pull request does have a milestone', (): void => {
beforeEach((): void => {
issueInterface.milestone = {
title: 'dummy-title'
@ -617,25 +504,6 @@ describe('Milestones', (): void => {
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 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 options are not configured to exempt all pull request milestones', (): void => {

View File

@ -95,33 +95,9 @@ 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;
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptIssueMilestones
);
@ -147,33 +123,9 @@ 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;
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptPrMilestones
);

View File

@ -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',

View File

@ -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;

View File

@ -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: