mirror of
https://github.com/actions/stale.git
synced 2025-12-13 21:53:25 +00:00
Add a test for un-staling
This commit is contained in:
@@ -343,11 +343,11 @@ test('exempt issue labels will not be marked stale', async () => {
|
|||||||
])
|
])
|
||||||
];
|
];
|
||||||
|
|
||||||
let opts = DefaultProcessorOptions;
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt';
|
opts.exemptIssueLabels = 'Exempt';
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
DefaultProcessorOptions,
|
opts,
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
async (num, dt) => [],
|
async (num, dt) => [],
|
||||||
async (issue, label) => new Date().toDateString()
|
async (issue, label) => new Date().toDateString()
|
||||||
@@ -365,11 +365,11 @@ test('exempt issue labels will not be marked stale (multi issue label with space
|
|||||||
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool'])
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool'])
|
||||||
];
|
];
|
||||||
|
|
||||||
let opts = DefaultProcessorOptions;
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt, Cool, None';
|
opts.exemptIssueLabels = 'Exempt, Cool, None';
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
DefaultProcessorOptions,
|
opts,
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
async (num, dt) => [],
|
async (num, dt) => [],
|
||||||
async (issue, label) => new Date().toDateString()
|
async (issue, label) => new Date().toDateString()
|
||||||
@@ -387,11 +387,11 @@ test('exempt issue labels will not be marked stale (multi issue label)', async (
|
|||||||
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool'])
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool'])
|
||||||
];
|
];
|
||||||
|
|
||||||
let opts = DefaultProcessorOptions;
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt,Cool,None';
|
opts.exemptIssueLabels = 'Exempt,Cool,None';
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
DefaultProcessorOptions,
|
opts,
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
async (num, dt) => [],
|
async (num, dt) => [],
|
||||||
async (issue, label) => new Date().toDateString()
|
async (issue, label) => new Date().toDateString()
|
||||||
@@ -411,11 +411,11 @@ test('exempt pr labels will not be marked stale', async () => {
|
|||||||
generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false)
|
generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false)
|
||||||
];
|
];
|
||||||
|
|
||||||
let opts = DefaultProcessorOptions;
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Cool';
|
opts.exemptIssueLabels = 'Cool';
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
DefaultProcessorOptions,
|
opts,
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
async (num, dt) => [],
|
async (num, dt) => [],
|
||||||
async (issue, label) => new Date().toDateString()
|
async (issue, label) => new Date().toDateString()
|
||||||
@@ -436,11 +436,11 @@ test('stale issues should not be closed if days is set to -1', async () => {
|
|||||||
generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false, ['Stale'])
|
generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false, ['Stale'])
|
||||||
];
|
];
|
||||||
|
|
||||||
let opts = DefaultProcessorOptions;
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeClose = -1;
|
opts.daysBeforeClose = -1;
|
||||||
|
|
||||||
const processor = new IssueProcessor(
|
const processor = new IssueProcessor(
|
||||||
DefaultProcessorOptions,
|
opts,
|
||||||
async p => (p == 1 ? TestIssueList : []),
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
async (num, dt) => [],
|
async (num, dt) => [],
|
||||||
async (issue, label) => new Date().toDateString()
|
async (issue, label) => new Date().toDateString()
|
||||||
@@ -451,3 +451,32 @@ test('stale issues should not be closed if days is set to -1', async () => {
|
|||||||
|
|
||||||
expect(processor.closedIssues.length).toEqual(0);
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('stale label should be removed if a comment was added to a stale issue', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'An issue that should un-stale',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = DefaultProcessorOptions;
|
||||||
|
opts.removeStaleWhenUpdated = true;
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [{user: {type: 'User'}}], // return a fake comment so indicate there was an update
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.removedLabelIssues.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
@@ -8452,6 +8452,7 @@ class IssueProcessor {
|
|||||||
this.operationsLeft = 0;
|
this.operationsLeft = 0;
|
||||||
this.staleIssues = [];
|
this.staleIssues = [];
|
||||||
this.closedIssues = [];
|
this.closedIssues = [];
|
||||||
|
this.removedLabelIssues = [];
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.operationsLeft = options.operationsPerRun;
|
this.operationsLeft = options.operationsPerRun;
|
||||||
this.client = new github.GitHub(options.repoToken);
|
this.client = new github.GitHub(options.repoToken);
|
||||||
@@ -8632,6 +8633,7 @@ class IssueProcessor {
|
|||||||
removeLabel(issue, label) {
|
removeLabel(issue, label) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.debug(`Removing label ${label} from issue #${issue.number} - ${issue.title}`);
|
core.debug(`Removing label ${label} from issue #${issue.number} - ${issue.title}`);
|
||||||
|
this.removedLabelIssues.push(issue);
|
||||||
this.operationsLeft -= 1;
|
this.operationsLeft -= 1;
|
||||||
if (this.options.debugOnly) {
|
if (this.options.debugOnly) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export class IssueProcessor {
|
|||||||
|
|
||||||
readonly staleIssues: Issue[] = [];
|
readonly staleIssues: Issue[] = [];
|
||||||
readonly closedIssues: Issue[] = [];
|
readonly closedIssues: Issue[] = [];
|
||||||
|
readonly removedLabelIssues: Issue[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: IssueProcessorOptions,
|
options: IssueProcessorOptions,
|
||||||
@@ -326,6 +327,8 @@ export class IssueProcessor {
|
|||||||
`Removing label ${label} from issue #${issue.number} - ${issue.title}`
|
`Removing label ${label} from issue #${issue.number} - ${issue.title}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.removedLabelIssues.push(issue);
|
||||||
|
|
||||||
this.operationsLeft -= 1;
|
this.operationsLeft -= 1;
|
||||||
|
|
||||||
if (this.options.debugOnly) {
|
if (this.options.debugOnly) {
|
||||||
|
|||||||
Reference in New Issue
Block a user