feat(options): simplify config by removing skip stale message options (#457)
* feat(options): simplify config by removing skip stale message options Closes #405 Closes #455 BREAKING CHANGES: remove skip-stale-issue-message and skip-stale-pr-message options. If you used this option, replace it by an empty message for the options stale-issue-message and stale-pr-message * build(dist): update dist also lint some files * docs(readme): update the docs by removing the skip options
This commit is contained in:
parent
16dfaa2c02
commit
6ec637d238
|
@ -20,8 +20,7 @@ jobs:
|
||||||
runs-on: ...
|
runs-on: ...
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@...
|
- uses: actions/stale@...
|
||||||
with:
|
with: ...
|
||||||
...
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Further context
|
## Further context
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<!-- List the change(s) you're making with this PR. -->
|
<!-- List the change(s) you're making with this PR. -->
|
||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
- [x] ...
|
- [x] ...
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
|
|
22
README.md
22
README.md
|
@ -39,8 +39,6 @@ Every argument is optional.
|
||||||
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
|
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
|
||||||
| [debug-only](#debug-only) | Dry-run | `false` |
|
| [debug-only](#debug-only) | Dry-run | `false` |
|
||||||
| [ascending](#ascending) | Order to get issues/PRs | `false` |
|
| [ascending](#ascending) | Order to get issues/PRs | `false` |
|
||||||
| [skip-stale-issue-message](#skip-stale-issue-message) | Skip adding stale message on stale issues | `false` |
|
|
||||||
| [skip-stale-pr-message](#skip-stale-pr-message) | Skip adding stale message on stale 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-milestones](#exempt-milestones) | Milestones on issues/PRs exempted from stale | |
|
||||||
|
@ -141,7 +139,7 @@ Default value: unset
|
||||||
|
|
||||||
The message that will be added as a comment to the issues when the stale workflow marks it automatically as stale with a label.
|
The message that will be added as a comment to the issues when the stale workflow marks it automatically as stale with a label.
|
||||||
|
|
||||||
You can omit the comment by setting [skip-stale-issue-message](#skip-stale-issue-message) to `true`.
|
You can skip the comment sending by omitting the option or by passing an empty string.
|
||||||
|
|
||||||
Default value: unset
|
Default value: unset
|
||||||
|
|
||||||
|
@ -149,7 +147,7 @@ Default value: unset
|
||||||
|
|
||||||
The message that will be added as a comment to the pull requests when the stale workflow marks it automatically as stale with a label.
|
The message that will be added as a comment to the pull requests when the stale workflow marks it automatically as stale with a label.
|
||||||
|
|
||||||
You can omit the comment by setting [skip-stale-pr-message](#skip-stale-pr-message) to `true`.
|
You can skip the comment sending by omitting the option or by passing an empty string.
|
||||||
|
|
||||||
Default value: unset
|
Default value: unset
|
||||||
|
|
||||||
|
@ -316,22 +314,6 @@ Based on the order, you could prefer to focus on the new content or on the old c
|
||||||
|
|
||||||
Default value: `false`
|
Default value: `false`
|
||||||
|
|
||||||
#### skip-stale-issue-message
|
|
||||||
|
|
||||||
If set to `true`, no comment will be added to the issues when they are automatically marked as stale.
|
|
||||||
|
|
||||||
If set to `false`, you can define the comment with the [stale-issue-message](#stale-issue-message) option.
|
|
||||||
|
|
||||||
Default value: `false`
|
|
||||||
|
|
||||||
#### skip-stale-pr-message
|
|
||||||
|
|
||||||
If set to `true`, no comment will be added to the pull requests when they are automatically marked as stale.
|
|
||||||
|
|
||||||
If set to `false`, you can define the comment with the [stale-pr-message](#stale-pr-message) option.
|
|
||||||
|
|
||||||
Default value: `false`
|
|
||||||
|
|
||||||
#### start-date
|
#### start-date
|
||||||
|
|
||||||
The start date is used to ignore the issues and pull requests created before the start date.
|
The start date is used to ignore the issues and pull requests created before the start date.
|
||||||
|
|
|
@ -30,8 +30,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||||
removeIssueStaleWhenUpdated: undefined,
|
removeIssueStaleWhenUpdated: undefined,
|
||||||
removePrStaleWhenUpdated: undefined,
|
removePrStaleWhenUpdated: undefined,
|
||||||
ascending: false,
|
ascending: false,
|
||||||
skipStaleIssueMessage: false,
|
|
||||||
skipStalePrMessage: false,
|
|
||||||
deleteBranch: false,
|
deleteBranch: false,
|
||||||
startDate: '',
|
startDate: '',
|
||||||
exemptMilestones: '',
|
exemptMilestones: '',
|
||||||
|
|
|
@ -1422,11 +1422,11 @@ test('stale issues should not be closed until after the closed number of days (l
|
||||||
expect(processor.staleIssues).toHaveLength(1);
|
expect(processor.staleIssues).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('skips stale message on issues when skip-stale-issue-message is set', async () => {
|
test('skips stale message on issues when stale-issue-message is empty', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeStale = 5; // stale after 5 days
|
opts.daysBeforeStale = 5; // stale after 5 days
|
||||||
opts.daysBeforeClose = 20; // closes after 25 days
|
opts.daysBeforeClose = 20; // closes after 25 days
|
||||||
opts.skipStaleIssueMessage = true;
|
opts.staleIssueMessage = '';
|
||||||
const lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -1467,11 +1467,56 @@ test('skips stale message on issues when skip-stale-issue-message is set', async
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('skips stale message on prs when skip-stale-pr-message is set', async () => {
|
test('send stale message on issues when stale-issue-message is not empty', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeStale = 5; // stale after 5 days
|
opts.daysBeforeStale = 5; // stale after 5 days
|
||||||
opts.daysBeforeClose = 20; // closes after 25 days
|
opts.daysBeforeClose = 20; // closes after 25 days
|
||||||
opts.skipStalePrMessage = true;
|
opts.staleIssueMessage = 'dummy issue message';
|
||||||
|
const lastUpdate = new Date();
|
||||||
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
opts,
|
||||||
|
1,
|
||||||
|
'An issue that should be marked stale but not closed',
|
||||||
|
lastUpdate.toString(),
|
||||||
|
lastUpdate.toString(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const processor = new IssuesProcessorMock(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p === 1 ? TestIssueList : []),
|
||||||
|
async () => [],
|
||||||
|
async () => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// for sake of testing, mocking private function
|
||||||
|
const markSpy = jest.spyOn(processor as any, '_markStale');
|
||||||
|
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
// issue should be staled
|
||||||
|
expect(processor.closedIssues).toHaveLength(0);
|
||||||
|
expect(processor.removedLabelIssues).toHaveLength(0);
|
||||||
|
expect(processor.staleIssues).toHaveLength(1);
|
||||||
|
|
||||||
|
// comment should not be created
|
||||||
|
expect(markSpy).toHaveBeenCalledWith(
|
||||||
|
TestIssueList[0],
|
||||||
|
opts.staleIssueMessage,
|
||||||
|
opts.staleIssueLabel,
|
||||||
|
// this option is skipMessage
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('skips stale message on prs when stale-pr-message is empty', async () => {
|
||||||
|
const opts = {...DefaultProcessorOptions};
|
||||||
|
opts.daysBeforeStale = 5; // stale after 5 days
|
||||||
|
opts.daysBeforeClose = 20; // closes after 25 days
|
||||||
|
opts.stalePrMessage = '';
|
||||||
const lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -1512,46 +1557,11 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('not providing state takes precedence over skipStaleIssueMessage', async () => {
|
test('send stale message on prs when stale-pr-message is not empty', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeStale = 5; // stale after 5 days
|
opts.daysBeforeStale = 5; // stale after 5 days
|
||||||
opts.daysBeforeClose = 20; // closes after 25 days
|
opts.daysBeforeClose = 20; // closes after 25 days
|
||||||
opts.skipStalePrMessage = true;
|
opts.stalePrMessage = 'dummy pr message';
|
||||||
opts.staleIssueMessage = '';
|
|
||||||
const lastUpdate = new Date();
|
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
|
||||||
const TestIssueList: Issue[] = [
|
|
||||||
generateIssue(
|
|
||||||
opts,
|
|
||||||
1,
|
|
||||||
'An issue that should be marked stale but not closed',
|
|
||||||
lastUpdate.toString(),
|
|
||||||
lastUpdate.toString(),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
];
|
|
||||||
const processor = new IssuesProcessorMock(
|
|
||||||
opts,
|
|
||||||
async () => 'abot',
|
|
||||||
async p => (p === 1 ? TestIssueList : []),
|
|
||||||
async () => [],
|
|
||||||
async () => new Date().toDateString()
|
|
||||||
);
|
|
||||||
|
|
||||||
await processor.processIssues(1);
|
|
||||||
|
|
||||||
// issue should be staled
|
|
||||||
expect(processor.closedIssues).toHaveLength(0);
|
|
||||||
expect(processor.removedLabelIssues).toHaveLength(0);
|
|
||||||
expect(processor.staleIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('not providing stalePrMessage takes precedence over skipStalePrMessage', async () => {
|
|
||||||
const opts = {...DefaultProcessorOptions};
|
|
||||||
opts.daysBeforeStale = 5; // stale after 5 days
|
|
||||||
opts.daysBeforeClose = 20; // closes after 25 days
|
|
||||||
opts.skipStalePrMessage = true;
|
|
||||||
opts.stalePrMessage = '';
|
|
||||||
const lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -1572,12 +1582,24 @@ test('not providing stalePrMessage takes precedence over skipStalePrMessage', as
|
||||||
async () => new Date().toDateString()
|
async () => new Date().toDateString()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// for sake of testing, mocking private function
|
||||||
|
const markSpy = jest.spyOn(processor as any, '_markStale');
|
||||||
|
|
||||||
await processor.processIssues(1);
|
await processor.processIssues(1);
|
||||||
|
|
||||||
// issue should be staled
|
// issue should be staled
|
||||||
expect(processor.closedIssues).toHaveLength(0);
|
expect(processor.closedIssues).toHaveLength(0);
|
||||||
expect(processor.removedLabelIssues).toHaveLength(0);
|
expect(processor.removedLabelIssues).toHaveLength(0);
|
||||||
expect(processor.staleIssues).toHaveLength(0);
|
expect(processor.staleIssues).toHaveLength(1);
|
||||||
|
|
||||||
|
// comment should not be created
|
||||||
|
expect(markSpy).toHaveBeenCalledWith(
|
||||||
|
TestIssueList[0],
|
||||||
|
opts.stalePrMessage,
|
||||||
|
opts.stalePrLabel,
|
||||||
|
// this option is skipMessage
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('git branch is deleted when option is enabled', async () => {
|
test('git branch is deleted when option is enabled', async () => {
|
||||||
|
|
|
@ -132,14 +132,6 @@ inputs:
|
||||||
description: 'The order to get issues or pull requests. Defaults to false, which is descending.'
|
description: 'The order to get issues or pull requests. Defaults to false, which is descending.'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
skip-stale-pr-message:
|
|
||||||
description: 'Skip adding stale message when marking a pull request as stale.'
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
skip-stale-issue-message:
|
|
||||||
description: 'Skip adding stale message when marking an issue as stale.'
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
delete-branch:
|
delete-branch:
|
||||||
description: 'Delete the git branch after closing a stale pull request.'
|
description: 'Delete the git branch after closing a stale pull request.'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -38,8 +38,6 @@ describe('Issue', (): void => {
|
||||||
removeIssueStaleWhenUpdated: undefined,
|
removeIssueStaleWhenUpdated: undefined,
|
||||||
removePrStaleWhenUpdated: undefined,
|
removePrStaleWhenUpdated: undefined,
|
||||||
repoToken: '',
|
repoToken: '',
|
||||||
skipStaleIssueMessage: false,
|
|
||||||
skipStalePrMessage: false,
|
|
||||||
staleIssueMessage: '',
|
staleIssueMessage: '',
|
||||||
stalePrMessage: '',
|
stalePrMessage: '',
|
||||||
startDate: undefined,
|
startDate: undefined,
|
||||||
|
|
|
@ -138,8 +138,8 @@ export class IssuesProcessor {
|
||||||
? this.options.closePrLabel
|
? this.options.closePrLabel
|
||||||
: this.options.closeIssueLabel;
|
: this.options.closeIssueLabel;
|
||||||
const skipMessage = issue.isPullRequest
|
const skipMessage = issue.isPullRequest
|
||||||
? this.options.skipStalePrMessage
|
? this.options.stalePrMessage.length === 0
|
||||||
: this.options.skipStaleIssueMessage;
|
: this.options.staleIssueMessage.length === 0;
|
||||||
const daysBeforeStale: number = issue.isPullRequest
|
const daysBeforeStale: number = issue.isPullRequest
|
||||||
? this._getDaysBeforePrStale()
|
? this._getDaysBeforePrStale()
|
||||||
: this._getDaysBeforeIssueStale();
|
: this._getDaysBeforeIssueStale();
|
||||||
|
@ -196,20 +196,6 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
const shouldMarkAsStale: boolean = shouldMarkWhenStale(daysBeforeStale);
|
const shouldMarkAsStale: boolean = shouldMarkWhenStale(daysBeforeStale);
|
||||||
|
|
||||||
if (!staleMessage && shouldMarkAsStale) {
|
|
||||||
issueLogger.info(
|
|
||||||
`Skipping this $$type because it should be marked as stale based on the option ${issueLogger.createOptionLink(
|
|
||||||
this._getDaysBeforeStaleUsedOptionName(issue)
|
|
||||||
)} (${chalk.cyan(
|
|
||||||
daysBeforeStale
|
|
||||||
)}) but the option ${issueLogger.createOptionLink(
|
|
||||||
IssuesProcessor._getStaleMessageUsedOptionName(issue)
|
|
||||||
)} is not set`
|
|
||||||
);
|
|
||||||
IssuesProcessor._endIssueProcessing(issue);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (issue.state === 'closed') {
|
if (issue.state === 'closed') {
|
||||||
issueLogger.info(`Skipping this $$type because it is closed`);
|
issueLogger.info(`Skipping this $$type because it is closed`);
|
||||||
IssuesProcessor._endIssueProcessing(issue);
|
IssuesProcessor._endIssueProcessing(issue);
|
||||||
|
|
|
@ -24,8 +24,6 @@ export enum Option {
|
||||||
RemoveStaleWhenUpdated = 'remove-stale-when-updated',
|
RemoveStaleWhenUpdated = 'remove-stale-when-updated',
|
||||||
DebugOnly = 'debug-only',
|
DebugOnly = 'debug-only',
|
||||||
Ascending = 'ascending',
|
Ascending = 'ascending',
|
||||||
SkipStaleIssueMessage = 'skip-stale-issue-message',
|
|
||||||
SkipStalePrMessage = 'skip-stale-pr-message',
|
|
||||||
DeleteBranch = 'delete-branch',
|
DeleteBranch = 'delete-branch',
|
||||||
StartDate = 'start-date',
|
StartDate = 'start-date',
|
||||||
ExemptMilestones = 'exempt-milestones',
|
ExemptMilestones = 'exempt-milestones',
|
||||||
|
|
|
@ -30,8 +30,6 @@ export interface IIssuesProcessorOptions {
|
||||||
removePrStaleWhenUpdated: boolean | undefined;
|
removePrStaleWhenUpdated: boolean | undefined;
|
||||||
debugOnly: boolean;
|
debugOnly: boolean;
|
||||||
ascending: boolean;
|
ascending: boolean;
|
||||||
skipStaleIssueMessage: boolean;
|
|
||||||
skipStalePrMessage: 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;
|
exemptMilestones: string;
|
||||||
|
|
|
@ -57,8 +57,6 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||||
),
|
),
|
||||||
debugOnly: core.getInput('debug-only') === 'true',
|
debugOnly: core.getInput('debug-only') === 'true',
|
||||||
ascending: core.getInput('ascending') === 'true',
|
ascending: core.getInput('ascending') === 'true',
|
||||||
skipStalePrMessage: core.getInput('skip-stale-pr-message') === 'true',
|
|
||||||
skipStaleIssueMessage: core.getInput('skip-stale-issue-message') === 'true',
|
|
||||||
deleteBranch: core.getInput('delete-branch') === 'true',
|
deleteBranch: core.getInput('delete-branch') === 'true',
|
||||||
startDate:
|
startDate:
|
||||||
core.getInput('start-date') !== ''
|
core.getInput('start-date') !== ''
|
||||||
|
|
Loading…
Reference in New Issue