Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for skipping checklists in comments #45

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ inputs:
description: Require a checklist to exist
required: false
default: "false"
skipComments:
description: Do not look for checklists in comments
required: false
default: "false"
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ async function action() {
bodyList.push(issue.body);
}

const { data: comments } = await octokit.rest.issues.listComments({
...github.context.repo,
issue_number: issueNumber,
});

for (let comment of comments) {
bodyList.push(comment.body);
if (core.getInput("skipComments") != "true") {
const { data: comments } = await octokit.rest.issues.listComments({
...github.context.repo,
issue_number: issueNumber,
});

for (let comment of comments) {
bodyList.push(comment.body);
}
}

// Check each comment for a checklist
Expand Down
15 changes: 15 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ describe("Require Checklist", () => {
expect(core.setFailed).toBeCalledWith(
"The following items are not marked as completed: Two, Three"
);

delete process.env.INPUT_ISSUENUMBER;
});

it("ignores checklists in comments when skipComments is enabled", async () => {
process.env.INPUT_REQUIRECHECKLIST = "false";
process.env.INPUT_SKIPCOMMENTS = "true";
mockIssueBody("Nothing in the body");

console.log = jest.fn();
await action(tools);

expect(console.log).toBeCalledWith(
"There are no incomplete task list items"
);
});
});

Expand Down
Loading