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

chore: add num_comments_as_exitcode option #119

Merged
merged 1 commit into from Mar 27, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -117,6 +117,7 @@ at once, so `clang-tidy-review` will only attempt to post the first
- `annotations`: Use Annotations instead of comments. A maximum of 10
annotations can be written fully, the rest will be summarised. This is a
limitation of the GitHub API.
- `num_comments_as_exitcode`: Set the exit code to be the amount of comments (enabled by default).

## Outputs

Expand Down
5 changes: 5 additions & 0 deletions post/action.yml
Expand Up @@ -23,6 +23,10 @@ inputs:
description: "Use annotations instead of comments. See README for limitations on annotations"
required: false
default: false
num_comments_as_exitcode:
description: "Set the exit code to be the amount of comments"
required: false
default: 'true'
workflow_id:
description: 'ID of the review workflow'
default: ${{ github.event.workflow_run.id }}
Expand All @@ -39,3 +43,4 @@ runs:
- --lgtm-comment-body='${{ inputs.lgtm_comment_body }}'
- --workflow_id=${{ inputs.workflow_id }}
- --annotations=${{ inputs.annotations }}
- --num-comments-as-exitcode=${{ inputs.num_comments_as_exitcode }}
15 changes: 13 additions & 2 deletions post/clang_tidy_review/clang_tidy_review/post.py
Expand Up @@ -56,6 +56,12 @@ def main() -> int:
type=bool_argument,
default=False,
)
parser.add_argument(
"--num-comments-as-exitcode",
help="Set the exit code to be the amount of comments",
type=bool_argument,
default=True,
)
add_auth_arguments(parser)
parser.add_argument(
"reviews",
Expand Down Expand Up @@ -91,13 +97,18 @@ def main() -> int:
)

if args.annotations:
return post_annotations(pull_request, review)
exit_code = post_annotations(pull_request, review)
else:
lgtm_comment_body = strip_enclosing_quotes(args.lgtm_comment_body)
return post_review(
exit_code = post_review(
pull_request, review, args.max_comments, lgtm_comment_body, args.dry_run
)

if args.num_comments_as_exitcode:
return exit_code
else:
return 0


if __name__ == "__main__":
exit(main())