Skip to content

Commit

Permalink
feat(prs): add new input pull-request-limit-api-queries-count
Browse files Browse the repository at this point in the history
Before processing each pull request, the workflow will check if the input is enabled.
If this is the case, the processing may stop if the statistics for queries are higher than the limit.
Closes #254
  • Loading branch information
C0ZEN committed Feb 2, 2022
1 parent db5effb commit ee9a293
Show file tree
Hide file tree
Showing 18 changed files with 853 additions and 167 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ All the inputs that are used both for issues and pull requests.
| [pull-request-add-labels-after-close](https://sonia-corporation.github.io/stale/docs/pull-requests/inputs/pull-request-add-labels-after-close-input) | A list of labels added when the processing close the pull request (multiline). | |
| [pull-request-processing](https://sonia-corporation.github.io/stale/docs/pull-requests/inputs/pull-request-processing-input) | Allow to process the pull requests. | `true` |
| [pull-request-to-draft-instead-of-stale](https://sonia-corporation.github.io/stale/docs/pull-requests/inputs/pull-request-to-draft-instead-of-stale-input) | Convert the pull request to a draft pull request instead of handling it as a stale candidate. | `false` |
| [pull-request-limit-api-queries-count](https://sonia-corporation.github.io/stale/docs/pull-requests/inputs/pull-request-limit-api-queries-count) | Limit the quantity of API queries calls performed during the processing of pull requests (-1 for unlimited). | `-1` |

## All the pull requests outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ inputs:
description: 'Convert the pull request to a draft pull request instead of handling it as a stale candidate.'
required: false
default: 'false'
pull-request-limit-api-queries-count:
description: 'Limit the quantity of API queries calls performed during the processing of pull requests (-1 for unlimited).'
required: false
default: '-1'
outputs:
# Issues outputs
processed-issues-count:
Expand Down
4 changes: 2 additions & 2 deletions 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) 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) to alter your repository on a reduced scope.

```yml {5-6} 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 @@ -46,3 +46,4 @@ The list of all the inputs.
| [pull-request-add-labels-after-close](pull-requests/inputs/pull-request-add-labels-after-close-input) | A list of labels added when the processing close the pull request (multiline). | |
| [pull-request-processing](pull-requests/inputs/pull-request-processing-input) | Allow to process the pull requests. | `true` |
| [pull-request-to-draft-instead-of-stale](pull-requests/inputs/pull-request-to-draft-instead-of-stale-input) | Convert the pull request to a draft pull request instead of handling it as a stale candidate. | `false` |
| [pull-request-limit-api-queries-count](pull-requests/inputs/pull-request-limit-api-queries-count-input) | Limit the quantity of API queries calls performed during the processing of pull requests (-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 API queries calls performed during the processing.
This input will let you define a limit count of issues API queries 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
Expand Up @@ -27,3 +27,4 @@ The list of all the pull requests inputs.
| [pull-request-add-labels-after-close](pull-request-add-labels-after-close-input) | A list of labels added when the processing close the pull request (multiline). | |
| [pull-request-processing](pull-request-processing-input) | Allow to process the pull requests. | `true` |
| [pull-request-to-draft-instead-of-stale](pull-request-to-draft-instead-of-stale-input) | Convert the pull request to a draft pull request instead of handling it as a stale candidate. | `false` |
| [pull-request-limit-api-queries-count](pull-request-limit-api-queries-count-input) | Limit the quantity of API queries calls performed during the processing of pull requests (-1 for unlimited). | `-1` |
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: pull-request-limit-api-queries-count-input
title: Pull request limit api queries count input
tags:
- Pull requests
- Inputs
---

### Input {#input}

Name: `pull-request-limit-api-queries-count`
Type: `number`
Default value: `-1`

### Description {#description}

This input will let you define a limit count of pull requests API queries 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).

### Example {#example}

```yml {6}
# ...
name: Stale
id: stale
uses: sonia-corporation/stale@latest
with:
pull-request-limit-api-queries-count: false
```
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) 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) 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 @@ -33,4 +33,5 @@ export enum EInputs {
PULL_REQUEST_CLOSE_COMMENT = `pull-request-close-comment`,
PULL_REQUEST_PROCESSING = `pull-request-processing`,
PULL_REQUEST_TO_DRAFT_INSTEAD_OF_STALE = `pull-request-to-draft-instead-of-stale`,
PULL_REQUEST_LIMIT_API_QUERIES_COUNT = `pull-request-limit-api-queries-count`,
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IPullRequestsInputs extends IInputs {
readonly pullRequestIgnoreAnyLabels: string[];
readonly pullRequestIgnoreBeforeCreationDate: IIso8601Date | '';
readonly pullRequestIgnoreDraft: boolean;
readonly pullRequestLimitApiQueriesCount: number;
readonly pullRequestProcessing: boolean;
readonly pullRequestStaleComment: IComment | '';
readonly pullRequestStaleLabel: string;
Expand Down

0 comments on commit ee9a293

Please sign in to comment.