mirror of
https://github.com/actions/stale.git
synced 2025-12-29 19:38:18 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d6f46564a | ||
|
|
d21d307fd8 | ||
|
|
7164109781 | ||
|
|
079c368275 |
1
CODEOWNERS
Normal file
1
CODEOWNERS
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @actions/actions-runtime
|
||||||
@@ -2262,3 +2262,186 @@ test('a PR with an exempted milestone and with an exempted issue milestone will
|
|||||||
expect(processor.closedIssues.length).toStrictEqual(0);
|
expect(processor.closedIssues.length).toStrictEqual(0);
|
||||||
expect(processor.removedLabelIssues.length).toStrictEqual(0);
|
expect(processor.removedLabelIssues.length).toStrictEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 3 will not make it stale', async () => {
|
||||||
|
expect.assertions(2);
|
||||||
|
const opts: IssueProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
daysBeforeStale: 10,
|
||||||
|
daysBeforeIssueStale: 3
|
||||||
|
};
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
||||||
|
];
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 2 will make it stale', async () => {
|
||||||
|
expect.assertions(2);
|
||||||
|
const opts: IssueProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
daysBeforeStale: 10,
|
||||||
|
daysBeforeIssueStale: 2
|
||||||
|
};
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
||||||
|
];
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 1 will make it stale', async () => {
|
||||||
|
expect.assertions(2);
|
||||||
|
const opts: IssueProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
daysBeforeStale: 10,
|
||||||
|
daysBeforeIssueStale: 1
|
||||||
|
};
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
||||||
|
];
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
const opts: IssueProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
daysBeforeStale: 10,
|
||||||
|
daysBeforePrStale: 3
|
||||||
|
};
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
opts,
|
||||||
|
1,
|
||||||
|
'A pull request with no label',
|
||||||
|
issueDate.toDateString(),
|
||||||
|
issueDate.toDateString(),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 2 will make it stale', async () => {
|
||||||
|
expect.assertions(2);
|
||||||
|
const opts: IssueProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
daysBeforeStale: 10,
|
||||||
|
daysBeforePrStale: 2
|
||||||
|
};
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
opts,
|
||||||
|
1,
|
||||||
|
'A pull request with no label',
|
||||||
|
issueDate.toDateString(),
|
||||||
|
issueDate.toDateString(),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing a pull request opened since 2 days and with the option "daysBeforePrStale" at 1 will make it stale', async () => {
|
||||||
|
expect.assertions(2);
|
||||||
|
const opts: IssueProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
daysBeforeStale: 10,
|
||||||
|
daysBeforePrStale: 1
|
||||||
|
};
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
opts,
|
||||||
|
1,
|
||||||
|
'A pull request with no label',
|
||||||
|
issueDate.toDateString(),
|
||||||
|
issueDate.toDateString(),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async () => 'abot',
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|||||||
5
dist/index.js
vendored
5
dist/index.js
vendored
@@ -157,13 +157,16 @@ 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, this.options.daysBeforeStale);
|
const shouldBeStale = !IssueProcessor._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`);
|
||||||
yield this._markStale(issue, staleMessage, staleLabel, skipMessage);
|
yield this._markStale(issue, staleMessage, staleLabel, skipMessage);
|
||||||
issue.isStale = true; // this issue is now considered stale
|
issue.isStale = true; // this issue is now considered stale
|
||||||
}
|
}
|
||||||
|
else if (!issue.isStale) {
|
||||||
|
issueLogger.info(`Not marking as stale: shouldBeStale=${shouldBeStale}, shouldMarkAsStale=${shouldMarkAsStale}`);
|
||||||
|
}
|
||||||
// process the issue if it was marked stale
|
// process the issue if it was marked stale
|
||||||
if (issue.isStale) {
|
if (issue.isStale) {
|
||||||
issueLogger.info(`Found a stale ${issueType}`);
|
issueLogger.info(`Found a stale ${issueType}`);
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ export class IssueProcessor {
|
|||||||
// should this issue be marked stale?
|
// should this issue be marked stale?
|
||||||
const shouldBeStale = !IssueProcessor._updatedSince(
|
const shouldBeStale = !IssueProcessor._updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
this.options.daysBeforeStale
|
daysBeforeStale
|
||||||
);
|
);
|
||||||
|
|
||||||
// determine if this issue needs to be marked stale first
|
// determine if this issue needs to be marked stale first
|
||||||
@@ -283,6 +283,10 @@ export class IssueProcessor {
|
|||||||
);
|
);
|
||||||
await this._markStale(issue, staleMessage, staleLabel, skipMessage);
|
await this._markStale(issue, staleMessage, staleLabel, skipMessage);
|
||||||
issue.isStale = true; // this issue is now considered stale
|
issue.isStale = true; // this issue is now considered stale
|
||||||
|
} else if (!issue.isStale) {
|
||||||
|
issueLogger.info(
|
||||||
|
`Not marking as stale: shouldBeStale=${shouldBeStale}, shouldMarkAsStale=${shouldMarkAsStale}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process the issue if it was marked stale
|
// process the issue if it was marked stale
|
||||||
|
|||||||
Reference in New Issue
Block a user