Skip to content

Commit

Permalink
feat(issues): add new input issue-limit-api-queries-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 queries are higher than the limit.
Closes #254
  • Loading branch information
C0ZEN committed Feb 2, 2022
1 parent 915c513 commit db5effb
Show file tree
Hide file tree
Showing 16 changed files with 879 additions and 148 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ All the inputs that are used both for issues and pull requests.
| [issue-add-labels-after-stale](https://sonia-corporation.github.io/stale/docs/issues/inputs/issue-add-labels-after-stale-input) | A list of labels added when the processing stale the issue (multiline). | |
| [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` |

## 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 @@ -68,6 +68,10 @@ inputs:
description: 'Allow to process the issues.'
required: false
default: 'true'
issue-limit-api-queries-count:
description: 'Limit the quantity of API queries 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
17 changes: 14 additions & 3 deletions documentation/docs/02-getting-started/02-workflow-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ tags:
At this point, you shall have a working stale action.
Before going further into the customization, you may want to try it first.

:::tip
### Test it with the dry-run mode {#test-it-with-the-dry-run-mode}

Use the [dry-run](../dry-run-input) mode to avoid altering your repository yet.

:::

```yml {5-6} title=".github/workflows/stale.yml"
# ...
name: Stale
Expand All @@ -33,6 +31,19 @@ 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.

```yml {5-6} title=".github/workflows/stale.yml"
# ...
name: Stale
id: stale
uses: sonia-corporation/stale@latest
with:
issue-limit-api-queries-count: 30
```

## Customize the behaviour {#customize-the-behaviour}

If the action was successful, you may wish now to configure it at your convenience.
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 @@ -28,6 +28,7 @@ The list of all the inputs.
| [issue-add-labels-after-stale](issues/inputs/issue-add-labels-after-stale-input) | A list of labels added when the processing stale the issue (multiline). | |
| [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` |
| [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 @@ -24,3 +24,4 @@ The list of all issues the inputs.
| [issue-add-labels-after-stale](issue-add-labels-after-stale-input) | A list of labels added when the processing stale the issue (multiline). | |
| [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` |
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: issue-limit-api-queries-count-input
title: Issue limit api queries count input
tags:
- Issues
- Inputs
---

### Input {#input}

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

### Description {#description}

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

### Example {#example}

```yml {6}
# ...
name: Stale
id: stale
uses: sonia-corporation/stale@latest
with:
issue-limit-api-queries-count: false
```
6 changes: 6 additions & 0 deletions documentation/docs/10-statistics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ tags:
To have an oversight vision of your workflow, you can check out the logs.
There is, at the end, a list of statistics listing the main events that occurred during the run.

### Dry-run mode {#dry-run-mode}

This feature can be very helpful when you are not sure how the workflow will behave based on your configuration.
In such case, enable the [dry-run mode](dry-run-input) to avoid altering your repository, execute the workflow, and then analyse the statistics.

### 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.

### 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 @@ -15,6 +15,7 @@ export enum EInputs {
ISSUE_STALE_COMMENT = `issue-stale-comment`,
ISSUE_CLOSE_COMMENT = `issue-close-comment`,
ISSUE_PROCESSING = `issue-processing`,
ISSUE_LIMIT_API_QUERIES_COUNT = `issue-limit-api-queries-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 issueLimitApiQueriesCount: number;
readonly issueProcessing: boolean;
readonly issueStaleComment: IComment | '';
readonly issueStaleLabel: string;
Expand Down
Loading

0 comments on commit db5effb

Please sign in to comment.