Skip to content

Commit

Permalink
feat(processing): add new input to enable or disable the processing
Browse files Browse the repository at this point in the history
Add the `issue-processing` and `pull-request-processing` inputs.
When enabled, the processing occurs as expected.
When disabled, the processing will be skipped.
Closes #277
  • Loading branch information
C0ZEN committed Jan 18, 2022
1 parent 8879e76 commit b57eac0
Show file tree
Hide file tree
Showing 23 changed files with 646 additions and 102 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ To help us have a clear vision over the workflow and also for you if you are jus

### Issues

- Check if the issues processing is enabled and stop the processing if this is the case (coming from the `issue-processing` input)
- Fetch all the open issues per batch of 20, sorted by update date from the oldest first
- 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)
Expand All @@ -152,6 +153,7 @@ To help us have a clear vision over the workflow and also for you if you are jus

### Pull requests

- Check if the pull requests processing is enabled and stop the processing if this is the case (coming from the `pull-request-processing` input)
- Fetch all the open pull requests per batch of 20, sorted by update date from the oldest first
- Check if the pull request is locked and stop the processing if this is the case
- Check if the pull request has a label (except the stale one) and stop the processing if this is the case (coming from the `pull-request-ignore-all-labels` input)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ All the inputs that are used both for issues and pull requests.
| issue-days-before-close | The number of days until a stale issue is considered as closed. | `10` |
| issue-close-comment | The comment that will be sent once the issue is close (keep empty to not send a comment). | |
| issue-add-labels-after-stale | A list of labels added when the processing stale the issue (multiline). | |
| issue-processing | Allow to process the issues. | `true` |

## All the issues outputs

Expand Down Expand Up @@ -118,6 +119,7 @@ All the inputs that are used both for issues and pull requests.
| pull-request-close-comment | The comment that will be sent once the pull request is close (keep empty to not send a comment). | |
| pull-request-delete-branch-after-close | Delete the branch when the processing close the pull request. | `false` |
| pull-request-add-labels-after-stale | A list of labels added when the processing stale the pull request (multiline). | |
| pull-request-processing | Allow to process the pull requests. | `true` |

## All the pull requests outputs

Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ inputs:
description: 'A list of labels added when the processing stale the issue (multiline).'
required: false
default: ''
issue-processing:
description: 'Allow to process the issues.'
required: false
default: 'true'
# Pull request inputs
pull-request-stale-label:
description: 'The label that will be added to the pull request when it is stale.'
Expand Down Expand Up @@ -117,6 +121,10 @@ inputs:
description: 'A list of labels added when the processing stale the pull request (multiline).'
required: false
default: ''
pull-request-processing:
description: 'Allow to process the pull requests.'
required: false
default: 'true'
runs:
using: 'node12'
main: 'dist/index.js'
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/core/inputs/inputs.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum EInputs {
ISSUE_STALE_LABEL = `issue-stale-label`,
ISSUE_STALE_COMMENT = `issue-stale-comment`,
ISSUE_CLOSE_COMMENT = `issue-close-comment`,
ISSUE_PROCESSING = `issue-processing`,
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 All @@ -27,4 +28,5 @@ export enum EInputs {
PULL_REQUEST_STALE_LABEL = `pull-request-stale-label`,
PULL_REQUEST_STALE_COMMENT = `pull-request-stale-comment`,
PULL_REQUEST_CLOSE_COMMENT = `pull-request-close-comment`,
PULL_REQUEST_PROCESSING = `pull-request-processing`,
}
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 @@ -13,6 +13,7 @@ export interface IIssuesInputs extends IInputs {
readonly issueIgnoreAnyAssignees: string[];
readonly issueIgnoreAnyLabels: string[];
readonly issueIgnoreBeforeCreationDate: IIso8601Date | '';
readonly issueProcessing: boolean;
readonly issueStaleComment: IComment | '';
readonly issueStaleLabel: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface IPullRequestsInputs extends IInputs {
readonly pullRequestIgnoreAnyLabels: string[];
readonly pullRequestIgnoreBeforeCreationDate: IIso8601Date | '';
readonly pullRequestIgnoreDraft: boolean;
readonly pullRequestProcessing: boolean;
readonly pullRequestStaleComment: IComment | '';
readonly pullRequestStaleLabel: string;
}
86 changes: 55 additions & 31 deletions src/core/inputs/issues-inputs.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe(`IssuesInputsService`, (): void => {
issueIgnoreBeforeCreationDate: DateTime.utc(2020).toISO({
includeOffset: false,
}),
issueProcessing: true,
issueStaleComment: `issue-stale-comment`,
issueStaleLabel: `issue-stale-label`,
});
Expand Down Expand Up @@ -154,7 +155,7 @@ describe(`IssuesInputsService`, (): void => {

service.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(3);
expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(1, `issue-ignore-all-assignees`, { required: false });
expect(service.inputs$$?.issueIgnoreAllAssignees).toBeFalse();
});
Expand All @@ -164,7 +165,7 @@ describe(`IssuesInputsService`, (): void => {

service.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(3);
expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(2, `issue-ignore-all-labels`, { required: false });
expect(service.inputs$$?.issueIgnoreAllLabels).toBeFalse();
});
Expand All @@ -174,7 +175,7 @@ describe(`IssuesInputsService`, (): void => {

service.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(3);
expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(3, `issue-ignore-all-project-cards`, { required: false });
expect(service.inputs$$?.issueIgnoreAllProjectCards).toBeFalse();
});
Expand Down Expand Up @@ -215,6 +216,16 @@ describe(`IssuesInputsService`, (): void => {
expect(service.inputs$$?.issueIgnoreBeforeCreationDate).toBe(`dummy-issue-ignore-before-creation-date`);
});

it(`should get the issue-processing input, parse it and set it`, (): void => {
expect.assertions(3);

service.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(4, `issue-processing`, { required: false });
expect(service.inputs$$?.issueProcessing).toBeFalse();
});

it(`should get the issue-stale-comment input, parse it and set it`, (): void => {
expect.assertions(3);

Expand Down Expand Up @@ -251,6 +262,7 @@ describe(`IssuesInputsService`, (): void => {
issueIgnoreAnyAssignees: [`dummy-issue-ignore-any-assignees-1`, `dummy-issue-ignore-any-assignees-2`],
issueIgnoreAnyLabels: [`dummy-issue-ignore-any-labels-1`, `dummy-issue-ignore-any-labels-2`],
issueIgnoreBeforeCreationDate: `dummy-issue-ignore-before-creation-date`,
issueProcessing: false,
issueStaleComment: `dummy-issue-stale-comment`,
issueStaleLabel: `dummy-issue-stale-label`,
} as IIssuesInputs);
Expand Down Expand Up @@ -294,6 +306,7 @@ describe(`IssuesInputsService`, (): void => {
issueIgnoreBeforeCreationDate: DateTime.utc(2020).toISO({
includeOffset: false,
}),
issueProcessing: false,
issueStaleComment: `dummy-issue-stale-comment`,
issueStaleLabel: `dummy-issue-stale-label`,
});
Expand All @@ -304,14 +317,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
1,
`white-├──`,
`input-issue-add-labels-after-stale`,
`value-dummy-extra-stale-label-1,dummy-extra-stale-label-2`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(1, `issue-add-labels-after-stale`);
});

Expand All @@ -320,14 +333,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
2,
`white-├──`,
`input-issue-close-comment`,
`value-dummy-issue-close-comment`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(2, `issue-close-comment`);
});

