mirror of
https://github.com/actions/stale.git
synced 2025-12-28 19:18:16 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e611bf905b | ||
|
|
1e900bc060 |
@@ -34,7 +34,7 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'Message to comment on stale issues. If none provided, will not mark issues stale'
|
stale-issue-message: 'Message to comment on stale issues. If none provided, will not mark issues stale'
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
|
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
|
||||||
@@ -71,7 +71,7 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'Stale issue message'
|
stale-issue-message: 'Stale issue message'
|
||||||
@@ -84,4 +84,4 @@ jobs:
|
|||||||
|
|
||||||
### Debugging
|
### Debugging
|
||||||
|
|
||||||
To see debug ouput from this action, you must set the secret `ACTIONS_STEP_DEBUG` to `true` in your repository. You can run this action in debug only mode (no actions will be taken on your issues) by passing `debug-only` `true` as an argument to the action.
|
To see debug output from this action, you must set the secret `ACTIONS_STEP_DEBUG` to `true` in your repository. You can run this action in debug only mode (no actions will be taken on your issues) by passing `debug-only` `true` as an argument to the action.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const DefaultProcessorOptions: IssueProcessorOptions = {
|
|||||||
staleIssueMessage: 'This issue is stale',
|
staleIssueMessage: 'This issue is stale',
|
||||||
stalePrMessage: 'This PR is stale',
|
stalePrMessage: 'This PR is stale',
|
||||||
daysBeforeStale: 1,
|
daysBeforeStale: 1,
|
||||||
daysBeforeClose: 1,
|
daysBeforeClose: 30,
|
||||||
staleIssueLabel: 'Stale',
|
staleIssueLabel: 'Stale',
|
||||||
exemptIssueLabels: '',
|
exemptIssueLabels: '',
|
||||||
stalePrLabel: 'Stale',
|
stalePrLabel: 'Stale',
|
||||||
@@ -62,7 +62,7 @@ test('empty issue list results in 1 operation', async () => {
|
|||||||
expect(operationsLeft).toEqual(99);
|
expect(operationsLeft).toEqual(99);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing an issue with no label will make it stale', async () => {
|
test('processing an issue with no label will make it stale and close it, if it is old enough', async () => {
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||||
];
|
];
|
||||||
@@ -77,6 +77,30 @@ test('processing an issue with no label will make it stale', async () => {
|
|||||||
// process our fake issue list
|
// process our fake issue list
|
||||||
await processor.processIssues(1);
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing an issue with no label will make it stale but not close it', async () => {
|
||||||
|
// issue should be from 2 days ago so it will be
|
||||||
|
// stale but not close-able, based on default settings
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'An issue with no label', issueDate.toDateString())
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
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.staleIssues.length).toEqual(1);
|
||||||
expect(processor.closedIssues.length).toEqual(0);
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|||||||
18
dist/index.js
vendored
18
dist/index.js
vendored
@@ -8510,14 +8510,20 @@ class IssueProcessor {
|
|||||||
core.debug(`Skipping ${issueType} because it has an exempt label`);
|
core.debug(`Skipping ${issueType} because it has an exempt label`);
|
||||||
continue; // don't process exempt issues
|
continue; // don't process exempt issues
|
||||||
}
|
}
|
||||||
if (IssueProcessor.isLabeled(issue, staleLabel)) {
|
// does this issue have a stale label?
|
||||||
core.debug(`Found a stale ${issueType}`);
|
let isStale = IssueProcessor.isLabeled(issue, staleLabel);
|
||||||
yield this.processStaleIssue(issue, issueType, staleLabel);
|
// determine if this issue needs to be marked stale first
|
||||||
}
|
if (!isStale &&
|
||||||
else if (!IssueProcessor.updatedSince(issue.updated_at, this.options.daysBeforeStale)) {
|
!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} and it does not have a stale label`);
|
||||||
yield this.markStale(issue, staleMessage, staleLabel);
|
yield this.markStale(issue, staleMessage, staleLabel);
|
||||||
this.operationsLeft -= 2;
|
this.operationsLeft -= 2;
|
||||||
|
isStale = true; // this issue is now considered stale
|
||||||
|
}
|
||||||
|
// process any issues marked stale (including the issue above, if it was marked)
|
||||||
|
if (isStale) {
|
||||||
|
core.debug(`Found a stale ${issueType}`);
|
||||||
|
yield this.processStaleIssue(issue, issueType, staleLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do the next batch
|
// do the next batch
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.2.3",
|
||||||
"@actions/github": "^2.1.1",
|
"@actions/github": "^2.2.0",
|
||||||
"@octokit/rest": "^16.43.1",
|
"@octokit/rest": "^16.43.1",
|
||||||
"semver": "^6.1.1"
|
"semver": "^6.1.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -150,20 +150,29 @@ export class IssueProcessor {
|
|||||||
continue; // don't process exempt issues
|
continue; // don't process exempt issues
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IssueProcessor.isLabeled(issue, staleLabel)) {
|
// does this issue have a stale label?
|
||||||
core.debug(`Found a stale ${issueType}`);
|
let isStale = IssueProcessor.isLabeled(issue, staleLabel);
|
||||||
await this.processStaleIssue(issue, issueType, staleLabel);
|
|
||||||
} else if (
|
// determine if this issue needs to be marked stale first
|
||||||
|
if (
|
||||||
|
!isStale &&
|
||||||
!IssueProcessor.updatedSince(
|
!IssueProcessor.updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
this.options.daysBeforeStale
|
this.options.daysBeforeStale
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
core.debug(
|
core.debug(
|
||||||
`Marking ${issueType} stale because it was last updated on ${issue.updated_at}`
|
`Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label`
|
||||||
);
|
);
|
||||||
await this.markStale(issue, staleMessage, staleLabel);
|
await this.markStale(issue, staleMessage, staleLabel);
|
||||||
this.operationsLeft -= 2;
|
this.operationsLeft -= 2;
|
||||||
|
isStale = true; // this issue is now considered stale
|
||||||
|
}
|
||||||
|
|
||||||
|
// process any issues marked stale (including the issue above, if it was marked)
|
||||||
|
if (isStale) {
|
||||||
|
core.debug(`Found a stale ${issueType}`);
|
||||||
|
await this.processStaleIssue(issue, issueType, staleLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,16 +263,14 @@ export class IssueProcessor {
|
|||||||
|
|
||||||
// grab issues from github in baches of 100
|
// grab issues from github in baches of 100
|
||||||
private async getIssues(page: number): Promise<Issue[]> {
|
private async getIssues(page: number): Promise<Issue[]> {
|
||||||
const issueResult: OctoKitIssueList = await this.client.issues.listForRepo(
|
const issueResult: OctoKitIssueList = await this.client.issues.listForRepo({
|
||||||
{
|
owner: github.context.repo.owner,
|
||||||
owner: github.context.repo.owner,
|
repo: github.context.repo.repo,
|
||||||
repo: github.context.repo.repo,
|
state: 'open',
|
||||||
state: 'open',
|
labels: this.options.onlyLabels,
|
||||||
labels: this.options.onlyLabels,
|
per_page: 100,
|
||||||
per_page: 100,
|
page
|
||||||
page
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return issueResult.data;
|
return issueResult.data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user