Skip to content

Commit

Permalink
feat(issues): add new input issue-limit-api-mutations-count
Browse files Browse the repository at this point in the history
Before processing each issue, the workflow will check if the input is enabled.
If this is the case, the processing may stop if the statistics for mutations are higher than the limit.
Closes #376
  • Loading branch information
C0ZEN committed Feb 5, 2022
1 parent 26e01e9 commit 14b034a
Show file tree
Hide file tree
Showing 22 changed files with 658 additions and 67 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ To help us have a clear vision over the workflow and also for you if you are jus
- Fetch all the open issues per batch of 20, sorted by update date from the oldest first
- Check if the issue can be processed
- If the issues API queries calls performed are below the limit (coming from the `issue-limit-api-queries-count`), stop the processing
- If the issues API mutations calls performed are below the limit (coming from the `issue-limit-api-mutations-count`), stop the processing
- Check if the issue is locked and stop the processing if this is the case
- Check if the issue has a label (except the stale one) and stop the processing if this is the case (coming from the `issue-ignore-all-labels` input)
- Check if the issue has any of the ignored labels and stop the processing if this is the case (coming from the `issue-ignore-any-labels` input)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ All the inputs that are used both for issues and pull requests.
| [issue-add-labels-after-close](https://sonia-corporation.github.io/stale/docs/issues/inputs/issue-add-labels-after-close-input) | A list of labels added when the processing close the issue (multiline). | |
| [issue-processing](https://sonia-corporation.github.io/stale/docs/issues/inputs/issue-processing-input) | Allow to process the issues. | `true` |
| [issue-limit-api-queries-count](https://sonia-corporation.github.io/stale/docs/issues/inputs/issue-limit-api-queries-count) | Limit the quantity of API queries calls performed during the processing of issues (-1 for unlimited). | `-1` |
| [issue-limit-api-mutations-count](https://sonia-corporation.github.io/stale/docs/issues/inputs/issue-limit-api-mutations-count) | Limit the quantity of API mutations calls performed during the processing of issues (-1 for unlimited). | `-1` |

## All the issues outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ inputs:
description: 'Limit the quantity of API queries calls performed during the processing of issues (-1 for unlimited).'
required: false
default: '-1'
issue-limit-api-mutations-count:
description: 'Limit the quantity of API mutations calls performed during the processing of issues (-1 for unlimited).'
required: false
default: '-1'
# Pull request inputs
pull-request-stale-label:
description: 'The label that will be added to the pull request when it is stale.'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You will have a better idea over what to expect when a real run without the [dry
### Test it with a limited amount of API calls {#test-it-with-a-limited-amount-of-api-calls}
If you still wish to play it safe, you can configure a limit of API queries calls for your [issues](../issues/inputs/issue-limit-api-queries-count-input) and [pull requests](../pull-requests/inputs/pull-request-limit-api-queries-count-input) to alter your repository on a reduced scope.
If you still wish to play it safe, you can configure a limit of API queries calls for your [issues](../issues/inputs/issue-limit-api-queries-count-input) and [pull requests](../pull-requests/inputs/pull-request-limit-api-queries-count-input), and a limit of API mutations calls for your [issues](../issues/inputs/issue-limit-api-mutations-count-input) to alter your repository on a reduced scope.
```yml {5-7} title=".github/workflows/stale.yml"
# ...
Expand Down
1 change: 1 addition & 0 deletions documentation/docs/03-all-inputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The list of all the inputs.
| [issue-add-labels-after-close](issues/inputs/issue-add-labels-after-close-input) | A list of labels added when the processing close the issue (multiline). | |
| [issue-processing](issues/inputs/issue-processing-input) | Allow to process the issues. | `true` |
| [issue-limit-api-queries-count](issues/inputs/issue-limit-api-queries-count-input) | Limit the quantity of API queries calls performed during the processing of issues (-1 for unlimited). | `-1` |
| [issue-limit-api-mutations-count](issues/inputs/issue-limit-api-mutations-count-input) | Limit the quantity of API mutations calls performed during the processing of issues (-1 for unlimited). | `-1` |
| [pull-request-stale-label](pull-requests/inputs/pull-request-stale-label-input) | The label that will be added to the pull request when it is stale. | `stale` |
| [pull-request-ignore-all-labels](pull-requests/inputs/pull-request-ignore-all-labels-input) | Allow to ignore the processing of pull requests that contains any labels. | `false` |
| [pull-request-ignore-any-labels](pull-requests/inputs/pull-request-ignore-any-labels-input) | Allow to ignore the processing of pull requests that contains one of those labels (multiline). | |
Expand Down
1 change: 1 addition & 0 deletions documentation/docs/06-issues/01-inputs/01-all-inputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ The list of all issues the inputs.
| [issue-add-labels-after-close](issue-add-labels-after-close-input) | A list of labels added when the processing close the issue (multiline). | |
| [issue-processing](issue-processing-input) | Allow to process the issues. | `true` |
| [issue-limit-api-queries-count](issue-limit-api-queries-count-input) | Limit the quantity of API queries calls performed during the processing of issues (-1 for unlimited). | `-1` |
| [issue-limit-api-mutations-count](issue-limit-api-mutations-count-input) | Limit the quantity of API mutations calls performed during the processing of issues (-1 for unlimited). | `-1` |
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Default value: `-1`

### Description {#description}

This input will let you define a limit count of issues API queries calls performed during the processing.
This input will let you define a limit count of issues API queries (read) calls performed during the processing.
If the limit is reached, the ongoing processed issue will finish it's processing then all other issues will be ignored.
This can be useful when you want to play it safe with this action.
This can be also very useful if you have a lot of issues to process, and you want to limit the quotas of your associated [GitHub token](../../github-token-input).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: issue-limit-api-mutations-count-input
title: Issue limit api mutations count input
tags:
- Issues
- Inputs
---

### Input {#input}

Name: `issue-limit-api-mutations-count`
Type: `number`
Default value: `-1`

### Description {#description}

This input will let you define a limit count of issues API mutations (add, edit, delete) calls performed during the processing.
If the limit is reached, the ongoing processed issue will finish it's processing then all other issues will be ignored.
This can be useful when you want to play it safe with this action.
This can be also very useful if you have a lot of issues to process, and you want to limit the quotas of your associated [GitHub token](../../github-token-input).

### Example {#example}

```yml {6}
# ...
name: Stale
id: stale
uses: sonia-corporation/stale@latest
with:
issue-limit-api-mutations-count: false
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Default value: `-1`

### Description {#description}

This input will let you define a limit count of pull requests API queries calls performed during the processing.
This input will let you define a limit count of pull requests API queries (read) calls performed during the processing.
If the limit is reached, the ongoing processed pull request will finish it's processing then all other pull requests will be ignored.
This can be useful when you want to play it safe with this action.
This can be also very useful if you have a lot of pull requests to process, and you want to limit the quotas of your associated [GitHub token](../../github-token-input).
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/10-statistics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In such case, enable the [dry-run mode](dry-run-input) to avoid altering your re

### Limited API calls {#limited-api-calls}

You can also simply limit the number of API queries calls for your [issues](issues/inputs/issue-limit-api-queries-count-input) and [pull requests](pull-requests/inputs/pull-request-limit-api-queries-count-input) to alter your repository on a reduced scope.
You can also simply limit the number of API queries calls for your [issues](issues/inputs/issue-limit-api-queries-count-input) and [pull requests](pull-requests/inputs/pull-request-limit-api-queries-count-input), and a limit of API mutations calls for your [issues](issues/inputs/issue-limit-api-mutations-count-input) to alter your repository on a reduced scope.

### Example {#example}

Expand Down
1 change: 1 addition & 0 deletions src/core/inputs/inputs.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum EInputs {
ISSUE_CLOSE_COMMENT = `issue-close-comment`,
ISSUE_PROCESSING = `issue-processing`,
ISSUE_LIMIT_API_QUERIES_COUNT = `issue-limit-api-queries-count`,
ISSUE_LIMIT_API_MUTATIONS_COUNT = `issue-limit-api-mutations-count`,
PULL_REQUEST_DAYS_BEFORE_CLOSE = `pull-request-days-before-close`,
PULL_REQUEST_DAYS_BEFORE_STALE = `pull-request-days-before-stale`,
PULL_REQUEST_IGNORE_ALL_ASSIGNEES = `pull-request-ignore-all-assignees`,
Expand Down
1 change: 1 addition & 0 deletions src/core/inputs/interfaces/issues-inputs.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IIssuesInputs extends IInputs {
readonly issueIgnoreAnyAssignees: string[];
readonly issueIgnoreAnyLabels: string[];
readonly issueIgnoreBeforeCreationDate: IIso8601Date | '';
readonly issueLimitApiMutationsCount: number;
readonly issueLimitApiQueriesCount: number;
readonly issueProcessing: boolean;
readonly issueStaleComment: IComment | '';
Expand Down
Loading

0 comments on commit 14b034a

Please sign in to comment.