-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathaction.yml
136 lines (114 loc) · 6.24 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# See https://github.com/sturdy-dev/codeball-action for more information of how to use this action
name: Codeball AI Code Review
description: AI Code Review – Codeball approves Pull Requests that a human would have approved. Wait less for review, save time and money.
author: Sturdy
branding:
icon: check
color: orange
inputs:
approvePullRequests:
description: 'If "true", the action will submit an approving review if the Codeball AI approves the contribution'
default: "true"
required: false
labelPullRequestsWhenApproved:
description: 'If "true", the action will add `codeball:approved` label to the PR if the Codeball AI confidence is above the configured approve threshold'
default: "true"
required: false
labelPullRequestsWhenReviewNeeded:
description: 'If "true", the action will add `codeball:needs-review` label to the PR if the Codeball AI confidence is between the "approve" and "careful" thresholds'
default: "false"
required: false
labelPullRequestsWhenCarefulReviewNeeded:
description: 'If "true", the action will add `codeball:needs-careful-review` label to the PR if the Codeball AI confidence is below the configured careful threshold'
default: "true"
required: false
approveThreshold:
description: 'The threshold to use for "approving" (greater than or equal to). A number between 0 and 1. Must be specified with 3 decimals.'
default: "0.935"
required: false
carefulReviewThreshold:
description: 'The threshold to use for "careful review" actions (less than). A number between 0 and 1. Must be specified with 3 decimals.'
default: "0.300"
required: false
failJobsWhenReviewNeeded:
description: 'If "true", the action will exit with status code 1 if the Codeball AI does not approve the contribution'
default: "false"
required: false
codeSuggestionsFromComments:
description: 'If "true", Codeball will read generate code suggestions from comments made in Pull Requests (beta)'
default: "false"
required: false
GITHUB_TOKEN:
description: 'Default to {{ github.token }}. This is the default GitHub token available to actions and is used to run Codeball and to post the result. The default token permissions (https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#permissions) work fine.'
default: '${{ github.token }}'
required: false
runs:
using: 'composite'
steps:
# Start a new Codeball review job
# This step is asynchronous and will return a job id
- name: Trigger Codeball
id: codeball_baller
uses: sturdy-dev/codeball-action/baller@v2
with:
approveThreshold: ${{ inputs.approveThreshold }}
carefulReviewThreshold: ${{ inputs.carefulReviewThreshold }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# Wait for Codeball to return the status
- name: Get Status
id: codeball_status
uses: sturdy-dev/codeball-action/status@v2
with:
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
# If the Codeball confidence is high, add the "codeball:approved" label
- name: Label Approved
uses: sturdy-dev/codeball-action/labeler@v2
if: ${{ steps.codeball_status.outputs.jobType == 'contribution' && inputs.labelPullRequestsWhenApproved == 'true' && steps.codeball_status.outputs.confidence >= inputs.approveThreshold }}
with:
name: "codeball:approved"
color: "86efac" # green
remove-label-names: "codeball:needs-review,codeball:needs-careful-review"
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# If the Codeball confidence is medium, add the "codeball:needs-review" label
- name: Label Needs Review
uses: sturdy-dev/codeball-action/labeler@v2
if: ${{ steps.codeball_status.outputs.jobType == 'contribution' && inputs.labelPullRequestsWhenReviewNeeded == 'true' && steps.codeball_status.outputs.confidence >= inputs.carefulReviewThreshold && steps.codeball_status.outputs.confidence < inputs.approveThreshold }}
with:
name: "codeball:needs-review"
color: "bfdbfe" # blue
remove-label-names: "codeball:approved,codeball:needs-careful-review"
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# If the Codeball confidence is low, add the "codeball:needs-careful-review" label
- name: Label Needs Careful Review
uses: sturdy-dev/codeball-action/labeler@v2
if: ${{ steps.codeball_status.outputs.jobType == 'contribution' && inputs.labelPullRequestsWhenCarefulReviewNeeded == 'true' && steps.codeball_status.outputs.confidence < inputs.carefulReviewThreshold }}
with:
name: "codeball:needs-careful-review"
color: "fde68a" # amber
remove-label-names: "codeball:approved,codeball:needs-review"
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# If Codeball approved the contribution, approve the PR
- name: Approve PR
uses: sturdy-dev/codeball-action/approver@v2
if: ${{ steps.codeball_status.outputs.jobType == 'contribution' && inputs.approvePullRequests == 'true' }}
with:
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
approve: ${{ steps.codeball_status.outputs.confidence >= inputs.approveThreshold }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# If Codeball have code suggestions, add suggestions as comments
- name: Add Suggestions
uses: sturdy-dev/codeball-action/suggester@v2
if: ${{ steps.codeball_status.outputs.suggested == 'true' && inputs.codeSuggestionsFromComments == 'true' && steps.codeball_status.outputs.jobType == 'comment' }}
with:
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# If Codeball didn't approve the contribution, fail the job.
- name: Fail Job
shell: bash
if: ${{ steps.codeball_status.outputs.approved == 'false' && inputs.failJobsWhenReviewNeeded == 'true' && steps.codeball_status.outputs.jobType == 'contribution' }}
run: |
echo "Not approved"
exit 1