Skip to content

Commit

Permalink
feat(outputs): add new outputs removed-pull-requests-labels-count a…
Browse files Browse the repository at this point in the history
…nd `pull-requests-labels-count`

Closes #858.
  • Loading branch information
C0ZEN committed Aug 30, 2022
1 parent ccf4e1b commit ff3f686
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 16 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ All the inputs that are used both for issues and pull requests.
| [remove-stale-issues-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/remove-stale-issues-count-output) | The number of issues from where the stale state was removed. |
| [close-issues-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/close-issues-count-output) | The number of issues closed. |
| [added-issues-comments-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/added-issues-comments-count-output) | The number of added issues comments. |
| [issues-labels-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/issues-labels-count-output) | The number of issues labels mutated (added or removed). |
| [issues-labels-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/issues-labels-count-output) | The number of mutated issues labels (added or removed). |
| [added-issues-labels-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/added-issues-labels-count-output) | The number of added issues labels. |
| [removed-issues-labels-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/removed-issues-labels-count-output) | The number of removed issues labels. |
| [called-api-issues-count](https://sonia-stale-action.vercel.app/docs/issues/outputs/called-api-issues-count-output) | The number of GitHub API calls performed for the issues. |
Expand Down Expand Up @@ -190,7 +190,9 @@ All the inputs that are used both for issues and pull requests.
| [close-pull-requests-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/close-pull-requests-count-output) | The number of pull requests closed. |
| [deleted-pull-requests-branches-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/deleted-pull-requests-branches-count-output) | The number of deleted pull requests branches closed. |
| [added-pull-requests-comments-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/added-pull-requests-comments-count-output) | The number of added pull requests comments. |
| [pull-requests-labels-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/pull-requests-labels-count-output) | The number of mutated pull requests labels (added or removed). |
| [added-pull-requests-labels-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/added-pull-requests-labels-count-output) | The number of added pull requests labels. |
| [removed-pull-requests-labels-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/removed-pull-requests-labels-count-output) | The number of removed pull requests labels. |
| [draft-pull-requests-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/draft-pull-requests-count-output) | The number of pull requests converted to draft. |
| [called-api-pull-requests-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/called-api-pull-requests-count-output) | The number of GitHub API calls performed for the pull requests. |
| [called-api-pull-requests-queries-count](https://sonia-stale-action.vercel.app/docs/pull-requests/outputs/called-api-pull-requests-queries-count-output) | The number of GitHub API queries calls performed for the pull requests. |
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ outputs:
added-issues-comments-count:
description: 'The number of added issues comments.'
issues-labels-count:
description: 'The number of issues labels mutated (added or removed).'
description: 'The number of mutated issues labels (added or removed).'
added-issues-labels-count:
description: 'The number of added issues labels.'
removed-issues-labels-count:
Expand Down Expand Up @@ -302,8 +302,12 @@ outputs:
description: 'The number of deleted pull requests branches closed.'
added-pull-requests-comments-count:
description: 'The number of added pull requests comments.'
pull-requests-labels-count:
description: 'The number of mutated pull requests labels (added or removed).'
added-pull-requests-labels-count:
description: 'The number of added pull requests labels.'
removed-pull-requests-labels-count:
description: 'The number of removed pull requests labels.'
draft-pull-requests-count:
description: 'The number of pull requests converted to draft.'
called-api-pull-requests-count:
Expand Down
4 changes: 3 additions & 1 deletion documentation/docs/04-all-outputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The list of all the outputs.
| [already-stale-issues-count](issues/outputs/already-stale-issues-count-output) | The number of issues processed which were already stale. | `number` |
| [remove-stale-issues-count](issues/outputs/remove-stale-issues-count-output) | The number of issues from where the stale state was removed. | `number` |
| [close-issues-count](issues/outputs/close-issues-count-output) | The number of issues closed. | `number` |
| [issues-comments-count](issues/outputs/issues-comments-count-output) | The number of issues labels mutated (added or removed). | `number` |
| [issues-comments-count](issues/outputs/issues-comments-count-output) | The number of mutated issues labels (added or removed). | `number` |
| [added-issues-comments-count](issues/outputs/added-issues-comments-count-output) | The number of added issues comments. | `number` |
| [removed-issues-comments-count](issues/outputs/removed-issues-comments-count-output) | The number of removed issues comments. | `number` |
| [added-issues-labels-count](issues/outputs/added-issues-labels-count-output) | The number of added issues labels. | `number` |
Expand All @@ -37,7 +37,9 @@ The list of all the outputs.
| [close-pull-requests-count](pull-requests/outputs/close-pull-requests-count-output) | The number of pull requests closed. | `number` |
| [deleted-pull-requests-branches-count](pull-requests/outputs/deleted-pull-requests-branches-count-output) | The number of deleted pull requests branches closed. | `number` |
| [added-pull-requests-comments-count](pull-requests/outputs/added-pull-requests-comments-count-output) | The number of added pull requests comments. | `number` |
| [pull-requests-labels-count](pull-requests/outputs/pull-requests-labels-count-output) | The number of mutated pull requests labels (added or removed). | `number` |
| [added-pull-requests-labels-count](pull-requests/outputs/added-pull-requests-labels-count-output) | The number of added pull requests labels. | `number` |
| [removed-pull-requests-labels-count](pull-requests/outputs/removed-pull-requests-labels-count-output) | The number of removed pull requests labels. | `number` |
| [draft-pull-requests-count](pull-requests/outputs/draft-pull-requests-count-output) | The number of pull requests converted to draft. | `number` |
| [called-api-pull-requests-count](pull-requests/outputs/called-api-pull-requests-count-output) | The number of GitHub API calls performed for the pull requests. | `number` |
| [called-api-pull-requests-queries-count](pull-requests/outputs/called-api-pull-requests-queries-count-output) | The number of GitHub API queries calls performed for the pull requests. | `number` |
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/06-issues/02-outputs/01-all-outputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The list of all issues the outputs.
| [remove-stale-issues-count](remove-stale-issues-count-output) | The number of issues from where the stale state was removed. | `number` |
| [close-issues-count](close-issues-count-output) | The number of issues closed. | `number` |
| [added-issues-comments-count](added-issues-comments-count-output) | The number of added issues comments. | `number` |
| [issues-labels-count](issues-labels-count-output) | The number of issues labels mutated (added or removed). | `number` |
| [issues-labels-count](issues-labels-count-output) | The number of mutated issues labels (added or removed). | `number` |
| [added-issues-labels-count](added-issues-labels-count-output) | The number of added issues labels. | `number` |
| [removed-issues-labels-count](removed-issues-labels-count-output) | The number of removed issues labels. | `number` |
| [called-api-issues-count](called-api-issues-count-output) | The number of GitHub API calls performed for the issues. | `number` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Type: `number`

### Description {#description}

This output will expose the number of issues labels mutated (added or removed).
This output will expose the number of mutated issues labels (added or removed).

### Example {#example}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This can be useful when you are sure that all your pull requests are useful and

:::info

When converting to draft, the inputs [stale comment](pull-request-stale-comment-input) and [add labels after stale](pull-request-add-labels-after-stale-input) will not be performed.
When converting to draft, the inputs [stale comment](pull-request-stale-comment-input), [add labels after stale](pull-request-add-labels-after-stale-input) and [remove labels after stale](pull-request-remove-labels-after-stale-input) will not be performed.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ The list of all pull requests the outputs.
| [close-pull-requests-count](close-pull-requests-count-output) | The number of pull requests closed. | `number` |
| [deleted-pull-requests-branches-count](deleted-pull-requests-branches-count-output) | The number of deleted pull requests branches closed. | `number` |
| [added-pull-requests-comments-count](added-pull-requests-comments-count-output) | The number of added pull requests comments. | `number` |
| [pull-requests-labels-count](pull-requests-labels-count-output) | The number of mutated pull requests labels (added or removed). | `number` |
| [added-pull-requests-labels-count](added-pull-requests-labels-count-output) | The number of added pull requests labels. | `number` |
| [removed-pull-requests-labels-count](removed-pull-requests-labels-count-output) | The number of removed pull requests labels. | `number` |
| [draft-pull-requests-count](draft-pull-requests-count-output) | The number of pull requests converted to draft. | `number` |
| [called-api-pull-requests-count](called-api-pull-requests-count-output) | The number of GitHub API calls performed for the pull requests. | `number` |
| [called-api-pull-requests-queries-count](called-api-pull-requests-queries-count-output) | The number of GitHub API queries calls performed for the pull requests. | `number` |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: pull-requests-labels-count-output
title: Pull requests labels count output
description: |
All the information you need to know about the mutated pull requests labels count output.
Including a detailed description and an example.
tags:
- Pull requests
- Outputs
---

### Output {#output}

Name: `pull-requests-labels-count`
Type: `number`

### Description {#description}

This output will expose the number of mutated pull requests labels (added or removed).

### Example {#example}

```yml {6-7}
# ...
steps:
- name: Stale
id: stale
uses: sonia-corporation/stale@latest
- name: Count
run: echo "${{ steps.Stale.outputs.pull-requests-labels-count }}"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: removed-pull-requests-labels-count-output
title: Removed pull requests labels count output
description: |
All the information you need to know about the removed pull requests labels count output.
Including a detailed description and an example.
tags:
- Pull requests
- Outputs
---

### Output {#output}

Name: `removed-pull-requests-labels-count`
Type: `number`

### Description {#description}

This output will expose the number of removed pull requests labels.

### Example {#example}

```yml {6-7}
# ...
steps:
- name: Stale
id: stale
uses: sonia-corporation/stale@latest
- name: Count
run: echo "${{ steps.Stale.outputs.removed-pull-requests-labels-count }}"
```
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ describe(`PullRequestsOutputsAnnotationsService`, (): void => {
PullRequestsStatisticsService.getInstance().deletedPullRequestsBranchesCount = 8;
PullRequestsStatisticsService.getInstance().addedPullRequestsCommentsCount = 9;
PullRequestsStatisticsService.getInstance().addedPullRequestsLabelsCount = 10;
PullRequestsStatisticsService.getInstance().draftPullRequestsCount = 11;
PullRequestsStatisticsService.getInstance().calledApiPullRequestsQueriesCount = 12;
PullRequestsStatisticsService.getInstance().calledApiPullRequestsMutationsCount = 13;
PullRequestsStatisticsService.getInstance().removedPullRequestsLabelsCount = 11;
PullRequestsStatisticsService.getInstance().draftPullRequestsCount = 12;
PullRequestsStatisticsService.getInstance().calledApiPullRequestsQueriesCount = 13;
PullRequestsStatisticsService.getInstance().calledApiPullRequestsMutationsCount = 14;
});

it(`should log the pull requests outputs annotations`, (): void => {
expect.assertions(15);
expect.assertions(17);

service.noticeAllOutputs();

expect(coreNoticeSpy).toHaveBeenCalledTimes(14);
expect(coreNoticeSpy).toHaveBeenCalledTimes(16);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(1, `Already stale pull requests: 5`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(2, `Ignored pull requests: 2`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(3, `Unaltered pull requests: 3`);
Expand All @@ -84,11 +85,13 @@ describe(`PullRequestsOutputsAnnotationsService`, (): void => {
expect(coreNoticeSpy).toHaveBeenNthCalledWith(7, `Closed pull requests: 7`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(8, `Deleted pull requests branches: 8`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(9, `Added pull requests comments: 9`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(10, `Added pull requests labels: 10`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(11, `Draft pull requests: 11`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(12, `Called api pull requests: 25`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(13, `Called api pull requests queries: 12`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(14, `Called api pull requests mutations: 13`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(10, `Pull requests labels: 21`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(11, `Added pull requests labels: 10`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(12, `Removed pull requests labels: 11`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(13, `Draft pull requests: 12`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(14, `Called api pull requests: 27`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(15, `Called api pull requests queries: 13`);
expect(coreNoticeSpy).toHaveBeenNthCalledWith(16, `Called api pull requests mutations: 14`);
});
});

Expand All @@ -104,6 +107,7 @@ describe(`PullRequestsOutputsAnnotationsService`, (): void => {
PullRequestsStatisticsService.getInstance().deletedPullRequestsBranchesCount = 0;
PullRequestsStatisticsService.getInstance().addedPullRequestsCommentsCount = 0;
PullRequestsStatisticsService.getInstance().addedPullRequestsLabelsCount = 0;
PullRequestsStatisticsService.getInstance().removedPullRequestsLabelsCount = 0;
PullRequestsStatisticsService.getInstance().draftPullRequestsCount = 0;
PullRequestsStatisticsService.getInstance().calledApiPullRequestsQueriesCount = 0;
PullRequestsStatisticsService.getInstance().calledApiPullRequestsMutationsCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ const MAP: { [key in keyof typeof EPullRequestsOutputs]: () => void } = {
PROCESSED_PULL_REQUESTS_COUNT(): void {
noticeCount(`Processed pull requests`, PullRequestsStatisticsService.getInstance().processedPullRequestsCount);
},
PULL_REQUESTS_LABELS_COUNT(): void {
noticeCount(`Pull requests labels`, PullRequestsStatisticsService.getInstance().pullRequestsLabelsCount);
},
REMOVE_STALE_PULL_REQUESTS_COUNT(): void {
noticeCount(`Remove stale pull requests`, PullRequestsStatisticsService.getInstance().removeStalePullRequestsCount);
},
REMOVED_PULL_REQUESTS_LABELS_COUNT(): void {
noticeCount(
`Removed pull requests labels`,
PullRequestsStatisticsService.getInstance().removedPullRequestsLabelsCount
);
},
STALE_PULL_REQUESTS_COUNT(): void {
noticeCount(`Stale pull requests`, PullRequestsStatisticsService.getInstance().stalePullRequestsCount);
},
Expand Down
2 changes: 2 additions & 0 deletions src/core/outputs/enums/pull-requests-outputs.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export enum EPullRequestsOutputs {
CLOSE_PULL_REQUESTS_COUNT = `close-pull-requests-count`,
DELETED_PULL_REQUESTS_BRANCHES_COUNT = `deleted-pull-requests-branches-count`,
ADDED_PULL_REQUESTS_COMMENTS_COUNT = `added-pull-requests-comments-count`,
PULL_REQUESTS_LABELS_COUNT = `pull-requests-labels-count`,
ADDED_PULL_REQUESTS_LABELS_COUNT = `added-pull-requests-labels-count`,
REMOVED_PULL_REQUESTS_LABELS_COUNT = `removed-pull-requests-labels-count`,
DRAFT_PULL_REQUESTS_COUNT = `draft-pull-requests-count`,
CALLED_API_PULL_REQUESTS_COUNT = `called-api-pull-requests-count`,
CALLED_API_PULL_REQUESTS_QUERIES_COUNT = `called-api-pull-requests-queries-count`,
Expand Down

0 comments on commit ff3f686

Please sign in to comment.