mirror of
https://github.com/actions/stale.git
synced 2025-12-26 10:18:17 +00:00
Compare commits
1 Commits
issue-596/
...
remove
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c1b1c6e11 |
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set Node.js 16.x
|
- name: Set Node.js 16.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# [5.1.1]
|
||||||
|
|
||||||
|
[Fix issue when days-before-close is more than days-before-stale](https://github.com/actions/stale/pull/775)
|
||||||
|
|
||||||
# [5.1.0]
|
# [5.1.0]
|
||||||
|
|
||||||
[Don't process stale issues right after they're marked stale](https://github.com/actions/stale/issues/696)
|
[Don't process stale issues right after they're marked stale](https://github.com/actions/stale/issues/696)
|
||||||
[Add close-issue-reason option][#764](https://github.com/actions/stale/pull/764)[#772](https://github.com/actions/stale/pull/772)
|
[Add close-issue-reason option][#764](https://github.com/actions/stale/pull/764)[#772](https://github.com/actions/stale/pull/772)
|
||||||
Various dependabot/dependency updates
|
Various dependabot/dependency updates
|
||||||
|
|
||||||
|
|
||||||
## [4.1.0](https://github.com/actions/stale/compare/v3.0.19...v4.1.0) (2021-07-14)
|
## [4.1.0](https://github.com/actions/stale/compare/v3.0.19...v4.1.0) (2021-07-14)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- [Ability to exempt draft PRs](https://github.com/actions/stale/commit/9912fa74d1c01b5d6187793d97441019cbe325d0
|
- [Ability to exempt draft PRs](https://github.com/actions/stale/commit/9912fa74d1c01b5d6187793d97441019cbe325d0)
|
||||||
)
|
|
||||||
|
|
||||||
## [4.0.0](https://github.com/actions/stale/compare/v3.0.19...v4.0.0) (2021-07-14)
|
## [4.0.0](https://github.com/actions/stale/compare/v3.0.19...v4.0.0) (2021-07-14)
|
||||||
|
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -11,12 +11,11 @@ The configuration must be on the default branch and the default values will:
|
|||||||
## Recommended permissions
|
## Recommended permissions
|
||||||
|
|
||||||
For the execution of this action, it must be able to fetch all issues and pull requests from your repository.
|
For the execution of this action, it must be able to fetch all issues and pull requests from your repository.
|
||||||
In addition, based on the provided configuration, the action could require more permission(s) (e.g.: add label, remove label, comment, close, delete branch, etc.).
|
In addition, based on the provided configuration, the action could require more permission(s) (e.g.: add label, remove label, comment, close, etc.).
|
||||||
This can be achieved with the following [configuration in the action](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions) if the permissions are restricted:
|
This can be achieved with the following [configuration in the action](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions) if the permissions are restricted:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # only for delete-branch option
|
|
||||||
issues: write
|
issues: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
```
|
```
|
||||||
@@ -82,7 +81,6 @@ Every argument is optional.
|
|||||||
| [ignore-updates](#ignore-updates) | Any update (update/comment) can reset the stale idle time on the issues/PRs | `false` |
|
| [ignore-updates](#ignore-updates) | Any update (update/comment) can reset the stale idle time on the issues/PRs | `false` |
|
||||||
| [ignore-issue-updates](#ignore-issue-updates) | Override [ignore-updates](#ignore-updates) for issues only | |
|
| [ignore-issue-updates](#ignore-issue-updates) | Override [ignore-updates](#ignore-updates) for issues only | |
|
||||||
| [ignore-pr-updates](#ignore-pr-updates) | Override [ignore-updates](#ignore-updates) for PRs only | |
|
| [ignore-pr-updates](#ignore-pr-updates) | Override [ignore-updates](#ignore-updates) for PRs only | |
|
||||||
| [include-only-assigned](#include-only-assigned) | Process only assigned issues | `false` |
|
|
||||||
|
|
||||||
### List of output options
|
### List of output options
|
||||||
|
|
||||||
@@ -398,7 +396,7 @@ Default value: unset
|
|||||||
If set to `true`, the stale workflow will automatically delete the GitHub branches related to the pull requests automatically closed by the stale workflow.
|
If set to `true`, the stale workflow will automatically delete the GitHub branches related to the pull requests automatically closed by the stale workflow.
|
||||||
|
|
||||||
Default value: `false`
|
Default value: `false`
|
||||||
Required Permission: `pull-requests: write` and `contents: write`
|
Required Permission: `pull-requests: write`
|
||||||
|
|
||||||
#### exempt-milestones
|
#### exempt-milestones
|
||||||
|
|
||||||
@@ -518,12 +516,6 @@ Useful to override [ignore-updates](#ignore-updates) but only to ignore the upda
|
|||||||
|
|
||||||
Default value: unset
|
Default value: unset
|
||||||
|
|
||||||
#### include-only-assigned
|
|
||||||
|
|
||||||
If set to `true`, only the issues or the pull requests with an assignee will be marked as stale automatically.
|
|
||||||
|
|
||||||
Default value: `false`
|
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
See also [action.yml](./action.yml) for a comprehensive list of all the options.
|
See also [action.yml](./action.yml) for a comprehensive list of all the options.
|
||||||
|
|||||||
@@ -51,6 +51,5 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
|||||||
ignoreIssueUpdates: undefined,
|
ignoreIssueUpdates: undefined,
|
||||||
ignorePrUpdates: undefined,
|
ignorePrUpdates: undefined,
|
||||||
exemptDraftPr: false,
|
exemptDraftPr: false,
|
||||||
closeIssueReason: '',
|
closeIssueReason: ''
|
||||||
includeOnlyAssigned: false
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2352,69 +2352,3 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
|
|||||||
expect(processor.closedIssues).toHaveLength(0);
|
expect(processor.closedIssues).toHaveLength(0);
|
||||||
expect(processor.statistics?.addedPullRequestsCommentsCount).toStrictEqual(0);
|
expect(processor.statistics?.addedPullRequestsCommentsCount).toStrictEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing an issue with the "includeOnlyAssigned" option and nonempty assignee list will stale the issue', async () => {
|
|
||||||
const issueDate = new Date();
|
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
|
||||||
|
|
||||||
const opts: IIssuesProcessorOptions = {
|
|
||||||
...DefaultProcessorOptions,
|
|
||||||
staleIssueLabel: 'This issue is stale',
|
|
||||||
includeOnlyAssigned: true
|
|
||||||
};
|
|
||||||
|
|
||||||
const TestIssueList: Issue[] = [
|
|
||||||
generateIssue(
|
|
||||||
opts,
|
|
||||||
1,
|
|
||||||
'An issue with no label',
|
|
||||||
issueDate.toDateString(),
|
|
||||||
issueDate.toDateString(),
|
|
||||||
false,
|
|
||||||
[],
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
undefined,
|
|
||||||
['assignee1']
|
|
||||||
)
|
|
||||||
];
|
|
||||||
const processor = new IssuesProcessorMock(
|
|
||||||
opts,
|
|
||||||
async p => (p === 1 ? TestIssueList : []),
|
|
||||||
async () => [],
|
|
||||||
async () => new Date().toDateString()
|
|
||||||
);
|
|
||||||
|
|
||||||
// process our fake issue list
|
|
||||||
await processor.processIssues(1);
|
|
||||||
|
|
||||||
expect(processor.staleIssues).toHaveLength(1);
|
|
||||||
expect(processor.closedIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('processing an issue with the "includeOnlyAssigned" option set and no assignees will not stale the issue', async () => {
|
|
||||||
const issueDate = new Date();
|
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
|
||||||
|
|
||||||
const opts: IIssuesProcessorOptions = {
|
|
||||||
...DefaultProcessorOptions,
|
|
||||||
staleIssueLabel: 'This issue is stale',
|
|
||||||
includeOnlyAssigned: true
|
|
||||||
};
|
|
||||||
|
|
||||||
const TestIssueList: Issue[] = [
|
|
||||||
generateIssue(opts, 1, 'An issue with no label', issueDate.toDateString())
|
|
||||||
];
|
|
||||||
const processor = new IssuesProcessorMock(
|
|
||||||
opts,
|
|
||||||
async p => (p === 1 ? TestIssueList : []),
|
|
||||||
async () => [],
|
|
||||||
async () => new Date().toDateString()
|
|
||||||
);
|
|
||||||
|
|
||||||
// process our fake issue list
|
|
||||||
await processor.processIssues(1);
|
|
||||||
|
|
||||||
expect(processor.staleIssues).toHaveLength(0);
|
|
||||||
expect(processor.closedIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -196,10 +196,6 @@ inputs:
|
|||||||
description: 'Any update (update/comment) can reset the stale idle time on the pull requests. Override "ignore-updates" option regarding only the pull requests.'
|
description: 'Any update (update/comment) can reset the stale idle time on the pull requests. Override "ignore-updates" option regarding only the pull requests.'
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
include-only-assigned:
|
|
||||||
description: 'Only the issues or the pull requests with an assignee will be marked as stale automatically.'
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
outputs:
|
outputs:
|
||||||
closed-issues-prs:
|
closed-issues-prs:
|
||||||
description: 'List of all closed issues and pull requests.'
|
description: 'List of all closed issues and pull requests.'
|
||||||
|
|||||||
2075
dist/index.js
vendored
2075
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
11707
package-lock.json
generated
11707
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -62,8 +62,7 @@ describe('Issue', (): void => {
|
|||||||
ignoreIssueUpdates: undefined,
|
ignoreIssueUpdates: undefined,
|
||||||
ignorePrUpdates: undefined,
|
ignorePrUpdates: undefined,
|
||||||
exemptDraftPr: false,
|
exemptDraftPr: false,
|
||||||
closeIssueReason: '',
|
closeIssueReason: ''
|
||||||
includeOnlyAssigned: false
|
|
||||||
};
|
};
|
||||||
issueInterface = {
|
issueInterface = {
|
||||||
title: 'dummy-title',
|
title: 'dummy-title',
|
||||||
|
|||||||
@@ -221,14 +221,6 @@ export class IssuesProcessor {
|
|||||||
return; // Don't process locked issues
|
return; // Don't process locked issues
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._isIncludeOnlyAssigned(issue)) {
|
|
||||||
issueLogger.info(
|
|
||||||
`Skipping this $$type because it's assignees list is empty`
|
|
||||||
);
|
|
||||||
IssuesProcessor._endIssueProcessing(issue);
|
|
||||||
return; // If the issue has an 'include-only-assigned' option, process only issues with nonempty assignees list
|
|
||||||
}
|
|
||||||
|
|
||||||
const onlyLabels: string[] = wordsToList(this._getOnlyLabels(issue));
|
const onlyLabels: string[] = wordsToList(this._getOnlyLabels(issue));
|
||||||
|
|
||||||
if (onlyLabels.length > 0) {
|
if (onlyLabels.length > 0) {
|
||||||
@@ -673,13 +665,8 @@ export class IssuesProcessor {
|
|||||||
issueLogger.info(`marked stale this run, so don't check for updates`);
|
issueLogger.info(`marked stale this run, so don't check for updates`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
const issueHasUpdateSinceStale =
|
||||||
// isDateMoreRecentThan makes sure they are not the same date within a certain tolerance (15 seconds in this case)
|
new Date(issue.updated_at) > new Date(markedStaleOn);
|
||||||
const issueHasUpdateSinceStale = isDateMoreRecentThan(
|
|
||||||
new Date(issue.updated_at),
|
|
||||||
new Date(markedStaleOn),
|
|
||||||
15
|
|
||||||
);
|
|
||||||
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`$$type has been updated since it was marked stale: ${LoggerService.cyan(
|
`$$type has been updated since it was marked stale: ${LoggerService.cyan(
|
||||||
@@ -1025,10 +1012,6 @@ export class IssuesProcessor {
|
|||||||
return this.options.onlyLabels;
|
return this.options.onlyLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _isIncludeOnlyAssigned(issue: Issue): boolean {
|
|
||||||
return this.options.includeOnlyAssigned && !issue.hasAssignees;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _getAnyOfLabels(issue: Issue): string {
|
private _getAnyOfLabels(issue: Issue): string {
|
||||||
if (issue.isPullRequest) {
|
if (issue.isPullRequest) {
|
||||||
if (this.options.anyOfPrLabels !== '') {
|
if (this.options.anyOfPrLabels !== '') {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {isDateEqualTo, isDateMoreRecentThan} from './is-date-more-recent-than';
|
import {isDateMoreRecentThan} from './is-date-more-recent-than';
|
||||||
|
|
||||||
describe('isDateMoreRecentThan()', (): void => {
|
describe('isDateMoreRecentThan()', (): void => {
|
||||||
let date: Date;
|
let date: Date;
|
||||||
@@ -48,68 +48,4 @@ describe('isDateMoreRecentThan()', (): void => {
|
|||||||
expect(result).toStrictEqual(true);
|
expect(result).toStrictEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('date equality', (): void => {
|
|
||||||
it('should correctly compare a before date outside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T14:00:00');
|
|
||||||
expect(isDateEqualTo(aDate, otherDate, 60)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare a before date inside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T13:00:42');
|
|
||||||
expect(isDateEqualTo(aDate, otherDate, 60)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare an after date outside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T12:00:00');
|
|
||||||
expect(isDateEqualTo(aDate, otherDate, 60)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare an after date inside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T12:59:42');
|
|
||||||
expect(isDateEqualTo(aDate, otherDate, 60)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare an exactly equal date', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T13:00:00');
|
|
||||||
expect(isDateEqualTo(aDate, otherDate, 60)).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('date comparison with tolerances', (): void => {
|
|
||||||
it('should correctly compare a before date outside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T14:00:00');
|
|
||||||
expect(isDateMoreRecentThan(aDate, otherDate)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare a before date inside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T13:00:42');
|
|
||||||
expect(isDateMoreRecentThan(aDate, otherDate, 60)).toBe(false); // considered equal here
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare an after date outside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T12:00:00');
|
|
||||||
expect(isDateMoreRecentThan(aDate, otherDate, 60)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare an after date inside tolerance', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T12:59:42');
|
|
||||||
expect(isDateMoreRecentThan(aDate, otherDate, 60)).toBe(false); // considered equal here
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly compare an exactly equal date', (): void => {
|
|
||||||
const aDate = new Date('2022-09-09T13:00:00');
|
|
||||||
const otherDate = new Date('2022-09-09T13:00:00');
|
|
||||||
expect(isDateMoreRecentThan(aDate, otherDate, 60)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,31 +1,6 @@
|
|||||||
/// returns false if the dates are equal within the `equalityToleranceInSeconds` number of seconds
|
|
||||||
/// otherwise returns true if `comparedDate` is after `date`
|
|
||||||
|
|
||||||
export function isDateMoreRecentThan(
|
export function isDateMoreRecentThan(
|
||||||
date: Readonly<Date>,
|
date: Readonly<Date>,
|
||||||
comparedDate: Readonly<Date>,
|
comparedDate: Readonly<Date>
|
||||||
equalityToleranceInSeconds = 0
|
|
||||||
): boolean {
|
): boolean {
|
||||||
if (equalityToleranceInSeconds > 0) {
|
|
||||||
const areDatesEqual = isDateEqualTo(
|
|
||||||
date,
|
|
||||||
comparedDate,
|
|
||||||
equalityToleranceInSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
return !areDatesEqual && date > comparedDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
return date > comparedDate;
|
return date > comparedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isDateEqualTo(
|
|
||||||
date: Date,
|
|
||||||
otherDate: Date,
|
|
||||||
toleranceInSeconds: number
|
|
||||||
): boolean {
|
|
||||||
const timestamp = date.getTime();
|
|
||||||
const otherTimestamp = otherDate.getTime();
|
|
||||||
const deltaInSeconds = Math.abs(timestamp - otherTimestamp) / 1000;
|
|
||||||
return deltaInSeconds <= toleranceInSeconds;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -52,5 +52,4 @@ export interface IIssuesProcessorOptions {
|
|||||||
ignorePrUpdates: boolean | undefined;
|
ignorePrUpdates: boolean | undefined;
|
||||||
exemptDraftPr: boolean;
|
exemptDraftPr: boolean;
|
||||||
closeIssueReason: string;
|
closeIssueReason: string;
|
||||||
includeOnlyAssigned: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||||||
ignoreIssueUpdates: _toOptionalBoolean('ignore-issue-updates'),
|
ignoreIssueUpdates: _toOptionalBoolean('ignore-issue-updates'),
|
||||||
ignorePrUpdates: _toOptionalBoolean('ignore-pr-updates'),
|
ignorePrUpdates: _toOptionalBoolean('ignore-pr-updates'),
|
||||||
exemptDraftPr: core.getInput('exempt-draft-pr') === 'true',
|
exemptDraftPr: core.getInput('exempt-draft-pr') === 'true',
|
||||||
closeIssueReason: core.getInput('close-issue-reason'),
|
closeIssueReason: core.getInput('close-issue-reason')
|
||||||
includeOnlyAssigned: core.getInput('include-only-assigned') === 'true'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const numberInput of [
|
for (const numberInput of [
|
||||||
|
|||||||
Reference in New Issue
Block a user