Skip to content

Commit 9008958

Browse files
authored
Merge pull request #119 from Nerixyz/chore/exit-with-comments
chore: add `num_comments_as_exitcode` option
2 parents fddb616 + ad2c4db commit 9008958

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ at once, so `clang-tidy-review` will only attempt to post the first
117117
- `annotations`: Use Annotations instead of comments. A maximum of 10
118118
annotations can be written fully, the rest will be summarised. This is a
119119
limitation of the GitHub API.
120+
- `num_comments_as_exitcode`: Set the exit code to be the amount of comments (enabled by default).
120121

121122
## Outputs
122123

Diff for: post/action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
description: "Use annotations instead of comments. See README for limitations on annotations"
2424
required: false
2525
default: false
26+
num_comments_as_exitcode:
27+
description: "Set the exit code to be the amount of comments"
28+
required: false
29+
default: 'true'
2630
workflow_id:
2731
description: 'ID of the review workflow'
2832
default: ${{ github.event.workflow_run.id }}
@@ -39,3 +43,4 @@ runs:
3943
- --lgtm-comment-body='${{ inputs.lgtm_comment_body }}'
4044
- --workflow_id=${{ inputs.workflow_id }}
4145
- --annotations=${{ inputs.annotations }}
46+
- --num-comments-as-exitcode=${{ inputs.num_comments_as_exitcode }}

Diff for: post/clang_tidy_review/clang_tidy_review/post.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def main() -> int:
5656
type=bool_argument,
5757
default=False,
5858
)
59+
parser.add_argument(
60+
"--num-comments-as-exitcode",
61+
help="Set the exit code to be the amount of comments",
62+
type=bool_argument,
63+
default=True,
64+
)
5965
add_auth_arguments(parser)
6066
parser.add_argument(
6167
"reviews",
@@ -91,13 +97,18 @@ def main() -> int:
9197
)
9298

9399
if args.annotations:
94-
return post_annotations(pull_request, review)
100+
exit_code = post_annotations(pull_request, review)
95101
else:
96102
lgtm_comment_body = strip_enclosing_quotes(args.lgtm_comment_body)
97-
return post_review(
103+
exit_code = post_review(
98104
pull_request, review, args.max_comments, lgtm_comment_body, args.dry_run
99105
)
100106

107+
if args.num_comments_as_exitcode:
108+
return exit_code
109+
else:
110+
return 0
111+
101112

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

0 commit comments

Comments
 (0)