Skip to content

Commit

Permalink
feat(options): simplify config by removing skip stale message options (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
C0ZEN authored May 25, 2021
1 parent 16dfaa2 commit 6ec637d
Show file tree
Hide file tree
Showing 12 changed files with 1,844 additions and 1,880 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/stale_issue_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ jobs:
runs-on: ...
steps:
- uses: actions/stale@...
with:
...
with: ...
```
## Further context
Expand Down
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!-- List the change(s) you're making with this PR. -->

## Changes

- [x] ...

## Context
Expand Down
22 changes: 2 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
| [debug-only](#debug-only) | Dry-run | `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 | |
| [delete-branch](#delete-branch) | Delete branch after closing a stale PR | `false` |
| [exempt-milestones](#exempt-milestones) | Milestones on issues/PRs exempted from stale | |
Expand Down Expand Up @@ -141,15 +139,15 @@ 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.

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

#### stale-pr-message

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

Expand Down Expand Up @@ -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`

#### 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

The start date is used to ignore the issues and pull requests created before the start date.
Expand Down
2 changes: 0 additions & 2 deletions __tests__/constants/default-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
removeIssueStaleWhenUpdated: undefined,
removePrStaleWhenUpdated: undefined,
ascending: false,
skipStaleIssueMessage: false,
skipStalePrMessage: false,
deleteBranch: false,
startDate: '',
exemptMilestones: '',
Expand Down
56 changes: 39 additions & 17 deletions __tests__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,11 +1422,11 @@ test('stale issues should not be closed until after the closed number of days (l
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};
opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeClose = 20; // closes after 25 days
opts.skipStaleIssueMessage = true;
opts.staleIssueMessage = '';
const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10);
const TestIssueList: Issue[] = [
Expand Down Expand Up @@ -1467,11 +1467,11 @@ 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};
opts.daysBeforeStale = 5; // stale after 5 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[] = [
Expand All @@ -1481,7 +1481,7 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
'An issue that should be marked stale but not closed',
lastUpdate.toString(),
lastUpdate.toString(),
true
false
)
];
const processor = new IssuesProcessorMock(
Expand All @@ -1505,19 +1505,18 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
// comment should not be created
expect(markSpy).toHaveBeenCalledWith(
TestIssueList[0],
opts.stalePrMessage,
opts.stalePrLabel,
opts.staleIssueMessage,
opts.staleIssueLabel,
// this option is skipMessage
true
false
);
});

test('not providing state takes precedence over skipStaleIssueMessage', async () => {
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.skipStalePrMessage = true;
opts.staleIssueMessage = '';
opts.stalePrMessage = '';
const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10);
const TestIssueList: Issue[] = [
Expand All @@ -1527,7 +1526,7 @@ test('not providing state takes precedence over skipStaleIssueMessage', async ()
'An issue that should be marked stale but not closed',
lastUpdate.toString(),
lastUpdate.toString(),
false
true
)
];
const processor = new IssuesProcessorMock(
Expand All @@ -1538,20 +1537,31 @@ test('not providing state takes precedence over skipStaleIssueMessage', 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(0);
expect(processor.staleIssues).toHaveLength(1);

// comment should not be created
expect(markSpy).toHaveBeenCalledWith(
TestIssueList[0],
opts.stalePrMessage,
opts.stalePrLabel,
// this option is skipMessage
true
);
});

test('not providing stalePrMessage takes precedence over skipStalePrMessage', async () => {
test('send stale message on prs when stale-pr-message is not empty', async () => {
const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeClose = 20; // closes after 25 days
opts.skipStalePrMessage = true;
opts.stalePrMessage = '';
opts.stalePrMessage = 'dummy pr message';
const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10);
const TestIssueList: Issue[] = [
Expand All @@ -1572,12 +1582,24 @@ test('not providing stalePrMessage takes precedence over skipStalePrMessage', as
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(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 () => {
Expand Down
8 changes: 0 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ inputs:
description: 'The order to get issues or pull requests. Defaults to false, which is descending.'
default: '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:
description: 'Delete the git branch after closing a stale pull request.'
default: 'false'
Expand Down
Loading

0 comments on commit 6ec637d

Please sign in to comment.