Add rotten functionality
Add processRottenIssue Add Options to support rotten issues Update main.ts to process rotten related inputs Update the Option enum to include rotten related variables Update issue.ts to include function to get the rotten label Add helper functions for rotten related options
This commit is contained in:
parent
3f3b0175e8
commit
9e2995bba5
|
@ -6,18 +6,25 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
|||
repoToken: 'none',
|
||||
staleIssueMessage: 'This issue is stale',
|
||||
stalePrMessage: 'This PR is stale',
|
||||
rottenIssueMessage: 'This issue is rotten',
|
||||
rottenPrMessage: 'This PR is rotten',
|
||||
closeIssueMessage: 'This issue is being closed',
|
||||
closePrMessage: 'This PR is being closed',
|
||||
daysBeforeStale: 1,
|
||||
daysBeforeRotten: 0,
|
||||
daysBeforeIssueStale: NaN,
|
||||
daysBeforePrStale: NaN,
|
||||
daysBeforeIssueRotten: NaN,
|
||||
daysBeforePrRotten: NaN,
|
||||
daysBeforeClose: 30,
|
||||
daysBeforeIssueClose: NaN,
|
||||
daysBeforePrClose: NaN,
|
||||
staleIssueLabel: 'Stale',
|
||||
rottenIssueLabel: 'Rotten',
|
||||
closeIssueLabel: '',
|
||||
exemptIssueLabels: '',
|
||||
stalePrLabel: 'Stale',
|
||||
rottenPrLabel: 'Rotten',
|
||||
closePrLabel: '',
|
||||
exemptPrLabels: '',
|
||||
onlyLabels: '',
|
||||
|
@ -31,6 +38,9 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
|||
removeStaleWhenUpdated: false,
|
||||
removeIssueStaleWhenUpdated: undefined,
|
||||
removePrStaleWhenUpdated: undefined,
|
||||
removeRottenWhenUpdated: false,
|
||||
removeIssueRottenWhenUpdated: undefined,
|
||||
removePrRottenWhenUpdated: undefined,
|
||||
ascending: false,
|
||||
deleteBranch: false,
|
||||
startDate: '',
|
||||
|
@ -50,6 +60,9 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
|||
labelsToRemoveWhenStale: '',
|
||||
labelsToRemoveWhenUnstale: '',
|
||||
labelsToAddWhenUnstale: '',
|
||||
labelsToRemoveWhenRotten: '',
|
||||
labelsToRemoveWhenUnrotten: '',
|
||||
labelsToAddWhenUnrotten: '',
|
||||
ignoreUpdates: false,
|
||||
ignoreIssueUpdates: undefined,
|
||||
ignorePrUpdates: undefined,
|
||||
|
|
|
@ -159,11 +159,12 @@ 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 () => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
const january2000 = '2000-01-01T00:00:00Z';
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: 0,
|
||||
daysBeforeRotten: 0,
|
||||
startDate: january2000.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
|
@ -187,6 +188,7 @@ test('processing an issue with no label and a start date as ISO 8601 being befor
|
|||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues.length).toStrictEqual(1);
|
||||
expect(processor.rottenIssues.length).toStrictEqual(1);
|
||||
expect(processor.closedIssues.length).toStrictEqual(1);
|
||||
});
|
||||
|
||||
|
@ -222,6 +224,39 @@ test('processing an issue with no label and a start date as ISO 8601 being after
|
|||
expect(processor.closedIssues.length).toStrictEqual(0);
|
||||
});
|
||||
|
||||
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 , rotten or close it when it is old enough and days-before-close is set to 0', async () => {
|
||||
expect.assertions(3);
|
||||
const january2021 = '2021-01-01T00:00:00Z';
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2021.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'An issue with no label',
|
||||
'2020-01-01T17:00:00Z',
|
||||
'2020-01-01T17:00:00Z'
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
alwaysFalseStateMock,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues.length).toStrictEqual(0);
|
||||
expect(processor.rottenIssues.length).toStrictEqual(0);
|
||||
expect(processor.closedIssues.length).toStrictEqual(0);
|
||||
});
|
||||
|
||||
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);
|
||||
const january2000 = 'January 1, 2000 00:00:00';
|
||||
|
@ -290,6 +325,7 @@ test('processing an issue with no label will make it stale and close it, if it i
|
|||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: 1,
|
||||
daysBeforeRotten: 0,
|
||||
daysBeforeIssueClose: 0
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
|
@ -307,6 +343,7 @@ test('processing an issue with no label will make it stale and close it, if it i
|
|||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
expect(processor.rottenIssues).toHaveLength(1);
|
||||
expect(processor.closedIssues).toHaveLength(1);
|
||||
expect(processor.deletedBranchIssues).toHaveLength(0);
|
||||
});
|
||||
|
@ -488,6 +525,7 @@ test('processing a stale issue will close it', async () => {
|
|||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues).toHaveLength(0);
|
||||
expect(processor.rottenIssues).toHaveLength(1);
|
||||
expect(processor.closedIssues).toHaveLength(1);
|
||||
});
|
||||
|
||||
|
|
56
action.yml
56
action.yml
|
@ -1,6 +1,6 @@
|
|||
name: 'Close Stale Issues'
|
||||
name: 'Close, Rotten and Stale Issues'
|
||||
description: 'Close issues and pull requests with no recent activity'
|
||||
author: 'GitHub'
|
||||
author: 'M Viswanath Sai'
|
||||
inputs:
|
||||
repo-token:
|
||||
description: 'Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`.'
|
||||
|
@ -12,6 +12,12 @@ inputs:
|
|||
stale-pr-message:
|
||||
description: 'The message to post on the pull request when tagging it. If none provided, will not mark pull requests stale.'
|
||||
required: false
|
||||
rotten-issue-message:
|
||||
description: 'The message to post on the issue when tagging it. If none provided, will not mark issues rotten.'
|
||||
required: false
|
||||
rotten-pr-message:
|
||||
description: 'The message to post on the pull request when tagging it. If none provided, will not mark pull requests rotten.'
|
||||
required: false
|
||||
close-issue-message:
|
||||
description: 'The message to post on the issue when closing it. If none provided, will not comment when closing an issue.'
|
||||
required: false
|
||||
|
@ -21,17 +27,27 @@ inputs:
|
|||
days-before-stale:
|
||||
description: 'The number of days old an issue or a pull request can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
|
||||
required: false
|
||||
default: '60'
|
||||
default: '90'
|
||||
days-before-issue-stale:
|
||||
description: 'The number of days old an issue can be before marking it stale. Set to -1 to never mark issues as stale automatically. Override "days-before-stale" option regarding only the issues.'
|
||||
required: false
|
||||
days-before-pr-stale:
|
||||
description: 'The number of days old a pull request can be before marking it stale. Set to -1 to never mark pull requests as stale automatically. Override "days-before-stale" option regarding only the pull requests.'
|
||||
required: false
|
||||
days-before-rotten:
|
||||
description: 'The number of days old an issue or a pull request can be before marking it rotten. Set to -1 to never mark issues or pull requests as rotten automatically.'
|
||||
required: false
|
||||
default: '30'
|
||||
days-before-issue-rotten:
|
||||
description: 'The number of days old an issue can be before marking it rotten. Set to -1 to never mark issues as rotten automatically. Override "days-before-rotten" option regarding only the issues.'
|
||||
required: false
|
||||
days-before-pr-rotten:
|
||||
description: 'The number of days old a pull request can be before marking it rotten. Set to -1 to never mark pull requests as rotten automatically. Override "days-before-rotten" option regarding only the pull requests.'
|
||||
required: false
|
||||
days-before-close:
|
||||
description: 'The number of days to wait to close an issue or a pull request after it being marked stale. Set to -1 to never close stale issues or pull requests.'
|
||||
required: false
|
||||
default: '7'
|
||||
default: '30'
|
||||
days-before-issue-close:
|
||||
description: 'The number of days to wait to close an issue after it being marked stale. Set to -1 to never close stale issues. Override "days-before-close" option regarding only the issues.'
|
||||
required: false
|
||||
|
@ -42,6 +58,10 @@ inputs:
|
|||
description: 'The label to apply when an issue is stale.'
|
||||
required: false
|
||||
default: 'Stale'
|
||||
rotten-issue-label:
|
||||
description: 'The label to apply when an issue is rotten.'
|
||||
required: false
|
||||
default: 'Rotten'
|
||||
close-issue-label:
|
||||
description: 'The label to apply when an issue is closed.'
|
||||
required: false
|
||||
|
@ -57,6 +77,10 @@ inputs:
|
|||
description: 'The label to apply when a pull request is stale.'
|
||||
default: 'Stale'
|
||||
required: false
|
||||
rotten-pr-label:
|
||||
description: 'The label to apply when a pull request is rotten.'
|
||||
default: 'Rotten'
|
||||
required: false
|
||||
close-pr-label:
|
||||
description: 'The label to apply when a pull request is closed.'
|
||||
required: false
|
||||
|
@ -128,6 +152,18 @@ inputs:
|
|||
description: 'Remove stale labels from pull requests when they are updated or commented on. Override "remove-stale-when-updated" option regarding only the pull requests.'
|
||||
default: ''
|
||||
required: false
|
||||
remove-rotten-when-updated:
|
||||
description: 'Remove rotten labels from issues and pull requests when they are updated or commented on.'
|
||||
default: 'true'
|
||||
required: false
|
||||
remove-issue-rotten-when-updated:
|
||||
description: 'Remove rotten labels from issues when they are updated or commented on. Override "remove-rotten-when-updated" option regarding only the issues.'
|
||||
default: ''
|
||||
required: false
|
||||
remove-pr-rotten-when-updated:
|
||||
description: 'Remove rotten labels from pull requests when they are updated or commented on. Override "remove-rotten-when-updated" option regarding only the pull requests.'
|
||||
default: ''
|
||||
required: false
|
||||
debug-only:
|
||||
description: 'Run the processor in debug mode without actually performing any operations on live issues.'
|
||||
default: 'false'
|
||||
|
@ -188,6 +224,18 @@ inputs:
|
|||
description: 'A comma delimited list of labels to remove when an issue or pull request becomes unstale.'
|
||||
default: ''
|
||||
required: false
|
||||
labels-to-add-when-unrotten:
|
||||
description: 'A comma delimited list of labels to add when an issue or pull request becomes unrotten.'
|
||||
default: ''
|
||||
required: false
|
||||
labels-to-remove-when-rotten:
|
||||
description: 'A comma delimited list of labels to remove when an issue or pull request becomes rotten.'
|
||||
default: ''
|
||||
required: false
|
||||
labels-to-remove-when-unrotten:
|
||||
description: 'A comma delimited list of labels to remove when an issue or pull request becomes unrotten.'
|
||||
default: ''
|
||||
required: false
|
||||
ignore-updates:
|
||||
description: 'Any update (update/comment) can reset the stale idle time on the issues and pull requests.'
|
||||
default: 'false'
|
||||
|
|
|
@ -1,76 +1,88 @@
|
|||
import {isLabeled} from '../functions/is-labeled';
|
||||
import {isPullRequest} from '../functions/is-pull-request';
|
||||
import {Assignee} from '../interfaces/assignee';
|
||||
import {IIssue, OctokitIssue} from '../interfaces/issue';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {ILabel} from '../interfaces/label';
|
||||
import {IMilestone} from '../interfaces/milestone';
|
||||
import {IsoDateString} from '../types/iso-date-string';
|
||||
import {Operations} from './operations';
|
||||
import { isLabeled } from '../functions/is-labeled';
|
||||
import { isPullRequest } from '../functions/is-pull-request';
|
||||
import { Assignee } from '../interfaces/assignee';
|
||||
import { IIssue, OctokitIssue } from '../interfaces/issue';
|
||||
import { IIssuesProcessorOptions } from '../interfaces/issues-processor-options';
|
||||
import { ILabel } from '../interfaces/label';
|
||||
import { IMilestone } from '../interfaces/milestone';
|
||||
import { IsoDateString } from '../types/iso-date-string';
|
||||
import { Operations } from './operations';
|
||||
|
||||
export class Issue implements IIssue {
|
||||
readonly title: string;
|
||||
readonly number: number;
|
||||
created_at: IsoDateString;
|
||||
updated_at: IsoDateString;
|
||||
readonly draft: boolean;
|
||||
readonly labels: ILabel[];
|
||||
readonly pull_request: object | null | undefined;
|
||||
readonly state: string | 'closed' | 'open';
|
||||
readonly locked: boolean;
|
||||
readonly milestone?: IMilestone | null;
|
||||
readonly assignees: Assignee[];
|
||||
isStale: boolean;
|
||||
markedStaleThisRun: boolean;
|
||||
operations = new Operations();
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
readonly title: string;
|
||||
readonly number: number;
|
||||
created_at: IsoDateString;
|
||||
updated_at: IsoDateString;
|
||||
readonly draft: boolean;
|
||||
readonly labels: ILabel[];
|
||||
readonly pull_request: object | null | undefined;
|
||||
readonly state: string | 'closed' | 'open';
|
||||
readonly locked: boolean;
|
||||
readonly milestone?: IMilestone | null;
|
||||
readonly assignees: Assignee[];
|
||||
isStale: boolean;
|
||||
isRotten: boolean;
|
||||
markedStaleThisRun: boolean;
|
||||
markedRottenThisRun: boolean;
|
||||
operations = new Operations();
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
|
||||
constructor(
|
||||
options: Readonly<IIssuesProcessorOptions>,
|
||||
issue: Readonly<OctokitIssue> | Readonly<IIssue>
|
||||
) {
|
||||
this._options = options;
|
||||
this.title = issue.title;
|
||||
this.number = issue.number;
|
||||
this.created_at = issue.created_at;
|
||||
this.updated_at = issue.updated_at;
|
||||
this.draft = Boolean(issue.draft);
|
||||
this.labels = mapLabels(issue.labels);
|
||||
this.pull_request = issue.pull_request;
|
||||
this.state = issue.state;
|
||||
this.locked = issue.locked;
|
||||
this.milestone = issue.milestone;
|
||||
this.assignees = issue.assignees || [];
|
||||
this.isStale = isLabeled(this, this.staleLabel);
|
||||
this.markedStaleThisRun = false;
|
||||
}
|
||||
constructor(
|
||||
options: Readonly<IIssuesProcessorOptions>,
|
||||
issue: Readonly<OctokitIssue> | Readonly<IIssue>
|
||||
) {
|
||||
this._options = options;
|
||||
this.title = issue.title;
|
||||
this.number = issue.number;
|
||||
this.created_at = issue.created_at;
|
||||
this.updated_at = issue.updated_at;
|
||||
this.draft = Boolean(issue.draft);
|
||||
this.labels = mapLabels(issue.labels);
|
||||
this.pull_request = issue.pull_request;
|
||||
this.state = issue.state;
|
||||
this.locked = issue.locked;
|
||||
this.milestone = issue.milestone;
|
||||
this.assignees = issue.assignees || [];
|
||||
this.isStale = isLabeled(this, this.staleLabel);
|
||||
this.isRotten = isLabeled(this, this.rottenLabel);
|
||||
this.markedStaleThisRun = false;
|
||||
this.markedRottenThisRun = false;
|
||||
}
|
||||
|
||||
get isPullRequest(): boolean {
|
||||
return isPullRequest(this);
|
||||
}
|
||||
get isPullRequest(): boolean {
|
||||
return isPullRequest(this);
|
||||
}
|
||||
|
||||
get staleLabel(): string {
|
||||
return this._getStaleLabel();
|
||||
}
|
||||
get staleLabel(): string {
|
||||
return this._getStaleLabel();
|
||||
}
|
||||
get rottenLabel(): string {
|
||||
return this._getRottenLabel();
|
||||
}
|
||||
|
||||
get hasAssignees(): boolean {
|
||||
return this.assignees.length > 0;
|
||||
}
|
||||
get hasAssignees(): boolean {
|
||||
return this.assignees.length > 0;
|
||||
}
|
||||
|
||||
private _getStaleLabel(): string {
|
||||
return this.isPullRequest
|
||||
? this._options.stalePrLabel
|
||||
: this._options.staleIssueLabel;
|
||||
}
|
||||
private _getStaleLabel(): string {
|
||||
return this.isPullRequest
|
||||
? this._options.stalePrLabel
|
||||
: this._options.staleIssueLabel;
|
||||
}
|
||||
private _getRottenLabel(): string {
|
||||
return this.isPullRequest
|
||||
? this._options.rottenPrLabel
|
||||
: this._options.rottenIssueLabel;
|
||||
}
|
||||
}
|
||||
|
||||
function mapLabels(labels: (string | ILabel)[] | ILabel[]): ILabel[] {
|
||||
return labels.map(label => {
|
||||
if (typeof label == 'string') {
|
||||
return {
|
||||
name: label
|
||||
};
|
||||
}
|
||||
return label;
|
||||
});
|
||||
return labels.map(label => {
|
||||
if (typeof label == 'string') {
|
||||
return {
|
||||
name: label
|
||||
};
|
||||
}
|
||||
return label;
|
||||
});
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,6 +15,10 @@ export class Statistics {
|
|||
stalePullRequestsCount = 0;
|
||||
undoStaleIssuesCount = 0;
|
||||
undoStalePullRequestsCount = 0;
|
||||
rottenIssuesCount = 0;
|
||||
rottenPullRequestsCount = 0;
|
||||
undoRottenIssuesCount = 0;
|
||||
undoRottenPullRequestsCount = 0;
|
||||
operationsCount = 0;
|
||||
closedIssuesCount = 0;
|
||||
closedPullRequestsCount = 0;
|
||||
|
@ -65,6 +69,18 @@ export class Statistics {
|
|||
return this._incrementUndoStaleIssuesCount(increment);
|
||||
}
|
||||
|
||||
incrementUndoRottenItemsCount(
|
||||
issue: Readonly<Issue>,
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
if (issue.isPullRequest) {
|
||||
return this._incrementUndoRottenPullRequestsCount(increment);
|
||||
}
|
||||
|
||||
return this._incrementUndoRottenIssuesCount(increment);
|
||||
}
|
||||
|
||||
|
||||
setOperationsCount(operationsCount: Readonly<number>): Statistics {
|
||||
this.operationsCount = operationsCount;
|
||||
|
||||
|
@ -222,6 +238,21 @@ export class Statistics {
|
|||
return this;
|
||||
}
|
||||
|
||||
private _incrementUndoRottenPullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this.undoRottenPullRequestsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
private _incrementUndoRottenIssuesCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this.undoRottenIssuesCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private _incrementUndoStalePullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
|
|
|
@ -2,18 +2,25 @@ export enum Option {
|
|||
RepoToken = 'repo-token',
|
||||
StaleIssueMessage = 'stale-issue-message',
|
||||
StalePrMessage = 'stale-pr-message',
|
||||
RottenIssueMessage = 'rotten-issue-message',
|
||||
RottenPrMessage = 'rotten-pr-message',
|
||||
CloseIssueMessage = 'close-issue-message',
|
||||
ClosePrMessage = 'close-pr-message',
|
||||
DaysBeforeStale = 'days-before-stale',
|
||||
DaysBeforeIssueStale = 'days-before-issue-stale',
|
||||
DaysBeforePrStale = 'days-before-pr-stale',
|
||||
DaysBeforeRotten = 'days-before-rotten',
|
||||
DaysBeforeIssueRotten = 'days-before-issue-rotten',
|
||||
DaysBeforePrRotten = 'days-before-pr-rotten',
|
||||
DaysBeforeClose = 'days-before-close',
|
||||
DaysBeforeIssueClose = 'days-before-issue-close',
|
||||
DaysBeforePrClose = 'days-before-pr-close',
|
||||
StaleIssueLabel = 'stale-issue-label',
|
||||
RottenIssueLabel = 'rotten-issue-label',
|
||||
CloseIssueLabel = 'close-issue-label',
|
||||
ExemptIssueLabels = 'exempt-issue-labels',
|
||||
StalePrLabel = 'stale-pr-label',
|
||||
RottenPrLabel = 'rotten-pr-label',
|
||||
ClosePrLabel = 'close-pr-label',
|
||||
ExemptPrLabels = 'exempt-pr-labels',
|
||||
OnlyLabels = 'only-labels',
|
||||
|
@ -24,6 +31,9 @@ export enum Option {
|
|||
RemoveStaleWhenUpdated = 'remove-stale-when-updated',
|
||||
RemoveIssueStaleWhenUpdated = 'remove-issue-stale-when-updated',
|
||||
RemovePrStaleWhenUpdated = 'remove-pr-stale-when-updated',
|
||||
RemoveRottenWhenUpdated = 'remove-rotten-when-updated',
|
||||
RemoveIssueRottenWhenUpdated = 'remove-issue-rotten-when-updated',
|
||||
RemovePrRottenWhenUpdated = 'remove-pr-rotten-when-updated',
|
||||
DebugOnly = 'debug-only',
|
||||
Ascending = 'ascending',
|
||||
DeleteBranch = 'delete-branch',
|
||||
|
@ -44,6 +54,9 @@ export enum Option {
|
|||
LabelsToRemoveWhenStale = 'labels-to-remove-when-stale',
|
||||
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
|
||||
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
|
||||
LabelsToRemoveWhenRotten = 'labels-to-remove-when-rotten',
|
||||
LabelsToRemoveWhenUnrotten = 'labels-to-remove-when-unstale',
|
||||
LabelsToAddWhenUnrotten = 'labels-to-add-when-unstale',
|
||||
IgnoreUpdates = 'ignore-updates',
|
||||
IgnoreIssueUpdates = 'ignore-issue-updates',
|
||||
IgnorePrUpdates = 'ignore-pr-updates',
|
||||
|
|
|
@ -1,57 +1,70 @@
|
|||
import {IsoOrRfcDateString} from '../types/iso-or-rfc-date-string';
|
||||
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;
|
||||
onlyIssueLabels: string;
|
||||
onlyPrLabels: string;
|
||||
anyOfLabels: string;
|
||||
anyOfIssueLabels: string;
|
||||
anyOfPrLabels: string;
|
||||
operationsPerRun: number;
|
||||
removeStaleWhenUpdated: boolean;
|
||||
removeIssueStaleWhenUpdated: boolean | undefined;
|
||||
removePrStaleWhenUpdated: boolean | undefined;
|
||||
debugOnly: boolean;
|
||||
ascending: boolean;
|
||||
deleteBranch: boolean;
|
||||
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
|
||||
exemptMilestones: string;
|
||||
exemptIssueMilestones: string;
|
||||
exemptPrMilestones: string;
|
||||
exemptAllMilestones: boolean;
|
||||
exemptAllIssueMilestones: boolean | undefined;
|
||||
exemptAllPrMilestones: boolean | undefined;
|
||||
exemptAssignees: string;
|
||||
exemptIssueAssignees: string;
|
||||
exemptPrAssignees: string;
|
||||
exemptAllAssignees: boolean;
|
||||
exemptAllIssueAssignees: boolean | undefined;
|
||||
exemptAllPrAssignees: boolean | undefined;
|
||||
enableStatistics: boolean;
|
||||
labelsToRemoveWhenStale: string;
|
||||
labelsToRemoveWhenUnstale: string;
|
||||
labelsToAddWhenUnstale: string;
|
||||
ignoreUpdates: boolean;
|
||||
ignoreIssueUpdates: boolean | undefined;
|
||||
ignorePrUpdates: boolean | undefined;
|
||||
exemptDraftPr: boolean;
|
||||
closeIssueReason: string;
|
||||
includeOnlyAssigned: boolean;
|
||||
repoToken: string;
|
||||
staleIssueMessage: string;
|
||||
stalePrMessage: string;
|
||||
rottenIssueMessage: string;
|
||||
rottenPrMessage: string;
|
||||
closeIssueMessage: string;
|
||||
closePrMessage: string;
|
||||
daysBeforeStale: number;
|
||||
daysBeforeIssueStale: number; // Could be NaN
|
||||
daysBeforePrStale: number; // Could be NaN
|
||||
daysBeforeRotten: number;
|
||||
daysBeforeIssueRotten: number; // Could be NaN
|
||||
daysBeforePrRotten: number; // Could be NaN
|
||||
daysBeforeClose: number;
|
||||
daysBeforeIssueClose: number; // Could be NaN
|
||||
daysBeforePrClose: number; // Could be NaN
|
||||
staleIssueLabel: string;
|
||||
rottenIssueLabel: string;
|
||||
closeIssueLabel: string;
|
||||
exemptIssueLabels: string;
|
||||
stalePrLabel: string;
|
||||
rottenPrLabel: string;
|
||||
closePrLabel: string;
|
||||
exemptPrLabels: string;
|
||||
onlyLabels: string;
|
||||
onlyIssueLabels: string;
|
||||
onlyPrLabels: string;
|
||||
anyOfLabels: string;
|
||||
anyOfIssueLabels: string;
|
||||
anyOfPrLabels: string;
|
||||
operationsPerRun: number;
|
||||
removeStaleWhenUpdated: boolean;
|
||||
removeIssueStaleWhenUpdated: boolean | undefined;
|
||||
removePrStaleWhenUpdated: boolean | undefined;
|
||||
removeRottenWhenUpdated: boolean;
|
||||
removeIssueRottenWhenUpdated: boolean | undefined;
|
||||
removePrRottenWhenUpdated: boolean | undefined;
|
||||
debugOnly: boolean;
|
||||
ascending: boolean;
|
||||
deleteBranch: boolean;
|
||||
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
|
||||
exemptMilestones: string;
|
||||
exemptIssueMilestones: string;
|
||||
exemptPrMilestones: string;
|
||||
exemptAllMilestones: boolean;
|
||||
exemptAllIssueMilestones: boolean | undefined;
|
||||
exemptAllPrMilestones: boolean | undefined;
|
||||
exemptAssignees: string;
|
||||
exemptIssueAssignees: string;
|
||||
exemptPrAssignees: string;
|
||||
exemptAllAssignees: boolean;
|
||||
exemptAllIssueAssignees: boolean | undefined;
|
||||
exemptAllPrAssignees: boolean | undefined;
|
||||
enableStatistics: boolean;
|
||||
labelsToRemoveWhenStale: string;
|
||||
labelsToRemoveWhenUnstale: string;
|
||||
labelsToAddWhenUnstale: string;
|
||||
labelsToRemoveWhenRotten: string;
|
||||
labelsToRemoveWhenUnrotten: string;
|
||||
labelsToAddWhenUnrotten: string;
|
||||
ignoreUpdates: boolean;
|
||||
ignoreIssueUpdates: boolean | undefined;
|
||||
ignorePrUpdates: boolean | undefined;
|
||||
exemptDraftPr: boolean;
|
||||
closeIssueReason: string;
|
||||
includeOnlyAssigned: boolean;
|
||||
}
|
||||
|
|
31
src/main.ts
31
src/main.ts
|
@ -46,6 +46,7 @@ async function _run(): Promise<void> {
|
|||
|
||||
await processOutput(
|
||||
issueProcessor.staleIssues,
|
||||
issueProcessor.rottenIssues,
|
||||
issueProcessor.closedIssues
|
||||
);
|
||||
} catch (error) {
|
||||
|
@ -59,22 +60,31 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
repoToken: core.getInput('repo-token'),
|
||||
staleIssueMessage: core.getInput('stale-issue-message'),
|
||||
stalePrMessage: core.getInput('stale-pr-message'),
|
||||
rottenIssueMessage: core.getInput('rotten-issue-message'),
|
||||
rottenPrMessage: core.getInput('rotten-pr-message'),
|
||||
closeIssueMessage: core.getInput('close-issue-message'),
|
||||
closePrMessage: core.getInput('close-pr-message'),
|
||||
daysBeforeStale: parseFloat(
|
||||
core.getInput('days-before-stale', {required: true})
|
||||
),
|
||||
daysBeforeRotten: parseFloat(
|
||||
core.getInput('days-before-rotten', {required: true})
|
||||
),
|
||||
daysBeforeIssueStale: parseFloat(core.getInput('days-before-issue-stale')),
|
||||
daysBeforePrStale: parseFloat(core.getInput('days-before-pr-stale')),
|
||||
daysBeforeIssueRotten: parseFloat(core.getInput('days-before-issue-rotten')),
|
||||
daysBeforePrRotten: parseFloat(core.getInput('days-before-pr-rotten')),
|
||||
daysBeforeClose: parseInt(
|
||||
core.getInput('days-before-close', {required: true})
|
||||
),
|
||||
daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close')),
|
||||
daysBeforePrClose: parseInt(core.getInput('days-before-pr-close')),
|
||||
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
|
||||
rottenIssueLabel: core.getInput('rotten-issue-label', {required: true}),
|
||||
closeIssueLabel: core.getInput('close-issue-label'),
|
||||
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
||||
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
|
||||
rottenPrLabel: core.getInput('rotten-pr-label', {required: true}),
|
||||
closePrLabel: core.getInput('close-pr-label'),
|
||||
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
||||
onlyLabels: core.getInput('only-labels'),
|
||||
|
@ -95,6 +105,15 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
removePrStaleWhenUpdated: _toOptionalBoolean(
|
||||
'remove-pr-stale-when-updated'
|
||||
),
|
||||
removeRottenWhenUpdated: !(
|
||||
core.getInput('remove-rotten-when-updated') === 'false'
|
||||
),
|
||||
removeIssueRottenWhenUpdated: _toOptionalBoolean(
|
||||
'remove-issue-rotten-when-updated'
|
||||
),
|
||||
removePrRottenWhenUpdated: _toOptionalBoolean(
|
||||
'remove-pr-rotten-when-updated'
|
||||
),
|
||||
debugOnly: core.getInput('debug-only') === 'true',
|
||||
ascending: core.getInput('ascending') === 'true',
|
||||
deleteBranch: core.getInput('delete-branch') === 'true',
|
||||
|
@ -118,6 +137,9 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
labelsToRemoveWhenStale: core.getInput('labels-to-remove-when-stale'),
|
||||
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
||||
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
||||
labelsToRemoveWhenRotten: core.getInput('labels-to-remove-when-rotten'),
|
||||
labelsToRemoveWhenUnrotten: core.getInput('labels-to-remove-when-unrotten'),
|
||||
labelsToAddWhenUnrotten: core.getInput('labels-to-add-when-unrotten'),
|
||||
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
||||
ignoreIssueUpdates: _toOptionalBoolean('ignore-issue-updates'),
|
||||
ignorePrUpdates: _toOptionalBoolean('ignore-pr-updates'),
|
||||
|
@ -133,6 +155,13 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
for (const numberInput of ['days-before-rotten']) {
|
||||
if (isNaN(parseFloat(core.getInput(numberInput)))) {
|
||||
const errorMessage = `Option "${numberInput}" did not parse to a valid float`;
|
||||
core.setFailed(errorMessage);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
for (const numberInput of ['days-before-close', 'operations-per-run']) {
|
||||
if (isNaN(parseInt(core.getInput(numberInput)))) {
|
||||
|
@ -167,9 +196,11 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
|
||||
async function processOutput(
|
||||
staledIssues: Issue[],
|
||||
rottenIssues: Issue[],
|
||||
closedIssues: Issue[]
|
||||
): Promise<void> {
|
||||
core.setOutput('staled-issues-prs', JSON.stringify(staledIssues));
|
||||
core.setOutput('rotten-issues-prs', JSON.stringify(rottenIssues));
|
||||
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue