Skip to content

Commit

Permalink
Merge pull request #119 from Nerixyz/chore/exit-with-comments
Browse files Browse the repository at this point in the history
chore: add `num_comments_as_exitcode` option
  • Loading branch information
ZedThree authored Mar 27, 2024
2 parents fddb616 + ad2c4db commit 9008958
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 9008958

Please sign in to comment.