parent
9d6f46564a
commit
e96f31f877
|
@ -1,19 +1,20 @@
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
import {Issue} from '../src/classes/issue';
|
import {Issue} from '../src/classes/issue';
|
||||||
|
|
||||||
import {IssueProcessor, IssueProcessorOptions} from '../src/IssueProcessor';
|
import {IssuesProcessor} from '../src/classes/issues-processor';
|
||||||
|
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
||||||
import {IsoDateString} from '../src/types/iso-date-string';
|
import {IsoDateString} from '../src/types/iso-date-string';
|
||||||
|
|
||||||
function generateIssue(
|
function generateIssue(
|
||||||
options: IssueProcessorOptions,
|
options: IIssuesProcessorOptions,
|
||||||
id: number,
|
id: number,
|
||||||
title: string,
|
title: string,
|
||||||
updatedAt: IsoDateString,
|
updatedAt: IsoDateString,
|
||||||
createdAt: IsoDateString = updatedAt,
|
createdAt: IsoDateString = updatedAt,
|
||||||
isPullRequest: boolean = false,
|
isPullRequest = false,
|
||||||
labels: string[] = [],
|
labels: string[] = [],
|
||||||
isClosed: boolean = false,
|
isClosed = false,
|
||||||
isLocked: boolean = false,
|
isLocked = false,
|
||||||
milestone = ''
|
milestone = ''
|
||||||
): Issue {
|
): Issue {
|
||||||
return new Issue(options, {
|
return new Issue(options, {
|
||||||
|
@ -21,7 +22,7 @@ function generateIssue(
|
||||||
labels: labels.map(l => {
|
labels: labels.map(l => {
|
||||||
return {name: l};
|
return {name: l};
|
||||||
}),
|
}),
|
||||||
title: title,
|
title,
|
||||||
created_at: createdAt,
|
created_at: createdAt,
|
||||||
updated_at: updatedAt,
|
updated_at: updatedAt,
|
||||||
pull_request: isPullRequest ? {} : null,
|
pull_request: isPullRequest ? {} : null,
|
||||||
|
@ -33,7 +34,7 @@ function generateIssue(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultProcessorOptions: IssueProcessorOptions = Object.freeze({
|
const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||||
repoToken: 'none',
|
repoToken: 'none',
|
||||||
staleIssueMessage: 'This issue is stale',
|
staleIssueMessage: 'This issue is stale',
|
||||||
stalePrMessage: 'This PR is stale',
|
stalePrMessage: 'This PR is stale',
|
||||||
|
@ -66,7 +67,7 @@ const DefaultProcessorOptions: IssueProcessorOptions = Object.freeze({
|
||||||
});
|
});
|
||||||
|
|
||||||
test('empty issue list results in 1 operation', async () => {
|
test('empty issue list results in 1 operation', async () => {
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async () => [],
|
async () => [],
|
||||||
|
@ -82,14 +83,14 @@ test('empty issue list results in 1 operation', 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 () => {
|
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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0
|
daysBeforeClose: 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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -107,7 +108,7 @@ test('processing an issue with no label will make it stale and close it, if it i
|
||||||
test('processing an issue with no label and a start date as ECMAScript epoch in seconds being before the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as ECMAScript epoch in seconds being before the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2000 = 946681200000;
|
const january2000 = 946681200000;
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2000.toString()
|
startDate: january2000.toString()
|
||||||
|
@ -121,7 +122,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -139,7 +140,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
test('processing an issue with no label and a start date as ECMAScript epoch in seconds being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as ECMAScript epoch in seconds being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2021 = 1609455600000;
|
const january2021 = 1609455600000;
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2021.toString()
|
startDate: january2021.toString()
|
||||||
|
@ -153,7 +154,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -171,7 +172,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
test('processing an issue with no label and a start date as ECMAScript epoch in milliseconds being before the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as ECMAScript epoch in milliseconds being before the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2000 = 946681200000000;
|
const january2000 = 946681200000000;
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2000.toString()
|
startDate: january2000.toString()
|
||||||
|
@ -185,7 +186,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -203,7 +204,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
test('processing an issue with no label and a start date as ECMAScript epoch in milliseconds being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as ECMAScript epoch in milliseconds being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2021 = 1609455600000;
|
const january2021 = 1609455600000;
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2021.toString()
|
startDate: january2021.toString()
|
||||||
|
@ -217,7 +218,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -235,7 +236,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||||
test('processing an issue with no label and a start date as ISO 8601 being before the issue creation date will make it stale and close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as ISO 8601 being before the issue creation date will make it stale and close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2000 = '2000-01-01T00:00:00Z';
|
const january2000 = '2000-01-01T00:00:00Z';
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2000.toString()
|
startDate: january2000.toString()
|
||||||
|
@ -249,7 +250,7 @@ test('processing an issue with no label and a start date as ISO 8601 being befor
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -267,7 +268,7 @@ test('processing an issue with no label and a start date as ISO 8601 being befor
|
||||||
test('processing an issue with no label and a start date as ISO 8601 being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as ISO 8601 being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2021 = '2021-01-01T00:00:00Z';
|
const january2021 = '2021-01-01T00:00:00Z';
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2021.toString()
|
startDate: january2021.toString()
|
||||||
|
@ -281,7 +282,7 @@ test('processing an issue with no label and a start date as ISO 8601 being after
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -299,7 +300,7 @@ test('processing an issue with no label and a start date as ISO 8601 being after
|
||||||
test('processing an issue with no label and a start date as RFC 2822 being before the issue creation date will make it stale and close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as RFC 2822 being before the issue creation date will make it stale and close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2000 = 'January 1, 2000 00:00:00';
|
const january2000 = 'January 1, 2000 00:00:00';
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2000.toString()
|
startDate: january2000.toString()
|
||||||
|
@ -313,7 +314,7 @@ test('processing an issue with no label and a start date as RFC 2822 being befor
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -331,7 +332,7 @@ test('processing an issue with no label and a start date as RFC 2822 being befor
|
||||||
test('processing an issue with no label and a start date as RFC 2822 being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
test('processing an issue with no label and a start date as RFC 2822 being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const january2021 = 'January 1, 2021 00:00:00';
|
const january2021 = 'January 1, 2021 00:00:00';
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0,
|
||||||
startDate: january2021.toString()
|
startDate: january2021.toString()
|
||||||
|
@ -345,7 +346,7 @@ test('processing an issue with no label and a start date as RFC 2822 being after
|
||||||
'2020-01-01T17:00:00Z'
|
'2020-01-01T17:00:00Z'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -361,7 +362,7 @@ 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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 1,
|
daysBeforeClose: 1,
|
||||||
daysBeforeIssueClose: 0
|
daysBeforeIssueClose: 0
|
||||||
|
@ -369,7 +370,7 @@ test('processing an issue with no label will make it stale and close it, if it i
|
||||||
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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -386,7 +387,7 @@ test('processing an issue with no label will make it stale and close it, if it i
|
||||||
});
|
});
|
||||||
|
|
||||||
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 () => {
|
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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 1,
|
daysBeforeClose: 1,
|
||||||
daysBeforeIssueClose: 1
|
daysBeforeIssueClose: 1
|
||||||
|
@ -394,7 +395,7 @@ test('processing an issue with no label will make it stale and not close it, if
|
||||||
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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -410,14 +411,14 @@ test('processing an issue with no label will make it stale and not close it, if
|
||||||
});
|
});
|
||||||
|
|
||||||
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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 15
|
daysBeforeClose: 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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -433,7 +434,7 @@ 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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: -1,
|
daysBeforeClose: -1,
|
||||||
daysBeforeIssueClose: 15
|
daysBeforeIssueClose: 15
|
||||||
|
@ -441,7 +442,7 @@ test('processing an issue with no label will make it stale and not close it if d
|
||||||
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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -457,7 +458,7 @@ 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 not make it stale if days-before-stale is set to -1', async () => {
|
test('processing an issue with no label will not make it stale if days-before-stale is set to -1', async () => {
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
staleIssueMessage: '',
|
staleIssueMessage: '',
|
||||||
daysBeforeStale: -1
|
daysBeforeStale: -1
|
||||||
|
@ -465,7 +466,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||||
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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -481,7 +482,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing an issue with no label will not make it stale if days-before-stale and days-before-issue-stale are set to -1', async () => {
|
test('processing an issue with no label will not make it stale if days-before-stale and days-before-issue-stale are set to -1', async () => {
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
staleIssueMessage: '',
|
staleIssueMessage: '',
|
||||||
daysBeforeStale: -1,
|
daysBeforeStale: -1,
|
||||||
|
@ -490,7 +491,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||||
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')
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -508,7 +509,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||||
test('processing an issue with no label will make it stale but not close it', async () => {
|
test('processing an issue with no label will make it stale but not close it', async () => {
|
||||||
// issue should be from 2 days ago so it will be
|
// issue should be from 2 days ago so it will be
|
||||||
// stale but not close-able, based on default settings
|
// stale but not close-able, based on default settings
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -518,7 +519,7 @@ test('processing an issue with no label will make it stale but not close it', as
|
||||||
issueDate.toDateString()
|
issueDate.toDateString()
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -534,7 +535,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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 30
|
daysBeforeClose: 30
|
||||||
};
|
};
|
||||||
|
@ -549,7 +550,7 @@ test('processing a stale issue will close it', async () => {
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -565,7 +566,7 @@ test('processing a stale issue will close it', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing a stale issue containing a space in the label will close it', async () => {
|
test('processing a stale issue containing a space in the label will close it', async () => {
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
staleIssueLabel: 'state: stale'
|
staleIssueLabel: 'state: stale'
|
||||||
};
|
};
|
||||||
|
@ -580,7 +581,7 @@ test('processing a stale issue containing a space in the label will close it', a
|
||||||
['state: stale']
|
['state: stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -596,7 +597,7 @@ test('processing a stale issue containing a space in the label will close it', a
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing a stale issue containing a slash in the label will close it', async () => {
|
test('processing a stale issue containing a slash in the label will close it', async () => {
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
staleIssueLabel: 'lifecycle/stale'
|
staleIssueLabel: 'lifecycle/stale'
|
||||||
};
|
};
|
||||||
|
@ -611,7 +612,7 @@ test('processing a stale issue containing a slash in the label will close it', a
|
||||||
['lifecycle/stale']
|
['lifecycle/stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -627,7 +628,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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 30,
|
daysBeforeClose: 30,
|
||||||
daysBeforeIssueStale: 30
|
daysBeforeIssueStale: 30
|
||||||
|
@ -643,7 +644,7 @@ test('processing a stale issue will close it when days-before-issue-stale overri
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -659,7 +660,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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 30
|
daysBeforeClose: 30
|
||||||
};
|
};
|
||||||
|
@ -674,7 +675,7 @@ test('processing a stale PR will close it', async () => {
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -690,7 +691,7 @@ 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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 30,
|
daysBeforeClose: 30,
|
||||||
daysBeforePrClose: 30
|
daysBeforePrClose: 30
|
||||||
|
@ -706,7 +707,7 @@ test('processing a stale PR will close it when days-before-pr-stale override day
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -738,7 +739,7 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -771,7 +772,7 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -803,7 +804,7 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -836,7 +837,7 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -864,7 +865,7 @@ test('closed issues will not be marked stale', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -891,7 +892,7 @@ test('stale closed issues will not be closed', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -919,7 +920,7 @@ test('closed prs will not be marked stale', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -947,7 +948,7 @@ test('stale closed prs will not be closed', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -976,7 +977,7 @@ test('locked issues will not be marked stale', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : [])
|
async p => (p == 1 ? TestIssueList : [])
|
||||||
|
@ -1003,7 +1004,7 @@ test('stale locked issues will not be closed', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1032,7 +1033,7 @@ test('locked prs will not be marked stale', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : [])
|
async p => (p == 1 ? TestIssueList : [])
|
||||||
|
@ -1059,7 +1060,7 @@ test('stale locked prs will not be closed', async () => {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1089,7 +1090,7 @@ test('exempt issue labels will not be marked stale', async () => {
|
||||||
['Exempt']
|
['Exempt']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1119,7 +1120,7 @@ test('exempt issue labels will not be marked stale (multi issue label with space
|
||||||
['Cool']
|
['Cool']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1148,7 +1149,7 @@ test('exempt issue labels will not be marked stale (multi issue label)', async (
|
||||||
['Cool']
|
['Cool']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1195,7 +1196,7 @@ test('exempt pr labels will not be marked stale', async () => {
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1224,7 +1225,7 @@ test('exempt issue labels will not be marked stale and will remove the existing
|
||||||
['Exempt', 'Stale']
|
['Exempt', 'Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1279,7 +1280,7 @@ test('stale issues should not be closed if days is set to -1', async () => {
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1308,7 +1309,7 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1346,7 +1347,7 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1370,7 +1371,7 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
||||||
});
|
});
|
||||||
|
|
||||||
test('stale label containing a space should be removed if a comment was added to a stale issue', async () => {
|
test('stale label containing a space should be removed if a comment was added to a stale issue', async () => {
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
removeStaleWhenUpdated: true,
|
removeStaleWhenUpdated: true,
|
||||||
staleIssueLabel: 'stat: stale'
|
staleIssueLabel: 'stat: stale'
|
||||||
|
@ -1386,7 +1387,7 @@ test('stale label containing a space should be removed if a comment was added to
|
||||||
['stat: stale']
|
['stat: stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1406,7 +1407,7 @@ test('stale issues should not be closed until after the closed number of days',
|
||||||
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.daysBeforeClose = 1; // closes after 6 days
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 5);
|
lastUpdate.setDate(lastUpdate.getDate() - 5);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1418,7 +1419,7 @@ test('stale issues should not be closed until after the closed number of days',
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1438,7 +1439,7 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a
|
||||||
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.daysBeforeClose = 1; // closes after 6 days
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 7);
|
lastUpdate.setDate(lastUpdate.getDate() - 7);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1451,7 +1452,7 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1471,7 +1472,7 @@ test('stale issues should not be closed until after the closed number of days (l
|
||||||
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
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1483,7 +1484,7 @@ test('stale issues should not be closed until after the closed number of days (l
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1504,7 +1505,7 @@ test('skips stale message on issues when skip-stale-issue-message is set', async
|
||||||
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.skipStaleIssueMessage = true;
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1516,7 +1517,7 @@ test('skips stale message on issues when skip-stale-issue-message is set', async
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1549,7 +1550,7 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
|
||||||
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.skipStalePrMessage = true;
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1561,7 +1562,7 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1595,7 +1596,7 @@ test('not providing state takes precedence over skipStaleIssueMessage', async ()
|
||||||
opts.daysBeforeClose = 20; // closes after 25 days
|
opts.daysBeforeClose = 20; // closes after 25 days
|
||||||
opts.skipStalePrMessage = true;
|
opts.skipStalePrMessage = true;
|
||||||
opts.staleIssueMessage = '';
|
opts.staleIssueMessage = '';
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1607,7 +1608,7 @@ test('not providing state takes precedence over skipStaleIssueMessage', async ()
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1629,7 +1630,7 @@ test('not providing stalePrMessage takes precedence over skipStalePrMessage', as
|
||||||
opts.daysBeforeClose = 20; // closes after 25 days
|
opts.daysBeforeClose = 20; // closes after 25 days
|
||||||
opts.skipStalePrMessage = true;
|
opts.skipStalePrMessage = true;
|
||||||
opts.stalePrMessage = '';
|
opts.stalePrMessage = '';
|
||||||
let lastUpdate = new Date();
|
const lastUpdate = new Date();
|
||||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1641,7 +1642,7 @@ test('not providing stalePrMessage takes precedence over skipStalePrMessage', as
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1671,7 +1672,7 @@ test('git branch is deleted when option is enabled', async () => {
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1701,7 +1702,7 @@ test('git branch is not deleted when issue is not pull request', async () => {
|
||||||
['Stale']
|
['Stale']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1733,7 +1734,7 @@ test('an issue without a milestone will be marked as stale', async () => {
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1767,7 +1768,7 @@ test('an issue without an exempted milestone will be marked as stale', async ()
|
||||||
'Milestone'
|
'Milestone'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1801,7 +1802,7 @@ test('an issue with an exempted milestone will not be marked as stale', async ()
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1835,7 +1836,7 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||||
'Milestone2'
|
'Milestone2'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1869,7 +1870,7 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||||
'Milestone2'
|
'Milestone2'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1904,7 +1905,7 @@ test('an issue with an exempted milestone but without an exempted issue mileston
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1939,7 +1940,7 @@ test('an issue with an exempted milestone but with another exempted issue milest
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -1974,7 +1975,7 @@ test('an issue with an exempted milestone and with an exempted issue milestone w
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2006,7 +2007,7 @@ test('a PR without a milestone will be marked as stale', async () => {
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
DefaultProcessorOptions,
|
DefaultProcessorOptions,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2040,7 +2041,7 @@ test('a PR without an exempted milestone will be marked as stale', async () => {
|
||||||
'Milestone'
|
'Milestone'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2074,7 +2075,7 @@ test('a PR with an exempted milestone will not be marked as stale', async () =>
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2108,7 +2109,7 @@ test('a PR with an exempted milestone will not be marked as stale (multi milesto
|
||||||
'Milestone2'
|
'Milestone2'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2142,7 +2143,7 @@ test('a PR with an exempted milestone will not be marked as stale (multi milesto
|
||||||
'Milestone2'
|
'Milestone2'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2177,7 +2178,7 @@ test('a PR with an exempted milestone but without an exempted issue milestone wi
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2212,7 +2213,7 @@ test('a PR with an exempted milestone but with another exempted issue milestone
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2247,7 +2248,7 @@ test('a PR with an exempted milestone and with an exempted issue milestone will
|
||||||
'Milestone1'
|
'Milestone1'
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2265,17 +2266,17 @@ test('a PR with an exempted milestone and with an exempted issue milestone will
|
||||||
|
|
||||||
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: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforeIssueStale: 3
|
daysBeforeIssueStale: 3
|
||||||
};
|
};
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2292,17 +2293,17 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||||
|
|
||||||
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 2 will make it stale', async () => {
|
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 2 will make it stale', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforeIssueStale: 2
|
daysBeforeIssueStale: 2
|
||||||
};
|
};
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2319,17 +2320,17 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||||
|
|
||||||
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 1 will make it stale', async () => {
|
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 1 will make it stale', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforeIssueStale: 1
|
daysBeforeIssueStale: 1
|
||||||
};
|
};
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2346,12 +2347,12 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||||
|
|
||||||
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 3 will not make it stale', async () => {
|
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 3 will not make it stale', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforePrStale: 3
|
daysBeforePrStale: 3
|
||||||
};
|
};
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -2363,7 +2364,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2380,12 +2381,12 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||||
|
|
||||||
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 2 will make it stale', async () => {
|
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 2 will make it stale', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforePrStale: 2
|
daysBeforePrStale: 2
|
||||||
};
|
};
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -2397,7 +2398,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
@ -2414,12 +2415,12 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||||
|
|
||||||
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 1 will make it stale', async () => {
|
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 1 will make it stale', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const opts: IssueProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforePrStale: 1
|
daysBeforePrStale: 1
|
||||||
};
|
};
|
||||||
let issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -2431,7 +2432,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssuesProcessor(
|
||||||
opts,
|
opts,
|
||||||
async () => 'abot',
|
async () => 'abot',
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
|
|
@ -2,7 +2,43 @@ module.exports =
|
||||||
/******/ (() => { // webpackBootstrap
|
/******/ (() => { // webpackBootstrap
|
||||||
/******/ var __webpack_modules__ = ({
|
/******/ var __webpack_modules__ = ({
|
||||||
|
|
||||||
/***/ 4407:
|
/***/ 4783:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.Issue = void 0;
|
||||||
|
const is_labeled_1 = __nccwpck_require__(6792);
|
||||||
|
const is_pull_request_1 = __nccwpck_require__(5400);
|
||||||
|
class Issue {
|
||||||
|
constructor(options, issue) {
|
||||||
|
this._options = options;
|
||||||
|
this.title = issue.title;
|
||||||
|
this.number = issue.number;
|
||||||
|
this.created_at = issue.created_at;
|
||||||
|
this.updated_at = issue.updated_at;
|
||||||
|
this.labels = issue.labels;
|
||||||
|
this.pull_request = issue.pull_request;
|
||||||
|
this.state = issue.state;
|
||||||
|
this.locked = issue.locked;
|
||||||
|
this.milestone = issue.milestone;
|
||||||
|
this.isPullRequest = is_pull_request_1.isPullRequest(this);
|
||||||
|
this.staleLabel = this._getStaleLabel();
|
||||||
|
this.isStale = is_labeled_1.isLabeled(this, this.staleLabel);
|
||||||
|
}
|
||||||
|
_getStaleLabel() {
|
||||||
|
return this.isPullRequest
|
||||||
|
? this._options.stalePrLabel
|
||||||
|
: this._options.staleIssueLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Issue = Issue;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 3292:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -17,12 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.IssueProcessor = void 0;
|
exports.IssuesProcessor = void 0;
|
||||||
const github_1 = __nccwpck_require__(5438);
|
const github_1 = __nccwpck_require__(5438);
|
||||||
const issue_1 = __nccwpck_require__(4783);
|
|
||||||
const issue_logger_1 = __nccwpck_require__(2984);
|
|
||||||
const logger_1 = __nccwpck_require__(6212);
|
|
||||||
const milestones_1 = __nccwpck_require__(4601);
|
|
||||||
const get_humanized_date_1 = __nccwpck_require__(965);
|
const get_humanized_date_1 = __nccwpck_require__(965);
|
||||||
const is_date_more_recent_than_1 = __nccwpck_require__(1473);
|
const is_date_more_recent_than_1 = __nccwpck_require__(1473);
|
||||||
const is_valid_date_1 = __nccwpck_require__(891);
|
const is_valid_date_1 = __nccwpck_require__(891);
|
||||||
|
@ -31,10 +63,14 @@ const is_labeled_1 = __nccwpck_require__(6792);
|
||||||
const is_pull_request_1 = __nccwpck_require__(5400);
|
const is_pull_request_1 = __nccwpck_require__(5400);
|
||||||
const should_mark_when_stale_1 = __nccwpck_require__(2461);
|
const should_mark_when_stale_1 = __nccwpck_require__(2461);
|
||||||
const words_to_list_1 = __nccwpck_require__(1883);
|
const words_to_list_1 = __nccwpck_require__(1883);
|
||||||
|
const issue_1 = __nccwpck_require__(4783);
|
||||||
|
const issue_logger_1 = __nccwpck_require__(2984);
|
||||||
|
const logger_1 = __nccwpck_require__(6212);
|
||||||
|
const milestones_1 = __nccwpck_require__(4601);
|
||||||
/***
|
/***
|
||||||
* Handle processing of issues for staleness/closure.
|
* Handle processing of issues for staleness/closure.
|
||||||
*/
|
*/
|
||||||
class IssueProcessor {
|
class IssuesProcessor {
|
||||||
constructor(options, getActor, getIssues, listIssueComments, getLabelCreationDate) {
|
constructor(options, getActor, getIssues, listIssueComments, getLabelCreationDate) {
|
||||||
this._logger = new logger_1.Logger();
|
this._logger = new logger_1.Logger();
|
||||||
this._operationsLeft = 0;
|
this._operationsLeft = 0;
|
||||||
|
@ -157,7 +193,7 @@ class IssueProcessor {
|
||||||
continue; // don't process exempt milestones
|
continue; // don't process exempt milestones
|
||||||
}
|
}
|
||||||
// should this issue be marked stale?
|
// should this issue be marked stale?
|
||||||
const shouldBeStale = !IssueProcessor._updatedSince(issue.updated_at, daysBeforeStale);
|
const shouldBeStale = !IssuesProcessor._updatedSince(issue.updated_at, daysBeforeStale);
|
||||||
// determine if this issue needs to be marked stale first
|
// determine if this issue needs to be marked stale first
|
||||||
if (!issue.isStale && shouldBeStale && shouldMarkAsStale) {
|
if (!issue.isStale && shouldBeStale && shouldMarkAsStale) {
|
||||||
issueLogger.info(`Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label`);
|
issueLogger.info(`Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label`);
|
||||||
|
@ -199,7 +235,7 @@ class IssueProcessor {
|
||||||
else {
|
else {
|
||||||
issueLogger.info(`Days before issue close: ${daysBeforeClose}`);
|
issueLogger.info(`Days before issue close: ${daysBeforeClose}`);
|
||||||
}
|
}
|
||||||
const issueHasUpdate = IssueProcessor._updatedSince(issue.updated_at, daysBeforeClose);
|
const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose);
|
||||||
issueLogger.info(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
|
issueLogger.info(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
|
||||||
// should we un-stale this issue?
|
// should we un-stale this issue?
|
||||||
if (this.options.removeStaleWhenUpdated && issueHasComments) {
|
if (this.options.removeStaleWhenUpdated && issueHasComments) {
|
||||||
|
@ -503,43 +539,7 @@ class IssueProcessor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.IssueProcessor = IssueProcessor;
|
exports.IssuesProcessor = IssuesProcessor;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 4783:
|
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.Issue = void 0;
|
|
||||||
const is_labeled_1 = __nccwpck_require__(6792);
|
|
||||||
const is_pull_request_1 = __nccwpck_require__(5400);
|
|
||||||
class Issue {
|
|
||||||
constructor(options, issue) {
|
|
||||||
this._options = options;
|
|
||||||
this.title = issue.title;
|
|
||||||
this.number = issue.number;
|
|
||||||
this.created_at = issue.created_at;
|
|
||||||
this.updated_at = issue.updated_at;
|
|
||||||
this.labels = issue.labels;
|
|
||||||
this.pull_request = issue.pull_request;
|
|
||||||
this.state = issue.state;
|
|
||||||
this.locked = issue.locked;
|
|
||||||
this.milestone = issue.milestone;
|
|
||||||
this.isPullRequest = is_pull_request_1.isPullRequest(this);
|
|
||||||
this.staleLabel = this._getStaleLabel();
|
|
||||||
this.isStale = is_labeled_1.isLabeled(this, this.staleLabel);
|
|
||||||
}
|
|
||||||
_getStaleLabel() {
|
|
||||||
return this.isPullRequest
|
|
||||||
? this._options.stalePrLabel
|
|
||||||
: this._options.staleIssueLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Issue = Issue;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -924,12 +924,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const is_valid_date_1 = __nccwpck_require__(891);
|
const is_valid_date_1 = __nccwpck_require__(891);
|
||||||
const IssueProcessor_1 = __nccwpck_require__(4407);
|
const issues_processor_1 = __nccwpck_require__(3292);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const args = getAndValidateArgs();
|
const args = getAndValidateArgs();
|
||||||
const processor = new IssueProcessor_1.IssueProcessor(args);
|
const processor = new issues_processor_1.IssuesProcessor(args);
|
||||||
yield processor.processIssues();
|
yield processor.processIssues();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import {IIssue} from '../interfaces/issue';
|
import {IIssue} from '../interfaces/issue';
|
||||||
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
|
import {ILabel} from '../interfaces/label';
|
||||||
import {IMilestone} from '../interfaces/milestone';
|
import {IMilestone} from '../interfaces/milestone';
|
||||||
import {IssueProcessorOptions, Label} from '../IssueProcessor';
|
|
||||||
import {Issue} from './issue';
|
import {Issue} from './issue';
|
||||||
|
|
||||||
describe('Issue', (): void => {
|
describe('Issue', (): void => {
|
||||||
let issue: Issue;
|
let issue: Issue;
|
||||||
let optionsInterface: IssueProcessorOptions;
|
let optionsInterface: IIssuesProcessorOptions;
|
||||||
let issueInterface: IIssue;
|
let issueInterface: IIssue;
|
||||||
|
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
|
@ -91,7 +92,7 @@ describe('Issue', (): void => {
|
||||||
expect(issue.labels).toStrictEqual([
|
expect(issue.labels).toStrictEqual([
|
||||||
{
|
{
|
||||||
name: 'dummy-name'
|
name: 'dummy-name'
|
||||||
} as Label
|
} as ILabel
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -193,7 +194,7 @@ describe('Issue', (): void => {
|
||||||
issueInterface.labels = [
|
issueInterface.labels = [
|
||||||
{
|
{
|
||||||
name: 'dummy-stale-issue-label'
|
name: 'dummy-stale-issue-label'
|
||||||
} as Label
|
} as ILabel
|
||||||
];
|
];
|
||||||
issue = new Issue(optionsInterface, issueInterface);
|
issue = new Issue(optionsInterface, issueInterface);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import {isLabeled} from '../functions/is-labeled';
|
import {isLabeled} from '../functions/is-labeled';
|
||||||
import {isPullRequest} from '../functions/is-pull-request';
|
import {isPullRequest} from '../functions/is-pull-request';
|
||||||
import {IIssue} from '../interfaces/issue';
|
import {IIssue} from '../interfaces/issue';
|
||||||
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
|
import {ILabel} from '../interfaces/label';
|
||||||
import {IMilestone} from '../interfaces/milestone';
|
import {IMilestone} from '../interfaces/milestone';
|
||||||
import {IssueProcessorOptions, Label} from '../IssueProcessor';
|
|
||||||
import {IsoDateString} from '../types/iso-date-string';
|
import {IsoDateString} from '../types/iso-date-string';
|
||||||
|
|
||||||
export class Issue implements IIssue {
|
export class Issue implements IIssue {
|
||||||
private readonly _options: IssueProcessorOptions;
|
private readonly _options: IIssuesProcessorOptions;
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
readonly number: number;
|
readonly number: number;
|
||||||
created_at: IsoDateString;
|
created_at: IsoDateString;
|
||||||
updated_at: IsoDateString;
|
updated_at: IsoDateString;
|
||||||
readonly labels: Label[];
|
readonly labels: ILabel[];
|
||||||
readonly pull_request: Object | null | undefined;
|
readonly pull_request: Object | null | undefined;
|
||||||
readonly state: string;
|
readonly state: string;
|
||||||
readonly locked: boolean;
|
readonly locked: boolean;
|
||||||
|
@ -21,7 +22,7 @@ export class Issue implements IIssue {
|
||||||
isStale: boolean;
|
isStale: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: Readonly<IssueProcessorOptions>,
|
options: Readonly<IIssuesProcessorOptions>,
|
||||||
issue: Readonly<IIssue>
|
issue: Readonly<IIssue>
|
||||||
) {
|
) {
|
||||||
this._options = options;
|
this._options = options;
|
||||||
|
|
|
@ -1,84 +1,29 @@
|
||||||
import {context, getOctokit} from '@actions/github';
|
import {context, getOctokit} from '@actions/github';
|
||||||
import {GitHub} from '@actions/github/lib/utils';
|
import {GitHub} from '@actions/github/lib/utils';
|
||||||
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
|
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
|
||||||
import {Issue} from './classes/issue';
|
import {IssueType} from '../enums/issue-type';
|
||||||
import {IssueLogger} from './classes/loggers/issue-logger';
|
import {getHumanizedDate} from '../functions/dates/get-humanized-date';
|
||||||
import {Logger} from './classes/loggers/logger';
|
import {isDateMoreRecentThan} from '../functions/dates/is-date-more-recent-than';
|
||||||
import {Milestones} from './classes/milestones';
|
import {isValidDate} from '../functions/dates/is-valid-date';
|
||||||
import {IssueType} from './enums/issue-type';
|
import {getIssueType} from '../functions/get-issue-type';
|
||||||
import {getHumanizedDate} from './functions/dates/get-humanized-date';
|
import {isLabeled} from '../functions/is-labeled';
|
||||||
import {isDateMoreRecentThan} from './functions/dates/is-date-more-recent-than';
|
import {isPullRequest} from '../functions/is-pull-request';
|
||||||
import {isValidDate} from './functions/dates/is-valid-date';
|
import {shouldMarkWhenStale} from '../functions/should-mark-when-stale';
|
||||||
import {getIssueType} from './functions/get-issue-type';
|
import {wordsToList} from '../functions/words-to-list';
|
||||||
import {isLabeled} from './functions/is-labeled';
|
import {IComment} from '../interfaces/comment';
|
||||||
import {isPullRequest} from './functions/is-pull-request';
|
import {IIssue} from '../interfaces/issue';
|
||||||
import {shouldMarkWhenStale} from './functions/should-mark-when-stale';
|
import {IIssueEvent} from '../interfaces/issue-event';
|
||||||
import {IsoOrRfcDateString} from './types/iso-or-rfc-date-string';
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
import {wordsToList} from './functions/words-to-list';
|
import {IPullRequest} from '../interfaces/pull-request';
|
||||||
import {IIssue} from './interfaces/issue';
|
import {Issue} from './issue';
|
||||||
|
import {IssueLogger} from './loggers/issue-logger';
|
||||||
export interface PullRequest {
|
import {Logger} from './loggers/logger';
|
||||||
number: number;
|
import {Milestones} from './milestones';
|
||||||
head: {
|
|
||||||
ref: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface User {
|
|
||||||
type: string;
|
|
||||||
login: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Comment {
|
|
||||||
user: User;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IssueEvent {
|
|
||||||
created_at: string;
|
|
||||||
event: string;
|
|
||||||
label: Label;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Label {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IssueProcessorOptions {
|
|
||||||
repoToken: string;
|
|
||||||
staleIssueMessage: string;
|
|
||||||
stalePrMessage: string;
|
|
||||||
closeIssueMessage: string;
|
|
||||||
closePrMessage: string;
|
|
||||||
daysBeforeStale: number;
|
|
||||||
daysBeforeIssueStale: number; // Could be NaN
|
|
||||||
daysBeforePrStale: number; // Could be NaN
|
|
||||||
daysBeforeClose: number;
|
|
||||||
daysBeforeIssueClose: number; // Could be NaN
|
|
||||||
daysBeforePrClose: number; // Could be NaN
|
|
||||||
staleIssueLabel: string;
|
|
||||||
closeIssueLabel: string;
|
|
||||||
exemptIssueLabels: string;
|
|
||||||
stalePrLabel: string;
|
|
||||||
closePrLabel: string;
|
|
||||||
exemptPrLabels: string;
|
|
||||||
onlyLabels: string;
|
|
||||||
operationsPerRun: number;
|
|
||||||
removeStaleWhenUpdated: boolean;
|
|
||||||
debugOnly: boolean;
|
|
||||||
ascending: boolean;
|
|
||||||
skipStaleIssueMessage: boolean;
|
|
||||||
skipStalePrMessage: boolean;
|
|
||||||
deleteBranch: boolean;
|
|
||||||
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
|
|
||||||
exemptMilestones: string;
|
|
||||||
exemptIssueMilestones: string;
|
|
||||||
exemptPrMilestones: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Handle processing of issues for staleness/closure.
|
* Handle processing of issues for staleness/closure.
|
||||||
*/
|
*/
|
||||||
export class IssueProcessor {
|
export class IssuesProcessor {
|
||||||
private static _updatedSince(timestamp: string, num_days: number): boolean {
|
private static _updatedSince(timestamp: string, num_days: number): boolean {
|
||||||
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
||||||
const millisSinceLastUpdated =
|
const millisSinceLastUpdated =
|
||||||
|
@ -90,20 +35,20 @@ export class IssueProcessor {
|
||||||
private readonly _logger: Logger = new Logger();
|
private readonly _logger: Logger = new Logger();
|
||||||
private _operationsLeft = 0;
|
private _operationsLeft = 0;
|
||||||
readonly client: InstanceType<typeof GitHub>;
|
readonly client: InstanceType<typeof GitHub>;
|
||||||
readonly options: IssueProcessorOptions;
|
readonly options: IIssuesProcessorOptions;
|
||||||
readonly staleIssues: Issue[] = [];
|
readonly staleIssues: Issue[] = [];
|
||||||
readonly closedIssues: Issue[] = [];
|
readonly closedIssues: Issue[] = [];
|
||||||
readonly deletedBranchIssues: Issue[] = [];
|
readonly deletedBranchIssues: Issue[] = [];
|
||||||
readonly removedLabelIssues: Issue[] = [];
|
readonly removedLabelIssues: Issue[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: IssueProcessorOptions,
|
options: IIssuesProcessorOptions,
|
||||||
getActor?: () => Promise<string>,
|
getActor?: () => Promise<string>,
|
||||||
getIssues?: (page: number) => Promise<Issue[]>,
|
getIssues?: (page: number) => Promise<Issue[]>,
|
||||||
listIssueComments?: (
|
listIssueComments?: (
|
||||||
issueNumber: number,
|
issueNumber: number,
|
||||||
sinceDate: string
|
sinceDate: string
|
||||||
) => Promise<Comment[]>,
|
) => Promise<IComment[]>,
|
||||||
getLabelCreationDate?: (
|
getLabelCreationDate?: (
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
label: string
|
label: string
|
||||||
|
@ -271,7 +216,7 @@ export class IssueProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// should this issue be marked stale?
|
// should this issue be marked stale?
|
||||||
const shouldBeStale = !IssueProcessor._updatedSince(
|
const shouldBeStale = !IssuesProcessor._updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
daysBeforeStale
|
daysBeforeStale
|
||||||
);
|
);
|
||||||
|
@ -350,7 +295,7 @@ export class IssueProcessor {
|
||||||
issueLogger.info(`Days before issue close: ${daysBeforeClose}`);
|
issueLogger.info(`Days before issue close: ${daysBeforeClose}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const issueHasUpdate: boolean = IssueProcessor._updatedSince(
|
const issueHasUpdate: boolean = IssuesProcessor._updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
daysBeforeClose
|
daysBeforeClose
|
||||||
);
|
);
|
||||||
|
@ -423,7 +368,7 @@ export class IssueProcessor {
|
||||||
private async _listIssueComments(
|
private async _listIssueComments(
|
||||||
issueNumber: number,
|
issueNumber: number,
|
||||||
sinceDate: string
|
sinceDate: string
|
||||||
): Promise<Comment[]> {
|
): Promise<IComment[]> {
|
||||||
// find any comments since date on the given issue
|
// find any comments since date on the given issue
|
||||||
try {
|
try {
|
||||||
const comments = await this.client.issues.listComments({
|
const comments = await this.client.issues.listComments({
|
||||||
|
@ -586,7 +531,7 @@ export class IssueProcessor {
|
||||||
|
|
||||||
private async _getPullRequest(
|
private async _getPullRequest(
|
||||||
issue: Issue
|
issue: Issue
|
||||||
): Promise<PullRequest | undefined> {
|
): Promise<IPullRequest | undefined> {
|
||||||
const issueLogger: IssueLogger = new IssueLogger(issue);
|
const issueLogger: IssueLogger = new IssueLogger(issue);
|
||||||
this._operationsLeft -= 1;
|
this._operationsLeft -= 1;
|
||||||
|
|
||||||
|
@ -692,7 +637,7 @@ export class IssueProcessor {
|
||||||
issue_number: issue.number
|
issue_number: issue.number
|
||||||
});
|
});
|
||||||
|
|
||||||
const events: IssueEvent[] = await this.client.paginate(options);
|
const events: IIssueEvent[] = await this.client.paginate(options);
|
||||||
const reversedEvents = events.reverse();
|
const reversedEvents = events.reverse();
|
||||||
|
|
||||||
const staleLabeledEvent = reversedEvents.find(
|
const staleLabeledEvent = reversedEvents.find(
|
|
@ -1,11 +1,11 @@
|
||||||
import {IIssue} from '../interfaces/issue';
|
import {IIssue} from '../interfaces/issue';
|
||||||
import {IssueProcessorOptions} from '../IssueProcessor';
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
import {Issue} from './issue';
|
import {Issue} from './issue';
|
||||||
import {Milestones} from './milestones';
|
import {Milestones} from './milestones';
|
||||||
|
|
||||||
describe('Milestones', (): void => {
|
describe('Milestones', (): void => {
|
||||||
let milestones: Milestones;
|
let milestones: Milestones;
|
||||||
let optionsInterface: IssueProcessorOptions;
|
let optionsInterface: IIssuesProcessorOptions;
|
||||||
let issue: Issue;
|
let issue: Issue;
|
||||||
let issueInterface: IIssue;
|
let issueInterface: IIssue;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import deburr from 'lodash.deburr';
|
import deburr from 'lodash.deburr';
|
||||||
import {wordsToList} from '../functions/words-to-list';
|
import {wordsToList} from '../functions/words-to-list';
|
||||||
import {IssueProcessorOptions} from '../IssueProcessor';
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
import {Issue} from './issue';
|
import {Issue} from './issue';
|
||||||
|
|
||||||
type CleanMilestone = string;
|
type CleanMilestone = string;
|
||||||
|
@ -10,10 +10,10 @@ export class Milestones {
|
||||||
return deburr(label.toLowerCase());
|
return deburr(label.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly _options: IssueProcessorOptions;
|
private readonly _options: IIssuesProcessorOptions;
|
||||||
private readonly _issue: Issue;
|
private readonly _issue: Issue;
|
||||||
|
|
||||||
constructor(options: Readonly<IssueProcessorOptions>, issue: Issue) {
|
constructor(options: Readonly<IIssuesProcessorOptions>, issue: Issue) {
|
||||||
this._options = options;
|
this._options = options;
|
||||||
this._issue = issue;
|
this._issue = issue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import deburr from 'lodash.deburr';
|
import deburr from 'lodash.deburr';
|
||||||
import {Issue} from '../classes/issue';
|
import {Issue} from '../classes/issue';
|
||||||
import {Label} from '../IssueProcessor';
|
import {ILabel} from '../interfaces/label';
|
||||||
import {CleanLabel} from '../types/clean-label';
|
import {CleanLabel} from '../types/clean-label';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ export function isLabeled(
|
||||||
issue: Readonly<Issue>,
|
issue: Readonly<Issue>,
|
||||||
label: Readonly<string>
|
label: Readonly<string>
|
||||||
): boolean {
|
): boolean {
|
||||||
return !!issue.labels.find((issueLabel: Readonly<Label>): boolean => {
|
return !!issue.labels.find((issueLabel: Readonly<ILabel>): boolean => {
|
||||||
return cleanLabel(label) === cleanLabel(issueLabel.name);
|
return cleanLabel(label) === cleanLabel(issueLabel.name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import {IUser} from './user';
|
||||||
|
|
||||||
|
export interface IComment {
|
||||||
|
user: IUser;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
import {ILabel} from './label';
|
||||||
|
|
||||||
|
export interface IIssueEvent {
|
||||||
|
created_at: string;
|
||||||
|
event: string;
|
||||||
|
label: ILabel;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import {Label} from '../IssueProcessor';
|
|
||||||
import {IsoDateString} from '../types/iso-date-string';
|
import {IsoDateString} from '../types/iso-date-string';
|
||||||
|
import {ILabel} from './label';
|
||||||
import {IMilestone} from './milestone';
|
import {IMilestone} from './milestone';
|
||||||
|
|
||||||
export interface IIssue {
|
export interface IIssue {
|
||||||
|
@ -7,7 +7,7 @@ export interface IIssue {
|
||||||
number: number;
|
number: number;
|
||||||
created_at: IsoDateString;
|
created_at: IsoDateString;
|
||||||
updated_at: IsoDateString;
|
updated_at: IsoDateString;
|
||||||
labels: Label[];
|
labels: ILabel[];
|
||||||
pull_request: Object | null | undefined;
|
pull_request: Object | null | undefined;
|
||||||
state: string;
|
state: string;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import {IsoOrRfcDateString} from '../types/iso-or-rfc-date-string';
|
||||||
|
|
||||||
|
export interface IIssuesProcessorOptions {
|
||||||
|
repoToken: string;
|
||||||
|
staleIssueMessage: string;
|
||||||
|
stalePrMessage: string;
|
||||||
|
closeIssueMessage: string;
|
||||||
|
closePrMessage: string;
|
||||||
|
daysBeforeStale: number;
|
||||||
|
daysBeforeIssueStale: number; // Could be NaN
|
||||||
|
daysBeforePrStale: number; // Could be NaN
|
||||||
|
daysBeforeClose: number;
|
||||||
|
daysBeforeIssueClose: number; // Could be NaN
|
||||||
|
daysBeforePrClose: number; // Could be NaN
|
||||||
|
staleIssueLabel: string;
|
||||||
|
closeIssueLabel: string;
|
||||||
|
exemptIssueLabels: string;
|
||||||
|
stalePrLabel: string;
|
||||||
|
closePrLabel: string;
|
||||||
|
exemptPrLabels: string;
|
||||||
|
onlyLabels: string;
|
||||||
|
operationsPerRun: number;
|
||||||
|
removeStaleWhenUpdated: boolean;
|
||||||
|
debugOnly: boolean;
|
||||||
|
ascending: boolean;
|
||||||
|
skipStaleIssueMessage: boolean;
|
||||||
|
skipStalePrMessage: boolean;
|
||||||
|
deleteBranch: boolean;
|
||||||
|
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
|
||||||
|
exemptMilestones: string;
|
||||||
|
exemptIssueMilestones: string;
|
||||||
|
exemptPrMilestones: string;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
export interface ILabel {
|
||||||
|
name: string;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
export interface IPullRequest {
|
||||||
|
number: number;
|
||||||
|
head: {
|
||||||
|
ref: string;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export interface IUser {
|
||||||
|
type: string;
|
||||||
|
login: string;
|
||||||
|
}
|
|
@ -1,12 +1,13 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {isValidDate} from './functions/dates/is-valid-date';
|
import {isValidDate} from './functions/dates/is-valid-date';
|
||||||
import {IssueProcessor, IssueProcessorOptions} from './IssueProcessor';
|
import {IssuesProcessor} from './classes/issues-processor';
|
||||||
|
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const args = getAndValidateArgs();
|
const args = getAndValidateArgs();
|
||||||
|
|
||||||
const processor: IssueProcessor = new IssueProcessor(args);
|
const processor: IssuesProcessor = new IssuesProcessor(args);
|
||||||
await processor.processIssues();
|
await processor.processIssues();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
|
@ -14,8 +15,8 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAndValidateArgs(): IssueProcessorOptions {
|
function getAndValidateArgs(): IIssuesProcessorOptions {
|
||||||
const args: IssueProcessorOptions = {
|
const args: IIssuesProcessorOptions = {
|
||||||
repoToken: core.getInput('repo-token'),
|
repoToken: core.getInput('repo-token'),
|
||||||
staleIssueMessage: core.getInput('stale-issue-message'),
|
staleIssueMessage: core.getInput('stale-issue-message'),
|
||||||
stalePrMessage: core.getInput('stale-pr-message'),
|
stalePrMessage: core.getInput('stale-pr-message'),
|
||||||
|
|
Loading…
Reference in New Issue