Skip to content

Commit

Permalink
feat(issue): add new input "issue-ignore-all-project-cards"
Browse files Browse the repository at this point in the history
This new input will ignore the processing of the issues which have a related project card (whatever the state is).
  • Loading branch information
C0ZEN committed Dec 11, 2021
1 parent faca997 commit 91193f2
Show file tree
Hide file tree
Showing 19 changed files with 447 additions and 70 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ To help us have a clear vision over the workflow and also for you if you are jus
- 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)
- Check if the issue has an assignee and stop the processing if this is the case (coming from the `issue-ignore-all-assignees` input)
- Check if the issue has any of the ignored assignees and stop the processing if this is the case (coming from the `issue-ignore-any-assignees` input)
- Check if the issue has a project card and stop the processing if this is the case (coming from the `issue-ignore-all-project-cards` input)
- Check if the issue creation date is before x date and stop the processing if this is the case (coming from the `issue-ignore-before-creation-date` input)
- Check if the issue has already a stale state (stale label)
- If the issue has a stale label, check if it was updated after the addition of the stale label
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ All the inputs that are used both for issues and Pull Requests.
| issue-ignore-any-labels | Allow to ignore the processing of issues that contains one of those labels (multiline). | |
| issue-ignore-all-assignees | Allow to ignore the processing of issues that contains any assignees. | `false` |
| issue-ignore-any-assignees | Allow to ignore the processing of issues that contains one of those assignees (multiline). | |
| issue-ignore-all-project-cards | Allow to ignore the processing of issues that contains any project cards. | `false` |
| issue-ignore-before-creation-date | Allow to ignore the processing of issues that were created before this date (ISO 8601, see https://moment.github.io/luxon/#/parsing?id=iso-8601). | |
| issue-days-before-stale | The number of days until the issue is considered as stale. | `30` |
| issue-stale-comment | The comment that will be sent once the issue is stale (keep empty to not send a comment). | |
Expand Down Expand Up @@ -134,6 +135,7 @@ jobs:
This issue is now stale!
issue-close-comment: |
This issue is now closed!
issue-ignore-all-project-cards: false
```
## Debug the action
Expand Down
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/core/inputs/inputs.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum EInputs {
ISSUE_IGNORE_ANY_ASSIGNEES = `issue-ignore-any-assignees`,
ISSUE_IGNORE_ALL_LABELS = `issue-ignore-all-labels`,
ISSUE_IGNORE_ANY_LABELS = `issue-ignore-any-labels`,
ISSUE_IGNORE_ALL_PROJECT_CARDS = `issue-ignore-all-project-cards`,
ISSUE_IGNORE_BEFORE_CREATION_DATE = `issue-ignore-before-creation-date`,
ISSUE_STALE_LABEL = `issue-stale-label`,
ISSUE_STALE_COMMENT = `issue-stale-comment`,
Expand Down
1 change: 1 addition & 0 deletions src/core/inputs/inputs.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface IInputs {
readonly issueDaysBeforeStale: number;
readonly issueIgnoreAllAssignees: boolean;
readonly issueIgnoreAllLabels: boolean;
readonly issueIgnoreAllProjectCards: boolean;
readonly issueIgnoreAnyAssignees: string[];
readonly issueIgnoreAnyLabels: string[];
readonly issueIgnoreBeforeCreationDate: IIso8601Date | '';
Expand Down
103 changes: 66 additions & 37 deletions src/core/inputs/inputs.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe(`inputsService`, (): void => {
issueDaysBeforeStale: 30,
issueIgnoreAllAssignees: true,
issueIgnoreAllLabels: true,
issueIgnoreAllProjectCards: true,
issueIgnoreAnyAssignees: [`assignee-1`, `assignee-2`],
issueIgnoreAnyLabels: [`label-1`, `label-2`],
issueIgnoreBeforeCreationDate: DateTime.utc(2020).toISO({
Expand All @@ -84,7 +85,7 @@ describe(`inputsService`, (): void => {

InputsService.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(3);
expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(1, `dry-run`, { required: false });
expect(InputsService.inputs$$?.dryRun).toBeFalse();
});
Expand Down Expand Up @@ -134,7 +135,7 @@ describe(`inputsService`, (): void => {

InputsService.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(3);
expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(2, `issue-ignore-all-assignees`, { required: false });
expect(InputsService.inputs$$?.issueIgnoreAllAssignees).toBeFalse();
});
Expand All @@ -144,11 +145,21 @@ describe(`inputsService`, (): void => {

InputsService.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(3);
expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(3, `issue-ignore-all-labels`, { required: false });
expect(InputsService.inputs$$?.issueIgnoreAllLabels).toBeFalse();
});

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

InputsService.setInputs();

expect(coreGetBooleanInputSpy).toHaveBeenCalledTimes(4);
expect(coreGetBooleanInputSpy).toHaveBeenNthCalledWith(4, `issue-ignore-all-project-cards`, { required: false });
expect(InputsService.inputs$$?.issueIgnoreAllProjectCards).toBeFalse();
});

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

Expand Down Expand Up @@ -220,6 +231,7 @@ describe(`inputsService`, (): void => {
issueDaysBeforeStale: 666,
issueIgnoreAllAssignees: false,
issueIgnoreAllLabels: false,
issueIgnoreAllProjectCards: false,
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`,
Expand Down Expand Up @@ -276,6 +288,7 @@ describe(`inputsService`, (): void => {
issueDaysBeforeStale: 666,
issueIgnoreAllAssignees: false,
issueIgnoreAllLabels: false,
issueIgnoreAllProjectCards: false,
issueIgnoreAnyAssignees: [`dummy-assignee-1`, `dummy-assignee-2`],
issueIgnoreAnyLabels: [`dummy-label-1`, `dummy-label-2`],
issueIgnoreBeforeCreationDate: DateTime.utc(2020).toISO({
Expand All @@ -291,9 +304,9 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInfoSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInfoSpy).toHaveBeenNthCalledWith(1, `white-├──`, `input-dry-run`, `value-false`);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(12);
expect(loggerServiceInputSpy).toHaveBeenCalledTimes(13);
expect(loggerServiceInputSpy).toHaveBeenNthCalledWith(1, `dry-run`);
});

Expand All @@ -302,14 +315,14 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

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

Expand All @@ -318,14 +331,14 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

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

Expand All @@ -334,14 +347,14 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

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

Expand All @@ -350,14 +363,14 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

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

Expand All @@ -366,14 +379,14 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

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

Expand All @@ -382,95 +395,111 @@ describe(`inputsService`, (): void => {

InputsService.logInputs();

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

it(`should log the issue ignore any assignees input`, (): void => {
it(`should log the issue ignore all project cards input`, (): void => {
expect.assertions(4);

InputsService.logInputs();

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

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

InputsService.logInputs();

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

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

InputsService.logInputs();

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

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

InputsService.logInputs();

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

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

InputsService.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);

InputsService.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/inputs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class InputsService {
issueDaysBeforeStale: this.getNumberInput$$(EInputs.ISSUE_DAYS_BEFORE_STALE, { required: false }),
issueIgnoreAllAssignees: core.getBooleanInput(EInputs.ISSUE_IGNORE_ALL_ASSIGNEES, { required: false }),
issueIgnoreAllLabels: core.getBooleanInput(EInputs.ISSUE_IGNORE_ALL_LABELS, { required: false }),
issueIgnoreAllProjectCards: core.getBooleanInput(EInputs.ISSUE_IGNORE_ALL_PROJECT_CARDS, { required: false }),
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 }),
Expand Down
Loading

0 comments on commit 91193f2

Please sign in to comment.