Expand All @@ -336,14 +349,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
3,
`white-├──`,
`input-issue-days-before-close`,
`value-666`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(3, `issue-days-before-close`);
});

Expand All @@ -352,14 +365,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
4,
`white-├──`,
`input-issue-days-before-stale`,
`value-666`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(4, `issue-days-before-stale`);
});

Expand All @@ -368,14 +381,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
5,
`white-├──`,
`input-issue-ignore-all-assignees`,
`value-false`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(5, `issue-ignore-all-assignees`);
});

Expand All @@ -384,14 +397,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
6,
`white-├──`,
`input-issue-ignore-all-labels`,
`value-false`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(6, `issue-ignore-all-labels`);
});

Expand All @@ -400,14 +413,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
7,
`white-├──`,
`input-issue-ignore-all-project-cards`,
`value-false`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(7, `issue-ignore-all-project-cards`);
});

Expand All @@ -416,14 +429,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
8,
`white-├──`,
`input-issue-ignore-any-assignees`,
`value-dummy-assignee-1,dummy-assignee-2`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(8, `issue-ignore-any-assignees`);
});

Expand All @@ -432,14 +445,14 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
9,
`white-├──`,
`input-issue-ignore-any-labels`,
`value-dummy-label-1,dummy-label-2`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(9, `issue-ignore-any-labels`);
});

Expand All @@ -448,47 +461,58 @@ describe(`IssuesInputsService`, (): void => {

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
10,
`white-├──`,
`input-issue-ignore-before-creation-date`,
`value-2020-01-01T00:00:00.000`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(10, `issue-ignore-before-creation-date`);
});

it(`should log the issue processing input`, (): void => {
expect.assertions(4);

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(11, `white-├──`, `input-issue-processing`, `value-false`);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(11, `issue-processing`);
});

it(`should log the issue stale comment input`, (): void => {
expect.assertions(4);

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
11,
12,
`white-├──`,
`input-issue-stale-comment`,
`value-dummy-issue-stale-comment`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(11, `issue-stale-comment`);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(12, `issue-stale-comment`);
});

it(`should log the issue stale label input`, (): void => {
expect.assertions(4);

service.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(
12,
13,
`white-└──`,
`input-issue-stale-label`,
`value-dummy-issue-stale-label`
);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(12, `issue-stale-label`);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(13, `issue-stale-label`);
});
});

Expand Down
1 change: 1 addition & 0 deletions src/core/inputs/issues-inputs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class IssuesInputsService extends AbstractInputsService<IIssuesInputs> {
issueIgnoreAnyAssignees: core.getMultilineInput(EInputs.ISSUE_IGNORE_ANY_ASSIGNEES, { required: false }),
issueIgnoreAnyLabels: core.getMultilineInput(EInputs.ISSUE_IGNORE_ANY_LABELS, { required: false }),
issueIgnoreBeforeCreationDate: core.getInput(EInputs.ISSUE_IGNORE_BEFORE_CREATION_DATE, { required: false }),
issueProcessing: core.getBooleanInput(EInputs.ISSUE_PROCESSING, { required: false }),
issueStaleComment: core.getInput(EInputs.ISSUE_STALE_COMMENT, { required: false }),
issueStaleLabel: core.getInput(EInputs.ISSUE_STALE_LABEL, { required: false }),
};
Expand Down

0 comments on commit b57eac0

Please sign in to comment.