Skip to content

Commit bd40e77

Browse files
committed
Merge branch 'main' into v2
2 parents d7adcb2 + b4defaf commit bd40e77

File tree

10 files changed

+397
-32
lines changed

10 files changed

+397
-32
lines changed

README.md

Lines changed: 162 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,172 @@ on: [pull_request]
2020
jobs:
2121
codeball_job:
2222
runs-on: ubuntu-latest
23-
name: Run Codeball
23+
name: Codeball
2424
steps:
25-
- name: Codeball AI Actions
26-
uses: sturdy-dev/codeball-action@v1
27-
# with:
28-
# do-label: "true" # Configure if the action should label approved contributions
29-
# label-name: "codeball:approved" # Configure the label name to set if Codeball approves the contribution
30-
# do-approve: "true" # Configure if the action should approve PRs that have been approved by Codeball
25+
- name: Codeball
26+
uses: sturdy-dev/codeball-action@v2
3127
```
3228
3329
2. 🎉 That's it! Codeball will now run on your pull requests, and will pre-approve your PR if it's a good one!
3430
31+
## Customizations
32+
33+
Codeball Actions are built on multiple smaller building-blocks, that are heavily configurable through GitHub Actions.
34+
35+
### Example: "Dry-run" mode, labels all PRs with the Codeball Result
36+
37+
<details>
38+
<summary>codeball-dry-run.yml</summary>
39+
40+
```yaml
41+
on: [pull_request]
42+
43+
permissions:
44+
contents: read
45+
issues: write
46+
pull-requests: write
47+
48+
jobs:
49+
codeball:
50+
runs-on: ubuntu-latest
51+
name: Codeball
52+
steps:
53+
54+
# Start a new Codeball review job
55+
# This step is asynchronous and will return a job id
56+
- name: Trigger Codeball
57+
id: codeball_baller
58+
uses: sturdy-dev/codeball-action/baller@v2
59+
60+
61+
# Wait for Codeball to return the status
62+
- name: Get Status
63+
id: codeball_status
64+
uses: sturdy-dev/codeball-action/status@v2
65+
with:
66+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
67+
68+
# If Codeball approved the contribution, add a "codeball:approved" label
69+
- name: Label Approved
70+
uses: sturdy-dev/codeball-action/labeler@v2
71+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
72+
with:
73+
name: "codeball:approved"
74+
color: "86efac" # green
75+
76+
# If Codeball did not approve the contribution, add a "codeball:needs-review" label
77+
- name: Label Needs Review
78+
uses: sturdy-dev/codeball-action/labeler@v2
79+
if: ${{ steps.codeball_status.outputs.approved == 'false' }}
80+
with:
81+
name: "codeball:needs-review"
82+
color: "bfdbfe" # blue
83+
84+
```
85+
</details>
86+
87+
### Example: Approve only (no labels)
88+
89+
<details>
90+
<summary>codeball-approve.yml</summary>
91+
92+
```yaml
93+
on: [pull_request]
94+
95+
permissions:
96+
contents: read
97+
issues: write
98+
pull-requests: write
99+
100+
jobs:
101+
codeball:
102+
runs-on: ubuntu-latest
103+
name: Codeball
104+
steps:
105+
106+
# Start a new Codeball review job
107+
# This step is asynchronous and will return a job id
108+
- name: Trigger Codeball
109+
id: codeball_baller
110+
uses: sturdy-dev/codeball-action/baller@v2
111+
112+
113+
# Wait for Codeball to return the status
114+
- name: Get Status
115+
id: codeball_status
116+
uses: sturdy-dev/codeball-action/status@v2
117+
with:
118+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
119+
120+
# If Codeball approved the contribution, approve the PR
121+
- name: Approve PR
122+
uses: sturdy-dev/codeball-action/approver@v2
123+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
124+
with:
125+
message: "Codeball: LGTM! :+1:"
126+
```
127+
</details>
128+
129+
130+
### Example: Filter files (run only for PRs modifying a single service)
131+
132+
<details>
133+
<summary>codeball-filter-files.yml</summary>
134+
135+
```yaml
136+
on:
137+
pull_request:
138+
# Run Codeball only if files under "/web/" has been modified (and no other files)
139+
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-paths
140+
paths:
141+
- '!**'
142+
- '/web/**'
143+
144+
permissions:
145+
contents: read
146+
issues: write
147+
pull-requests: write
148+
149+
jobs:
150+
codeball:
151+
runs-on: ubuntu-latest
152+
name: Codeball
153+
154+
steps:
155+
156+
# Start a new Codeball review job
157+
# This step is asynchronous and will return a job id
158+
- name: Trigger Codeball
159+
id: codeball_baller
160+
uses: sturdy-dev/codeball-action/baller@v2
161+
162+
163+
# Wait for Codeball to return the status
164+
- name: Get Status
165+
id: codeball_status
166+
uses: sturdy-dev/codeball-action/status@v2
167+
with:
168+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
169+
170+
# If Codeball approved the contribution, approve the PR
171+
- name: Approve PR
172+
uses: sturdy-dev/codeball-action/approver@v2
173+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
174+
with:
175+
message: "Codeball: LGTM! :+1:"
176+
```
177+
</details>
178+
179+
180+
## Building Blocks
181+
182+
The Codeball sub-actions are:
183+
184+
* [`sturdy-dev/codeball-action/baller/@v2`](./baller/README.md) – Triggers new Codeball Jobs
185+
* [`sturdy-dev/codeball-action/status/@v2`](./status/README.md) – Waits for the the Codeball result
186+
* [`sturdy-dev/codeball-action/approver/@v2`](./approver/README.md) – Approves PRs
187+
* [`sturdy-dev/codeball-action/labeler/@v2`](./labeler/README.md) – Adds labels to PRs
188+
35189
## Troubleshooting
36190

37191
### Permissions
@@ -51,4 +205,4 @@ permissions:
51205

52206
By default, only pull requests from a fork does not have "write" permissions when running in GitHub Actions, and those Pull Requests can not be approved.
53207

54-
If you're using forks from a private repository, and want to use Codeball on Pull Requests created from a fork. Enable "Send write tokens to workflows from fork pull requests" on the repository ([docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-private-repository-forks)).
208+
If you're using forks from a private repository, and want to use Codeball on Pull Requests created from a fork. Enable "Send write tokens to workflows from fork pull requests" on the repository ([docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-private-repository-forks)).

action.yml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
11
# See https://github.com/sturdy-dev/codeball-action for more information of how to use this action
22
name: Codeball AI Actions
3-
description: AI Code Review
3+
description: AI Code Review – Codeball approves Pull Requests that a human would have approved. Wait less for review, save time and $$$.
44

55
author: Sturdy
66
branding:
77
icon: check
88
color: orange
99

10-
inputs:
11-
do-label:
12-
description: 'If "true", the action will label Pull Request if Codeball AI approves the contribution'
13-
default: "true"
14-
required: false
15-
label-name:
16-
description: 'Label value to be set.'
17-
default: 'codeball:approved'
18-
required: false
19-
do-approve:
20-
description: 'If "true", the action will submit an approving Pull Request review if Codeball AI approves the contribution'
21-
default: "true"
22-
required: false
23-
2410
runs:
2511
using: 'composite'
2612
steps:
13+
2714
# Start a new Codeball review job
2815
# This step is asynchronous and will return a job id
2916
- name: Trigger Codeball
3017
id: codeball_baller
31-
uses: sturdy-dev/codeball-action/baller@v1
18+
uses: sturdy-dev/codeball-action/baller@v2
3219

33-
# Wait for the codeball_baller job to complete
34-
# Approves the Pull Request if Codeball approves it
35-
- name: Codeball Approver
36-
id: codeball_approver
37-
uses: sturdy-dev/codeball-action/approver@v1
20+
# Wait for Codeball to return the status
21+
- name: Get Status
22+
id: codeball_status
23+
uses: sturdy-dev/codeball-action/status@v2
3824
with:
3925
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
40-
do-label: ${{ inputs.do-label }}
41-
label-name: ${{ inputs.label-name }}
42-
do-approve: ${{ inputs.do-approve }}
26+
27+
# If Codeball approved the contribution, add a "codeball:approved" label
28+
- name: Label Approved
29+
uses: sturdy-dev/codeball-action/labeler@v2
30+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
31+
with:
32+
name: "codeball:approved"
33+
color: "86efac" # green
34+
35+
# If Codeball approved the contribution, approve the PR
36+
- name: Approve PR
37+
uses: sturdy-dev/codeball-action/approver@v2
38+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}

approver/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Codeball Approver
2+
3+
This action approves a Pull Request with a message.
4+
5+
# Inputs
6+
7+
## `GITHUB_TOKEN` (optional)
8+
9+
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.
10+
11+
Default: `'${{ github.token }}'`
12+
13+
## `message` (optional)
14+
15+
The message to send in the code review comment.
16+
17+
Default: `"Codeball: LGTM! :+1:"`
18+
19+
# Outputs
20+
21+
_This action has no outputs_

baller/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Codeball Baller
2+
3+
This action starts a new asynchronous Codeball Job.
4+
5+
# Inputs
6+
7+
## `GITHUB_TOKEN` (optional)
8+
9+
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.
10+
11+
Default: `'${{ github.token }}'`
12+
13+
# Outputs
14+
15+
## `codeball-job-id`
16+
17+
ID of the Codeball Job

examples/codeball-approve.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on: [pull_request]
2+
3+
permissions:
4+
contents: read
5+
issues: write
6+
pull-requests: write
7+
8+
jobs:
9+
codeball:
10+
runs-on: ubuntu-latest
11+
name: Codeball
12+
steps:
13+
14+
# Start a new Codeball review job
15+
# This step is asynchronous and will return a job id
16+
- name: Trigger Codeball
17+
id: codeball_baller
18+
uses: sturdy-dev/codeball-action/baller@v2
19+
20+
21+
# Wait for Codeball to return the status
22+
- name: Get Status
23+
id: codeball_status
24+
uses: sturdy-dev/codeball-action/status@v2
25+
with:
26+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
27+
28+
# If Codeball approved the contribution, approve the PR
29+
- name: Approve PR
30+
uses: sturdy-dev/codeball-action/approver@v2
31+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
32+
with:
33+
message: "Codeball: LGTM! :+1:"

examples/codeball-dry-run.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on: [pull_request]
2+
3+
permissions:
4+
contents: read
5+
issues: write
6+
pull-requests: write
7+
8+
jobs:
9+
codeball:
10+
runs-on: ubuntu-latest
11+
name: Codeball
12+
steps:
13+
14+
# Start a new Codeball review job
15+
# This step is asynchronous and will return a job id
16+
- name: Trigger Codeball
17+
id: codeball_baller
18+
uses: sturdy-dev/codeball-action/baller@v2
19+
20+
21+
# Wait for Codeball to return the status
22+
- name: Get Status
23+
id: codeball_status
24+
uses: sturdy-dev/codeball-action/status@v2
25+
with:
26+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
27+
28+
# If Codeball approved the contribution, add a "codeball:approved" label
29+
- name: Label Approved
30+
uses: sturdy-dev/codeball-action/labeler@v2
31+
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
32+
with:
33+
name: "codeball:approved"
34+
color: "86efac" # green
35+
36+
# If Codeball did not approve the contribution, add a "codeball:needs-review" label
37+
- name: Label Needs Review
38+
uses: sturdy-dev/codeball-action/labeler@v2
39+
if: ${{ steps.codeball_status.outputs.approved == 'false' }}
40+
with:
41+
name: "codeball:needs-review"
42+
color: "bfdbfe" # blue

0 commit comments

Comments
 (0)