feat: remove the only-labels option

BREAKING CHANGE:
The option only-labels was removed
This commit is contained in:
TESTELIN Geoffrey 2021-10-08 20:39:44 +02:00
parent a8c5bb1c29
commit 6299c36a0d
No known key found for this signature in database
GPG Key ID: 05D28E8D8E8E52DA
11 changed files with 85 additions and 139 deletions

View File

@ -1,19 +1,20 @@
name: 'Stale issue handler' name: 'Stale issue handler'
on: on:
workflow_dispatch: workflow_dispatch:
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@main - uses: actions/stale@main
id: stale id: stale
with: 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' 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-stale: 30
days-before-close: 5 days-before-issue-close: 5
exempt-issue-labels: 'blocked,must,should,keep' days-before-pr-close: 5
- name: Print outputs exempt-issue-labels: 'blocked,must,should,keep'
run: echo ${{ join(steps.stale.outputs.*, ',') }} - name: Print outputs
run: echo ${{ join(steps.stale.outputs.*, ',') }}

View File

@ -34,9 +34,8 @@ Every argument is optional.
| [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 | |
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | | | [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
| [days-before-close](#days-before-close) | Idle number of days before closing stale issues/PRs | `7` | | [days-before-issue-close](#days-before-issue-close) | Idle number of days before closing stale issues | `7` |
| [days-before-issue-close](#days-before-issue-close) | Override [days-before-close](#days-before-close) for issues only | | | [days-before-pr-close](#days-before-pr-close) | Idle number of days before closing stale PRs | `7` |
| [days-before-pr-close](#days-before-pr-close) | Override [days-before-close](#days-before-close) for PRs only | |
| [stale-issue-message](#stale-issue-message) | Comment on the staled issues | | | [stale-issue-message](#stale-issue-message) | Comment on the staled issues | |
| [stale-pr-message](#stale-pr-message) | Comment on the staled PRs | | | [stale-pr-message](#stale-pr-message) | Comment on the staled PRs | |
| [close-issue-message](#close-issue-message) | Comment on the staled issues while closed | | | [close-issue-message](#close-issue-message) | Comment on the staled issues while closed | |
@ -144,32 +143,29 @@ Useful to override [days-before-stale](#days-before-stale) but only for the idle
Default value: unset Default value: unset
#### days-before-close #### days-before-issue-close
The idle number of days before closing the stale issues or the stale pull requests (due to the stale label). The idle number of days before closing the stale issues (due to the stale label).
The issues or the pull requests will be closed 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. The issues will be closed 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.
Since adding the stale label will alter the last update date, we can calculate the number of days from this date. Since adding the stale label will alter the last update date, we can calculate the number of days from this date.
If set to a negative number like `-1`, the issues or the pull requests will never be closed automatically. If set to a negative number like `-1`, the issues will never be closed automatically.
The label used to stale is defined by these two options: The label used to stale is defined by this option: [stale-issue-label](#stale-issue-label)
- [stale-issue-label](#stale-issue-label)
- [stale-pr-label](#stale-pr-label)
Default value: `7` Default value: `7`
#### days-before-issue-close
Override [days-before-close](#days-before-close) but only for the idle number of days before closing the stale issues.
Default value: unset
#### days-before-pr-close #### days-before-pr-close
Override [days-before-close](#days-before-close) but only for the idle number of days before closing the stale pull requests. The idle number of days before closing the stale pull requests (due to the stale label).
The pull requests will be closed 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.
Since adding the stale label will alter the last update date, we can calculate the number of days from this date.
Default value: unset If set to a negative number like `-1`, the pull requests will never be closed automatically.
The label used to stale is defined by this option: [stale-pr-label](#stale-pr-label)
Default value: `7`
#### stale-issue-message #### stale-issue-message
@ -527,7 +523,8 @@ jobs:
with: 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.' 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-stale: 30
days-before-close: 5 days-before-issue-close: 5
days-before-pr-close: 5
``` ```
Configure different stale timeouts but never close a PR: Configure different stale timeouts but never close a PR:
@ -548,7 +545,7 @@ jobs:
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.' stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.' close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
days-before-stale: 30 days-before-stale: 30
days-before-close: 5 days-before-issue-close: 5
days-before-pr-close: -1 days-before-pr-close: -1
``` ```

View File

@ -9,9 +9,8 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
daysBeforeStale: 1, daysBeforeStale: 1,
daysBeforeIssueStale: NaN, daysBeforeIssueStale: NaN,
daysBeforePrStale: NaN, daysBeforePrStale: NaN,
daysBeforeClose: 30, daysBeforeIssueClose: 30,
daysBeforeIssueClose: NaN, daysBeforePrClose: 30,
daysBeforePrClose: NaN,
staleIssueLabel: 'Stale', staleIssueLabel: 'Stale',
closeIssueLabel: '', closeIssueLabel: '',
exemptIssueLabels: '', exemptIssueLabels: '',

View File

@ -9,7 +9,7 @@ import {generateIssue} from './functions/generate-issue';
test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to 0', async () => { test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to 0', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0 daysBeforeIssueClose: 0
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z') generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
@ -33,7 +33,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
const january2000 = 946681200000; const january2000 = 946681200000;
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2000.toString() startDate: january2000.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -64,7 +64,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
const january2021 = 1609455600000; const january2021 = 1609455600000;
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2021.toString() startDate: january2021.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -95,7 +95,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
const january2000 = 946681200000000; const january2000 = 946681200000000;
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2000.toString() startDate: january2000.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -126,7 +126,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
const january2021 = 1609455600000; const january2021 = 1609455600000;
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2021.toString() startDate: january2021.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -157,7 +157,7 @@ test('processing an issue with no label and a start date as ISO 8601 being befor
const january2000 = '2000-01-01T00:00:00Z'; const january2000 = '2000-01-01T00:00:00Z';
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2000.toString() startDate: january2000.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -188,7 +188,7 @@ test('processing an issue with no label and a start date as ISO 8601 being after
const january2021 = '2021-01-01T00:00:00Z'; const january2021 = '2021-01-01T00:00:00Z';
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2021.toString() startDate: january2021.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -219,7 +219,7 @@ test('processing an issue with no label and a start date as RFC 2822 being befor
const january2000 = 'January 1, 2000 00:00:00'; const january2000 = 'January 1, 2000 00:00:00';
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2000.toString() startDate: january2000.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -250,7 +250,7 @@ test('processing an issue with no label and a start date as RFC 2822 being after
const january2021 = 'January 1, 2021 00:00:00'; const january2021 = 'January 1, 2021 00:00:00';
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 0, daysBeforeIssueClose: 0,
startDate: january2021.toString() startDate: january2021.toString()
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -279,7 +279,6 @@ test('processing an issue with no label and a start date as RFC 2822 being after
test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to 0', async () => { test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to 0', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 1,
daysBeforeIssueClose: 0 daysBeforeIssueClose: 0
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -300,33 +299,10 @@ test('processing an issue with no label will make it stale and close it, if it i
expect(processor.deletedBranchIssues).toHaveLength(0); expect(processor.deletedBranchIssues).toHaveLength(0);
}); });
test('processing an issue with no label will make it stale and not close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to > 0', async () => {
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeClose: 1,
daysBeforeIssueClose: 1
};
const TestIssueList: Issue[] = [
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
];
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).toHaveLength(1);
expect(processor.closedIssues).toHaveLength(0);
});
test('processing an issue with no label will make it stale and not close it if days-before-close is set to > 0', async () => { test('processing an issue with no label will make it stale and not close it if days-before-close is set to > 0', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 15 daysBeforeIssueClose: 15
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z') generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
@ -348,7 +324,6 @@ test('processing an issue with no label will make it stale and not close it if d
test('processing an issue with no label will make it stale and not close it if days-before-close is set to -1 and days-before-issue-close is set to > 0', async () => { test('processing an issue with no label will make it stale and not close it if days-before-close is set to -1 and days-before-issue-close is set to > 0', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: -1,
daysBeforeIssueClose: 15 daysBeforeIssueClose: 15
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -445,7 +420,7 @@ test('processing an issue with no label will make it stale but not close it', as
test('processing a stale issue will close it', async () => { test('processing a stale issue will close it', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 30 daysBeforeIssueClose: 30
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
@ -535,7 +510,7 @@ test('processing a stale issue containing a slash in the label will close it', a
test('processing a stale issue will close it when days-before-issue-stale override days-before-stale', async () => { test('processing a stale issue will close it when days-before-issue-stale override days-before-stale', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 30, daysBeforeIssueClose: 30,
daysBeforeIssueStale: 30 daysBeforeIssueStale: 30
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -566,7 +541,7 @@ test('processing a stale issue will close it when days-before-issue-stale overri
test('processing a stale PR will close it', async () => { test('processing a stale PR will close it', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 30 daysBeforePrClose: 30
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
@ -596,7 +571,6 @@ test('processing a stale PR will close it', async () => {
test('processing a stale PR will close it when days-before-pr-stale override days-before-stale', async () => { test('processing a stale PR will close it when days-before-pr-stale override days-before-stale', async () => {
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeClose: 30,
daysBeforePrClose: 30 daysBeforePrClose: 30
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -1134,7 +1108,8 @@ test('exempt issue labels will not be marked stale and will remove the existing
test('stale issues should not be closed if days is set to -1', async () => { test('stale issues should not be closed if days is set to -1', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeClose = -1; opts.daysBeforeIssueClose = -1;
opts.daysBeforePrClose = -1;
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue( generateIssue(
opts, opts,
@ -1330,7 +1305,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 () => { test('stale issues should not be closed until after the closed number of days', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeClose = 1; // closes after 6 days opts.daysBeforeIssueClose = 1; // closes after 6 days
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 5); lastUpdate.setDate(lastUpdate.getDate() - 5);
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -1361,7 +1336,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 () => { test('stale issues should be closed if the closed nubmer of days (additive) is also passed', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeStale = 5; // stale after 5 days
opts.daysBeforeClose = 1; // closes after 6 days opts.daysBeforeIssueClose = 1; // closes after 6 days
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 7); lastUpdate.setDate(lastUpdate.getDate() - 7);
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -1393,7 +1368,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 () => { test('stale issues should not be closed until after the closed number of days (long)', 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.daysBeforeIssueClose = 20; // closes after 25 days
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10); lastUpdate.setDate(lastUpdate.getDate() - 10);
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -1424,7 +1399,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 () => { 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.daysBeforeIssueClose = 20; // closes after 25 days
opts.staleIssueMessage = ''; opts.staleIssueMessage = '';
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10); lastUpdate.setDate(lastUpdate.getDate() - 10);
@ -1468,7 +1443,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 () => { 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.daysBeforeIssueClose = 20; // closes after 25 days
opts.staleIssueMessage = 'dummy issue message'; opts.staleIssueMessage = 'dummy issue message';
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10); lastUpdate.setDate(lastUpdate.getDate() - 10);
@ -1512,7 +1487,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 () => { test('skips stale message on prs when stale-pr-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.daysBeforeIssueClose = 20; // closes after 25 days
opts.stalePrMessage = ''; opts.stalePrMessage = '';
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10); lastUpdate.setDate(lastUpdate.getDate() - 10);
@ -1556,7 +1531,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 () => { 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.daysBeforeIssueClose = 20; // closes after 25 days
opts.stalePrMessage = 'dummy pr message'; opts.stalePrMessage = 'dummy pr message';
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10); lastUpdate.setDate(lastUpdate.getDate() - 10);
@ -2106,7 +2081,7 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
...DefaultProcessorOptions, ...DefaultProcessorOptions,
staleIssueLabel: 'stale-label', staleIssueLabel: 'stale-label',
daysBeforeStale: 30, daysBeforeStale: 30,
daysBeforeClose: 7, daysBeforeIssueClose: 7,
closeIssueMessage: 'close message', closeIssueMessage: 'close message',
removeStaleWhenUpdated: false removeStaleWhenUpdated: false
}; };
@ -2147,7 +2122,7 @@ test('processing an issue stale since less than the daysBeforeStale without a st
...DefaultProcessorOptions, ...DefaultProcessorOptions,
staleIssueLabel: 'stale-label', staleIssueLabel: 'stale-label',
daysBeforeStale: 30, daysBeforeStale: 30,
daysBeforeClose: 7, daysBeforeIssueClose: 7,
closeIssueMessage: 'close message', closeIssueMessage: 'close message',
removeStaleWhenUpdated: false removeStaleWhenUpdated: false
}; };

View File

@ -28,15 +28,13 @@ inputs:
days-before-pr-stale: 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 pull requests as stale automatically. Override "days-before-stale" option regarding only the pull requests.'
required: false required: false
days-before-close:
description: 'The number of days to wait to close an issue or a pull request after it being marked stale. Set to -1 to never close stale issues or pull requests.'
required: false
default: '7'
days-before-issue-close: 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. Override "days-before-close" option regarding only the issues.' 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.'
default: '7'
required: false required: false
days-before-pr-close: days-before-pr-close:
description: 'The number of days to wait to close a pull request after it being marked stale. Set to -1 to never close stale pull requests. Override "days-before-close" option regarding only the pull requests.' description: 'The number of days to wait to close a pull request after it being marked stale. Set to -1 to never close stale issues or pull requests.'
default: '7'
required: false required: false
stale-issue-label: stale-issue-label:
description: 'The label to apply when an issue is stale.' description: 'The label to apply when an issue is stale.'

23
dist/index.js vendored
View File

@ -669,8 +669,8 @@ class IssuesProcessor {
const issueHasComments = yield this._hasCommentsSince(issue, markedStaleOn, staleMessage); const issueHasComments = yield this._hasCommentsSince(issue, markedStaleOn, staleMessage);
issueLogger.info(`$$type has been commented on: ${logger_service_1.LoggerService.cyan(issueHasComments)}`); issueLogger.info(`$$type has been commented on: ${logger_service_1.LoggerService.cyan(issueHasComments)}`);
const daysBeforeClose = issue.isPullRequest const daysBeforeClose = issue.isPullRequest
? this._getDaysBeforePrClose() ? this.options.daysBeforePrClose
: this._getDaysBeforeIssueClose(); : this.options.daysBeforeIssueClose;
issueLogger.info(`Days before $$type close: ${logger_service_1.LoggerService.cyan(daysBeforeClose)}`); issueLogger.info(`Days before $$type close: ${logger_service_1.LoggerService.cyan(daysBeforeClose)}`);
const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose); const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose);
issueLogger.info(`$$type has been updated: ${logger_service_1.LoggerService.cyan(issueHasUpdate)}`); issueLogger.info(`$$type has been updated: ${logger_service_1.LoggerService.cyan(issueHasUpdate)}`);
@ -900,16 +900,6 @@ class IssuesProcessor {
? this.options.daysBeforeStale ? this.options.daysBeforeStale
: this.options.daysBeforePrStale; : this.options.daysBeforePrStale;
} }
_getDaysBeforeIssueClose() {
return isNaN(this.options.daysBeforeIssueClose)
? this.options.daysBeforeClose
: this.options.daysBeforeIssueClose;
}
_getDaysBeforePrClose() {
return isNaN(this.options.daysBeforePrClose)
? this.options.daysBeforeClose
: this.options.daysBeforePrClose;
}
_getOnlyLabels(issue) { _getOnlyLabels(issue) {
if (issue.isPullRequest) { if (issue.isPullRequest) {
return this.options.onlyPrLabels; return this.options.onlyPrLabels;
@ -1748,7 +1738,6 @@ var Option;
Option["DaysBeforeStale"] = "days-before-stale"; Option["DaysBeforeStale"] = "days-before-stale";
Option["DaysBeforeIssueStale"] = "days-before-issue-stale"; Option["DaysBeforeIssueStale"] = "days-before-issue-stale";
Option["DaysBeforePrStale"] = "days-before-pr-stale"; Option["DaysBeforePrStale"] = "days-before-pr-stale";
Option["DaysBeforeClose"] = "days-before-close";
Option["DaysBeforeIssueClose"] = "days-before-issue-close"; Option["DaysBeforeIssueClose"] = "days-before-issue-close";
Option["DaysBeforePrClose"] = "days-before-pr-close"; Option["DaysBeforePrClose"] = "days-before-pr-close";
Option["StaleIssueLabel"] = "stale-issue-label"; Option["StaleIssueLabel"] = "stale-issue-label";
@ -2050,9 +2039,8 @@ function _getAndValidateArgs() {
daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })), daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })),
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')), daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')),
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')), daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')),
daysBeforeClose: parseInt(core.getInput('days-before-close', { required: true })), daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close', { required: true })),
daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close')), daysBeforePrClose: parseInt(core.getInput('days-before-pr-close', { required: true })),
daysBeforePrClose: parseInt(core.getInput('days-before-pr-close')),
staleIssueLabel: core.getInput('stale-issue-label', { required: true }), staleIssueLabel: core.getInput('stale-issue-label', { required: true }),
closeIssueLabel: core.getInput('close-issue-label'), closeIssueLabel: core.getInput('close-issue-label'),
exemptIssueLabels: core.getInput('exempt-issue-labels'), exemptIssueLabels: core.getInput('exempt-issue-labels'),
@ -2090,7 +2078,8 @@ function _getAndValidateArgs() {
}; };
for (const numberInput of [ for (const numberInput of [
'days-before-stale', 'days-before-stale',
'days-before-close', 'days-before-issue-close',
'days-before-pr-close',
'operations-per-run' 'operations-per-run'
]) { ]) {
if (isNaN(parseInt(core.getInput(numberInput)))) { if (isNaN(parseInt(core.getInput(numberInput)))) {

View File

@ -17,7 +17,6 @@ describe('Issue', (): void => {
closeIssueMessage: '', closeIssueMessage: '',
closePrLabel: '', closePrLabel: '',
closePrMessage: '', closePrMessage: '',
daysBeforeClose: 0,
daysBeforeIssueClose: 0, daysBeforeIssueClose: 0,
daysBeforeIssueStale: 0, daysBeforeIssueStale: 0,
daysBeforePrClose: 0, daysBeforePrClose: 0,

View File

@ -640,8 +640,8 @@ export class IssuesProcessor {
); );
const daysBeforeClose: number = issue.isPullRequest const daysBeforeClose: number = issue.isPullRequest
? this._getDaysBeforePrClose() ? this.options.daysBeforePrClose
: this._getDaysBeforeIssueClose(); : this.options.daysBeforeIssueClose;
issueLogger.info( issueLogger.info(
`Days before $$type close: ${LoggerService.cyan(daysBeforeClose)}` `Days before $$type close: ${LoggerService.cyan(daysBeforeClose)}`
@ -969,18 +969,6 @@ export class IssuesProcessor {
: this.options.daysBeforePrStale; : this.options.daysBeforePrStale;
} }
private _getDaysBeforeIssueClose(): number {
return isNaN(this.options.daysBeforeIssueClose)
? this.options.daysBeforeClose
: this.options.daysBeforeIssueClose;
}
private _getDaysBeforePrClose(): number {
return isNaN(this.options.daysBeforePrClose)
? this.options.daysBeforeClose
: this.options.daysBeforePrClose;
}
private _getOnlyLabels(issue: Issue): string { private _getOnlyLabels(issue: Issue): string {
if (issue.isPullRequest) { if (issue.isPullRequest) {
return this.options.onlyPrLabels; return this.options.onlyPrLabels;

View File

@ -7,7 +7,6 @@ export enum Option {
DaysBeforeStale = 'days-before-stale', DaysBeforeStale = 'days-before-stale',
DaysBeforeIssueStale = 'days-before-issue-stale', DaysBeforeIssueStale = 'days-before-issue-stale',
DaysBeforePrStale = 'days-before-pr-stale', DaysBeforePrStale = 'days-before-pr-stale',
DaysBeforeClose = 'days-before-close',
DaysBeforeIssueClose = 'days-before-issue-close', DaysBeforeIssueClose = 'days-before-issue-close',
DaysBeforePrClose = 'days-before-pr-close', DaysBeforePrClose = 'days-before-pr-close',
StaleIssueLabel = 'stale-issue-label', StaleIssueLabel = 'stale-issue-label',

View File

@ -9,9 +9,8 @@ export interface IIssuesProcessorOptions {
daysBeforeStale: number; daysBeforeStale: number;
daysBeforeIssueStale: number; // Could be NaN daysBeforeIssueStale: number; // Could be NaN
daysBeforePrStale: number; // Could be NaN daysBeforePrStale: number; // Could be NaN
daysBeforeClose: number; daysBeforeIssueClose: number;
daysBeforeIssueClose: number; // Could be NaN daysBeforePrClose: number;
daysBeforePrClose: number; // Could be NaN
staleIssueLabel: string; staleIssueLabel: string;
closeIssueLabel: string; closeIssueLabel: string;
exemptIssueLabels: string; exemptIssueLabels: string;

View File

@ -33,11 +33,12 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
), ),
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')), daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')),
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')), daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')),
daysBeforeClose: parseInt( daysBeforeIssueClose: parseInt(
core.getInput('days-before-close', {required: true}) core.getInput('days-before-issue-close', {required: true})
),
daysBeforePrClose: parseInt(
core.getInput('days-before-pr-close', {required: true})
), ),
daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close')),
daysBeforePrClose: parseInt(core.getInput('days-before-pr-close')),
staleIssueLabel: core.getInput('stale-issue-label', {required: true}), staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
closeIssueLabel: core.getInput('close-issue-label'), closeIssueLabel: core.getInput('close-issue-label'),
exemptIssueLabels: core.getInput('exempt-issue-labels'), exemptIssueLabels: core.getInput('exempt-issue-labels'),
@ -87,7 +88,8 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
for (const numberInput of [ for (const numberInput of [
'days-before-stale', 'days-before-stale',
'days-before-close', 'days-before-issue-close',
'days-before-pr-close',
'operations-per-run' 'operations-per-run'
]) { ]) {
if (isNaN(parseInt(core.getInput(numberInput)))) { if (isNaN(parseInt(core.getInput(numberInput)))) {