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. Every argument is optional.
| Input | Description | Default | | Input | Description | Default |
| ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- | ------- | | ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- |
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` | | [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-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 | | | [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` | | [ascending](#ascending) | Order to get issues/PRs | `false` |
| [start-date](#start-date) | Skip stale action for issues/PRs created before it | | | [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` | | [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) | Milestones on issues exempted from stale | |
| [exempt-issue-milestones](#exempt-issue-milestones) | Override [exempt-milestones](#exempt-milestones) for issues only | | | [exempt-pr-milestones](#exempt-pr-milestones) | Milestones on PRs exempted from stale | |
| [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-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-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-issue-assignees](#exempt-issue-assignees) | Assignees on issues exempted from stale | |
| [exempt-pr-assignees](#exempt-pr-assignees) | Assignees on PRs 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` | | [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) - [only-labels](#only-labels)
- [any-of-labels](#any-of-labels) - [any-of-labels](#any-of-labels)
- [start-date](#start-date) - [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-issue-milestones](#exempt-all-issue-milestones)
- [exempt-all-pr-milestones](#exempt-all-pr-milestones) - [exempt-all-pr-milestones](#exempt-all-pr-milestones)
- [exempt-issue-assignees](#exempt-issue-assignees) - [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` Default value: `false`
Required Permission: `pull-requests: write` 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`). 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. If unset (or an empty string), this option will not alter the stale workflow.
Default value: unset 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 #### 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 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. 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` 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. 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` Default value: `false`

View File

@ -32,7 +32,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
ascending: false, ascending: false,
deleteBranch: false, deleteBranch: false,
startDate: '', startDate: '',
exemptMilestones: '',
exemptIssueMilestones: '', exemptIssueMilestones: '',
exemptPrMilestones: '', exemptPrMilestones: '',
exemptAllIssueMilestones: false, 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 () => { test('an issue without an exempted milestone will be marked as stale', async () => {
expect.assertions(3); expect.assertions(3);
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.exemptMilestones = 'Milestone1'; opts.exemptIssueMilestones = 'Milestone1';
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
opts, 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 () => { test('an issue with an exempted milestone will not be marked as stale', async () => {
expect.assertions(3); expect.assertions(3);
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.exemptMilestones = 'Milestone1'; opts.exemptIssueMilestones = 'Milestone1';
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
opts, 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 () => { test('an issue with an exempted milestone will not be marked as stale (multi milestones with spaces)', async () => {
expect.assertions(3); expect.assertions(3);
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.exemptMilestones = 'Milestone1, Milestone2'; opts.exemptIssueMilestones = 'Milestone1, Milestone2';
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
opts, 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 () => { test('an issue with an exempted milestone will not be marked as stale (multi milestones without spaces)', async () => {
expect.assertions(3); expect.assertions(3);
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.exemptMilestones = 'Milestone1,Milestone2'; opts.exemptIssueMilestones = 'Milestone1,Milestone2';
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
opts, 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); 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 () => { test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 3 will not make it stale', async () => {
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {

File diff suppressed because it is too large Load Diff

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").' description: 'The labels that mean a pull request is exempt from being marked as stale. Separate multiple labels with commas (eg. "label1,label2").'
default: '' default: ''
required: false 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: 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: '' default: ''
required: false required: false
exempt-pr-milestones: 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: '' default: ''
required: false required: false
exempt-all-issue-milestones: exempt-all-issue-milestones:

18
dist/index.js vendored
View File

@ -1267,13 +1267,7 @@ class Milestones {
_getExemptIssueMilestones() { _getExemptIssueMilestones() {
if (this._options.exemptIssueMilestones === '') { 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`); 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 === '') { return [];
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); 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`); 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() { _getExemptPullRequestMilestones() {
if (this._options.exemptPrMilestones === '') { 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`); 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 === '') { return [];
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); 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`); 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["Ascending"] = "ascending";
Option["DeleteBranch"] = "delete-branch"; Option["DeleteBranch"] = "delete-branch";
Option["StartDate"] = "start-date"; Option["StartDate"] = "start-date";
Option["ExemptMilestones"] = "exempt-milestones";
Option["ExemptIssueMilestones"] = "exempt-issue-milestones"; Option["ExemptIssueMilestones"] = "exempt-issue-milestones";
Option["ExemptPrMilestones"] = "exempt-pr-milestones"; Option["ExemptPrMilestones"] = "exempt-pr-milestones";
Option["ExemptAllIssueMilestones"] = "exempt-all-issue-milestones"; Option["ExemptAllIssueMilestones"] = "exempt-all-issue-milestones";
@ -2102,7 +2089,6 @@ function _getAndValidateArgs() {
startDate: core.getInput('start-date') !== '' startDate: core.getInput('start-date') !== ''
? core.getInput('start-date') ? core.getInput('start-date')
: undefined, : undefined,
exemptMilestones: core.getInput('exempt-milestones'),
exemptIssueMilestones: core.getInput('exempt-issue-milestones'), exemptIssueMilestones: core.getInput('exempt-issue-milestones'),
exemptPrMilestones: core.getInput('exempt-pr-milestones'), exemptPrMilestones: core.getInput('exempt-pr-milestones'),
exemptAllIssueMilestones: core.getInput('exempt-all-issue-milestones') === 'true', exemptAllIssueMilestones: core.getInput('exempt-all-issue-milestones') === 'true',

View File

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

View File

@ -26,266 +26,200 @@ describe('Milestones', (): void => {
issueInterface.pull_request = undefined; 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 => { 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 => { beforeEach((): void => {
optionsInterface.exemptIssueMilestones = ''; issueInterface.milestone = undefined;
}); });
describe('when the given issue does not have a milestone', (): void => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 options are configured to exempt an issue milestone', (): void => { describe('when the given issue does have a milestone', (): void => {
beforeEach((): void => { beforeEach((): void => {
optionsInterface.exemptIssueMilestones = issueInterface.milestone = {
'dummy-exempt-issue-milestone'; title: 'dummy-title'
};
}); });
describe('when the given issue does not have a milestone', (): void => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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);
});
}); });
}); });
}); });
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 => { 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 => { beforeEach((): void => {
optionsInterface.exemptIssueMilestones = ''; issueInterface.milestone = undefined;
}); });
describe('when the given issue does not have a milestone', (): void => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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);
});
}); });
}); });
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 => { beforeEach((): void => {
optionsInterface.exemptIssueMilestones = issueInterface.milestone = {
'dummy-exempt-issue-milestone'; title: 'dummy-title'
};
}); });
describe('when the given issue does not have a milestone', (): void => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-title' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-exempt-issue-milestone' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return true', (): void => { const result = milestones.shouldExemptMilestones();
expect.assertions(1);
issue = new Issue(optionsInterface, issueInterface);
milestones = new Milestones(optionsInterface, issue);
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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-title' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-exempt-milestone' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 = {}; 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 => { 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 => { beforeEach((): void => {
optionsInterface.exemptPrMilestones = ''; issueInterface.milestone = undefined;
}); });
describe('when the given pull request does not have a milestone', (): void => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { describe('when the given pull request does have a milestone', (): void => {
beforeEach((): 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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);
});
}); });
}); });
}); });
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 => { 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 => { beforeEach((): void => {
optionsInterface.exemptPrMilestones = ''; issueInterface.milestone = undefined;
}); });
describe('when the given pull request does not have a milestone', (): void => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { describe('when the given pull request does have a milestone', (): void => {
beforeEach((): 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = undefined; issue = new Issue(optionsInterface, issueInterface);
}); milestones = new Milestones(optionsInterface, issue);
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-title' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-exempt-pr-milestone' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return true', (): void => { const result = milestones.shouldExemptMilestones();
expect.assertions(1);
issue = new Issue(optionsInterface, issueInterface);
milestones = new Milestones(optionsInterface, issue);
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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-title' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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 => { it('should return false', (): void => {
beforeEach((): void => { expect.assertions(1);
issueInterface.milestone = { issue = new Issue(optionsInterface, issueInterface);
title: 'dummy-exempt-milestone' milestones = new Milestones(optionsInterface, issue);
};
});
it('should return false', (): void => { const result = milestones.shouldExemptMilestones();
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 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);
}); });
}); });
}); });

View File

@ -95,31 +95,7 @@ export class Milestones {
)} is disabled. No specific milestone can skip the stale process for this $$type` )} is disabled. No specific milestone can skip the stale process for this $$type`
); );
if (this._options.exemptMilestones === '') { return [];
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( const exemptMilestones: string[] = wordsToList(
@ -147,31 +123,7 @@ export class Milestones {
)} is disabled. No specific milestone can skip the stale process for this $$type` )} is disabled. No specific milestone can skip the stale process for this $$type`
); );
if (this._options.exemptMilestones === '') { return [];
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( const exemptMilestones: string[] = wordsToList(

View File

@ -28,7 +28,6 @@ export enum Option {
Ascending = 'ascending', Ascending = 'ascending',
DeleteBranch = 'delete-branch', DeleteBranch = 'delete-branch',
StartDate = 'start-date', StartDate = 'start-date',
ExemptMilestones = 'exempt-milestones',
ExemptIssueMilestones = 'exempt-issue-milestones', ExemptIssueMilestones = 'exempt-issue-milestones',
ExemptPrMilestones = 'exempt-pr-milestones', ExemptPrMilestones = 'exempt-pr-milestones',
ExemptAllIssueMilestones = 'exempt-all-issue-milestones', ExemptAllIssueMilestones = 'exempt-all-issue-milestones',

View File

@ -32,7 +32,6 @@ export interface IIssuesProcessorOptions {
ascending: boolean; ascending: boolean;
deleteBranch: boolean; deleteBranch: boolean;
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822 startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
exemptMilestones: string;
exemptIssueMilestones: string; exemptIssueMilestones: string;
exemptPrMilestones: string; exemptPrMilestones: string;
exemptAllIssueMilestones: boolean; exemptAllIssueMilestones: boolean;

View File

@ -69,7 +69,6 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
core.getInput('start-date') !== '' core.getInput('start-date') !== ''
? core.getInput('start-date') ? core.getInput('start-date')
: undefined, : undefined,
exemptMilestones: core.getInput('exempt-milestones'),
exemptIssueMilestones: core.getInput('exempt-issue-milestones'), exemptIssueMilestones: core.getInput('exempt-issue-milestones'),
exemptPrMilestones: core.getInput('exempt-pr-milestones'), exemptPrMilestones: core.getInput('exempt-pr-milestones'),
exemptAllIssueMilestones: exemptAllIssueMilestones: