Add debugging, update tests and fix logic.
This commit is contained in:
parent
5a67f409c9
commit
51cc4676ff
|
@ -64,7 +64,7 @@ test('empty issue list results in 1 operation', async () => {
|
||||||
|
|
||||||
test('processing an issue with no label will make it stale', async () => {
|
test('processing an issue with no label will make it stale', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z')
|
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||||
];
|
];
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
|
@ -83,7 +83,13 @@ test('processing an issue with no label will make it stale', async () => {
|
||||||
|
|
||||||
test('processing a stale issue will close it', async () => {
|
test('processing a stale issue will close it', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Stale'])
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale issue that should be closed',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
|
@ -102,7 +108,13 @@ test('processing a stale issue will close it', async () => {
|
||||||
|
|
||||||
test('processing a stale PR will close it', async () => {
|
test('processing a stale PR will close it', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(1, 'My first PR', '2020-01-01T17:00:00Z', true, ['Stale'])
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale PR that should be closed',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
|
@ -121,7 +133,14 @@ test('processing a stale PR will close it', async () => {
|
||||||
|
|
||||||
test('closed issues will not be marked stale', async () => {
|
test('closed issues will not be marked stale', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, [], true)
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A closed issue that will not be marked',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
[],
|
||||||
|
true
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
|
@ -141,7 +160,7 @@ test('stale closed issues will not be closed', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
1,
|
1,
|
||||||
'My first issue',
|
'A stale closed issue',
|
||||||
'2020-01-01T17:00:00Z',
|
'2020-01-01T17:00:00Z',
|
||||||
false,
|
false,
|
||||||
['Stale'],
|
['Stale'],
|
||||||
|
@ -165,7 +184,14 @@ test('stale closed issues will not be closed', async () => {
|
||||||
|
|
||||||
test('closed prs will not be marked stale', async () => {
|
test('closed prs will not be marked stale', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(1, 'My first PR', '2020-01-01T17:00:00Z', true, [], true)
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A closed PR that will not be marked',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
[],
|
||||||
|
true
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
|
@ -186,7 +212,7 @@ test('stale closed prs will not be closed', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
1,
|
1,
|
||||||
'My first PR',
|
'A stale closed PR that will not be closed again',
|
||||||
'2020-01-01T17:00:00Z',
|
'2020-01-01T17:00:00Z',
|
||||||
true,
|
true,
|
||||||
['Stale'],
|
['Stale'],
|
||||||
|
@ -212,7 +238,7 @@ test('locked issues will not be marked stale', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
1,
|
1,
|
||||||
'My first issue',
|
'A locked issue that will not be stale',
|
||||||
'2020-01-01T17:00:00Z',
|
'2020-01-01T17:00:00Z',
|
||||||
false,
|
false,
|
||||||
[],
|
[],
|
||||||
|
@ -236,7 +262,7 @@ test('stale locked issues will not be closed', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
1,
|
1,
|
||||||
'My first issue',
|
'A stale locked issue that will not be closed',
|
||||||
'2020-01-01T17:00:00Z',
|
'2020-01-01T17:00:00Z',
|
||||||
false,
|
false,
|
||||||
['Stale'],
|
['Stale'],
|
||||||
|
@ -263,7 +289,7 @@ test('locked prs will not be marked stale', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
1,
|
1,
|
||||||
'My first PR',
|
'A locked PR that will not be marked stale',
|
||||||
'2020-01-01T17:00:00Z',
|
'2020-01-01T17:00:00Z',
|
||||||
true,
|
true,
|
||||||
[],
|
[],
|
||||||
|
@ -287,7 +313,7 @@ test('stale locked prs will not be closed', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
1,
|
1,
|
||||||
'My first PR',
|
'A stale locked PR that will not be closed',
|
||||||
'2020-01-01T17:00:00Z',
|
'2020-01-01T17:00:00Z',
|
||||||
true,
|
true,
|
||||||
['Stale'],
|
['Stale'],
|
||||||
|
|
|
@ -8513,7 +8513,7 @@ class IssueProcessor {
|
||||||
core.debug(`Found a stale ${issueType}`);
|
core.debug(`Found a stale ${issueType}`);
|
||||||
yield this.processStaleIssue(issue, issueType, staleLabel);
|
yield this.processStaleIssue(issue, issueType, staleLabel);
|
||||||
}
|
}
|
||||||
else if (IssueProcessor.updatedSince(issue.updated_at, this.options.daysBeforeStale)) {
|
else if (!IssueProcessor.updatedSince(issue.updated_at, this.options.daysBeforeStale)) {
|
||||||
core.debug(`Marking ${issueType} stale because it was last updated on ${issue.updated_at}`);
|
core.debug(`Marking ${issueType} stale because it was last updated on ${issue.updated_at}`);
|
||||||
yield this.markStale(issue, staleMessage, staleLabel);
|
yield this.markStale(issue, staleMessage, staleLabel);
|
||||||
this.operationsLeft -= 2;
|
this.operationsLeft -= 2;
|
||||||
|
@ -8669,7 +8669,7 @@ class IssueProcessor {
|
||||||
static updatedSince(timestamp, num_days) {
|
static updatedSince(timestamp, num_days) {
|
||||||
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
||||||
const millisSinceLastUpdated = new Date().getTime() - new Date(timestamp).getTime();
|
const millisSinceLastUpdated = new Date().getTime() - new Date(timestamp).getTime();
|
||||||
return millisSinceLastUpdated >= daysInMillis;
|
return millisSinceLastUpdated < daysInMillis;
|
||||||
}
|
}
|
||||||
static parseCommaSeparatedString(s) {
|
static parseCommaSeparatedString(s) {
|
||||||
// String.prototype.split defaults to [''] when called on an empty string
|
// String.prototype.split defaults to [''] when called on an empty string
|
||||||
|
|
|
@ -153,7 +153,7 @@ export class IssueProcessor {
|
||||||
core.debug(`Found a stale ${issueType}`);
|
core.debug(`Found a stale ${issueType}`);
|
||||||
await this.processStaleIssue(issue, issueType, staleLabel);
|
await this.processStaleIssue(issue, issueType, staleLabel);
|
||||||
} else if (
|
} else if (
|
||||||
IssueProcessor.updatedSince(
|
!IssueProcessor.updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
this.options.daysBeforeStale
|
this.options.daysBeforeStale
|
||||||
)
|
)
|
||||||
|
@ -188,6 +188,7 @@ export class IssueProcessor {
|
||||||
issue,
|
issue,
|
||||||
markedStaleOn
|
markedStaleOn
|
||||||
);
|
);
|
||||||
|
|
||||||
const issueHasUpdate: boolean = IssueProcessor.updatedSince(
|
const issueHasUpdate: boolean = IssueProcessor.updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
this.options.daysBeforeClose
|
this.options.daysBeforeClose
|
||||||
|
@ -376,7 +377,8 @@ export class IssueProcessor {
|
||||||
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
||||||
const millisSinceLastUpdated =
|
const millisSinceLastUpdated =
|
||||||
new Date().getTime() - new Date(timestamp).getTime();
|
new Date().getTime() - new Date(timestamp).getTime();
|
||||||
return millisSinceLastUpdated >= daysInMillis;
|
|
||||||
|
return millisSinceLastUpdated < daysInMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static parseCommaSeparatedString(s: string): string[] {
|
private static parseCommaSeparatedString(s: string): string[] {
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
//"sourceMap": true
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
Loading…
Reference in New Issue