Skip to content

Commit

Permalink
chore: add num_comments_as_exitcode option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Mar 26, 2024
1 parent fddb616 commit ad2c4db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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())

0 comments on commit ad2c4db

Please sign in to comment.