Skip to content

Commit

Permalink
feat: remove the days-before-stale option
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
The option days-before-stale was removed
  • Loading branch information
C0ZEN committed Oct 8, 2021
1 parent 6299c36 commit bab816b
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 148 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
id: stale
with:
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
days-before-stale: 30
days-before-issue-stale: 30
days-before-pr-stale: 30
days-before-issue-close: 5
days-before-pr-close: 5
exempt-issue-labels: 'blocked,must,should,keep'
Expand Down
65 changes: 33 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ 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 | |
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
| [days-before-issue-stale](#days-before-issue-stale) | Idle number of days before marking issues stale | `60` |
| [days-before-pr-stale](#days-before-pr-stale) | Idle number of days before marking PRs stale | `60` |
| [days-before-issue-close](#days-before-issue-close) | Idle number of days before closing stale issues | `7` |
| [days-before-pr-close](#days-before-pr-close) | Idle number of days before closing stale PRs | `7` |
| [stale-issue-message](#stale-issue-message) | Comment on the staled issues | |
Expand Down Expand Up @@ -89,59 +88,61 @@ Under the hood, it uses the [@actions/github](https://www.npmjs.com/package/@act

Default value: `${{ github.token }}`

#### days-before-stale
#### days-before-issue-stale

The idle number of days before marking the issues or the pull requests as stale (by adding a label).
The issues or the pull requests will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
It means that any updates made, or any comments added to the issues or to the pull requests will restart the counter of days before marking as stale.
However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-issue-updates](#ignore-issue-updates) and [ignore-pr-updates](#ignore-pr-updates) options.
The idle number of days before marking the issues as stale (by adding a label).
The issues will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
It means that any updates made, or any comments added to the issues will restart the counter of days before marking as stale.
However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-issue-updates](#ignore-issue-updates) option.

If set to a negative number like `-1`, no issues or pull requests will be marked as stale automatically.
If set to a negative number like `-1`, no issues will be marked as stale automatically.
In that case, you can still add the stale label manually to mark as stale.

The label used to stale is defined by these two options:

- [stale-issue-label](#stale-issue-label)
- [stale-pr-label](#stale-pr-label)

A comment can also be added to notify about the stale and is defined by these two options:
The label used to stale is defined by this option: [stale-pr-label](#stale-pr-label)

- [stale-issue-message](#stale-issue-message)
- [stale-pr-message](#stale-pr-message)
A comment can also be added to notify about the stale and is defined by this option: [stale-pr-message](#stale-pr-message)

You can fine tune which issues or pull requests should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:
You can fine tune which issues should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:

- [exempt-issue-labels](#exempt-issue-labels)
- [exempt-pr-labels](#exempt-pr-labels)
- [only-issue-labels](#only-issue-labels)
- [only-pr-labels](#only-pr-labels)
- [any-of-issue-labels](#any-of-issue-labels)
- [any-of-pr-labels](#any-of-pr-labels)
- [start-date](#start-date)
- [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)
- [exempt-pr-assignees](#exempt-pr-assignees)
- [exempt-all-issue-assignees](#exempt-all-issue-assignees)
- [exempt-all-pr-assignees](#exempt-all-pr-assignees)
- [ignore-issue-updates](#ignore-issue-updates)
- [ignore-pr-updates](#ignore-pr-updates)

Default value: `60`

#### days-before-issue-stale
#### days-before-pr-stale

Useful to override [days-before-stale](#days-before-stale) but only for the idle number of days before marking the issues as stale.
The idle number of days before marking the pull requests as stale (by adding a label).
The pull requests will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
It means that any updates made, or any comments added to the pull requests will restart the counter of days before marking as stale.
However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-pr-updates](#ignore-pr-updates) option.

Default value: unset
If set to a negative number like `-1`, no pull requests will be marked as stale automatically.
In that case, you can still add the stale label manually to mark as stale.

#### days-before-pr-stale
The label used to stale is defined by this option: [stale-pr-label](#stale-pr-label)

Useful to override [days-before-stale](#days-before-stale) but only for the idle number of days before marking the pull requests as stale.
A comment can also be added to notify about the stale and is defined by this option: [stale-pr-message](#stale-pr-message)

Default value: unset
You can fine tune which pull requests should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:

- [exempt-pr-labels](#exempt-pr-labels)
- [only-pr-labels](#only-pr-labels)
- [any-of-pr-labels](#any-of-pr-labels)
- [start-date](#start-date)
- [exempt-pr-milestones](#exempt-pr-milestones)
- [exempt-all-pr-milestones](#exempt-all-pr-milestones)
- [exempt-pr-assignees](#exempt-pr-assignees)
- [exempt-all-pr-assignees](#exempt-all-pr-assignees)
- [ignore-pr-updates](#ignore-pr-updates)

Default value: `60`

#### days-before-issue-close

Expand Down
3 changes: 2 additions & 1 deletion __tests__/any-of-labels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ describe('any-of-pr-labels option', (): void => {
class IssuesProcessorBuilder {
private _options: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 0
daysBeforeIssueStale: 0,
daysBeforePrStale: 0
};
private _issues: Issue[] = [];

Expand Down
5 changes: 2 additions & 3 deletions __tests__/constants/default-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
stalePrMessage: 'This PR is stale',
closeIssueMessage: 'This issue is being closed',
closePrMessage: 'This PR is being closed',
daysBeforeStale: 1,
daysBeforeIssueStale: NaN,
daysBeforePrStale: NaN,
daysBeforeIssueStale: 1,
daysBeforePrStale: 1,
daysBeforeIssueClose: 30,
daysBeforePrClose: 30,
staleIssueLabel: 'Stale',
Expand Down
34 changes: 15 additions & 19 deletions __tests__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ test('processing an issue with no label will not make it stale if days-before-st
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
staleIssueMessage: '',
daysBeforeStale: -1
daysBeforeIssueStale: -1
};
const TestIssueList: Issue[] = [
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
Expand All @@ -370,7 +370,6 @@ test('processing an issue with no label will not make it stale if days-before-st
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
staleIssueMessage: '',
daysBeforeStale: -1,
daysBeforeIssueStale: -1
};
const TestIssueList: Issue[] = [
Expand Down Expand Up @@ -1304,7 +1303,7 @@ test('stale label containing a space should be removed if a comment was added to

test('stale issues should not be closed until after the closed number of days', async () => {
const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 1; // closes after 6 days
const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 5);
Expand Down Expand Up @@ -1335,7 +1334,7 @@ test('stale issues should not be closed until after the closed number of days',

test('stale issues should be closed if the closed nubmer of days (additive) is also passed', async () => {
const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 1; // closes after 6 days
const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 7);
Expand Down Expand Up @@ -1367,7 +1366,7 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a

test('stale issues should not be closed until after the closed number of days (long)', async () => {
const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days
const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10);
Expand Down Expand Up @@ -1398,7 +1397,7 @@ test('stale issues should not be closed until after the closed number of days (l

test('skips stale message on issues when stale-issue-message is empty', async () => {
const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.staleIssueMessage = '';
const lastUpdate = new Date();
Expand Down Expand Up @@ -1442,7 +1441,7 @@ test('skips stale message on issues when stale-issue-message is empty', 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.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.staleIssueMessage = 'dummy issue message';
const lastUpdate = new Date();
Expand Down Expand Up @@ -1486,7 +1485,7 @@ test('send stale message on issues when stale-issue-message is not empty', 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.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.stalePrMessage = '';
const lastUpdate = new Date();
Expand Down Expand Up @@ -1530,7 +1529,7 @@ test('skips stale message on prs when stale-pr-message is empty', 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.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.stalePrMessage = 'dummy pr message';
const lastUpdate = new Date();
Expand Down Expand Up @@ -1797,7 +1796,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
expect.assertions(2);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 3
};
const issueDate = new Date();
Expand All @@ -1823,7 +1821,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
expect.assertions(2);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 2
};
const issueDate = new Date();
Expand All @@ -1849,7 +1846,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
expect.assertions(2);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 1
};
const issueDate = new Date();
Expand All @@ -1875,7 +1871,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
expect.assertions(2);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 10,
daysBeforePrStale: 3
};
const issueDate = new Date();
Expand Down Expand Up @@ -1908,7 +1904,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
expect.assertions(2);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 10,
daysBeforePrStale: 2
};
const issueDate = new Date();
Expand Down Expand Up @@ -1941,7 +1937,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
expect.assertions(2);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 10,
daysBeforePrStale: 1
};
const issueDate = new Date();
Expand Down Expand Up @@ -2080,7 +2076,7 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
staleIssueLabel: 'stale-label',
daysBeforeStale: 30,
daysBeforeIssueStale: 30,
daysBeforeIssueClose: 7,
closeIssueMessage: 'close message',
removeStaleWhenUpdated: false
Expand Down Expand Up @@ -2121,7 +2117,7 @@ test('processing an issue stale since less than the daysBeforeStale without a st
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
staleIssueLabel: 'stale-label',
daysBeforeStale: 30,
daysBeforeIssueStale: 30,
daysBeforeIssueClose: 7,
closeIssueMessage: 'close message',
removeStaleWhenUpdated: false
Expand Down Expand Up @@ -2161,7 +2157,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
stalePrMessage: 'This PR is stale',
daysBeforeStale: 10,
daysBeforeIssueStale: 10,
daysBeforePrStale: 1
};
const issueDate = new Date();
Expand Down Expand Up @@ -2196,7 +2192,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
stalePrMessage: '',
daysBeforeStale: 10,
daysBeforeIssueStale: 10,
daysBeforePrStale: 1
};
const issueDate = new Date();
Expand Down
3 changes: 2 additions & 1 deletion __tests__/only-labels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ describe('only-pr-labels option', (): void => {
class IssuesProcessorBuilder {
private _options: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeStale: 0
daysBeforeIssueStale: 0,
daysBeforePrStale: 0
};
private _issues: Issue[] = [];

Expand Down
10 changes: 4 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ inputs:
close-pr-message:
description: 'The message to post on the pull request when closing it. If none provided, will not comment when closing a pull requests.'
required: false
days-before-stale:
description: 'The number of days old an issue or a pull request can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
required: false
default: '60'
days-before-issue-stale:
description: 'The number of days old an issue can be before marking it stale. Set to -1 to never mark issues as stale automatically. Override "days-before-stale" option regarding only the issues.'
description: 'The number of days old an issue can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
default: '60'
required: false
days-before-pr-stale:
description: 'The number of days old a pull request can be before marking it stale. Set to -1 to never mark pull requests as stale automatically. Override "days-before-stale" option regarding only the pull requests.'
description: 'The number of days old a pull request can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
default: '60'
required: false
days-before-issue-close:
description: 'The number of days to wait to close an issue after it being marked stale. Set to -1 to never close stale issues or pull requests.'
Expand Down
Loading

0 comments on commit bab816b

Please sign in to comment.