Skip to content

Commit 9e751d7

Browse files
committed
status: expose confidence
1 parent b328ec8 commit 9e751d7

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

Diff for: src/lib/jobs/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ export type Contribution = {
5454
created_at: string
5555
merged_at: any
5656
result: 'inconclusive' | 'approved' | 'not_approved' | null
57+
predicted_outcome?: PredictedOutcome
5758
}
5859

5960
export type Comment = {
6061
url: string
6162
suggestions: Suggestion[]
6263
}
64+
65+
export type PredictedOutcome = {
66+
file_probabilities?: number[]
67+
}

Diff for: src/status/main.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,23 @@ const getJobType = (job: Job): string => {
2929
return 'unknown'
3030
}
3131

32+
const getConfidence = (job: Job): number => {
33+
if (isContributionJob(job)) {
34+
const probabilities =
35+
job.contribution?.predicted_outcome?.file_probabilities || []
36+
return Math.min(...probabilities)
37+
}
38+
return 0
39+
}
40+
3241
const run = async (
3342
jobID: string
34-
): Promise<{isApproved: boolean; isSuggested: boolean; jobType: string}> => {
43+
): Promise<{
44+
isApproved: boolean
45+
isSuggested: boolean
46+
jobType: string
47+
confidence: number
48+
}> => {
3549
core.info(`Job ID: ${jobID}`)
3650

3751
let job = await get(jobID)
@@ -49,18 +63,20 @@ const run = async (
4963
return {
5064
isApproved: isApproved(job),
5165
isSuggested: isSuggested(job),
52-
jobType: getJobType(job)
66+
jobType: getJobType(job),
67+
confidence: getConfidence(job)
5368
}
5469
}
5570

5671
const jobID = required('codeball-job-id')
5772

5873
run(jobID)
59-
.then(async ({isApproved, isSuggested, jobType}) => {
74+
.then(async ({isApproved, isSuggested, jobType, confidence}) => {
6075
await track({jobID, actionName: 'status'})
6176
core.setOutput('approved', isApproved)
6277
core.setOutput('suggested', isSuggested)
6378
core.setOutput('jobType', jobType)
79+
core.setOutput('confidence', confidence)
6480
})
6581
.catch(async error => {
6682
if (error instanceof Error) {

Diff for: status/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ The ID of the Codeball Job created by the Baller Action
1010

1111
# Outputs
1212

13+
## `jobType`
14+
15+
`"contribution"` or `"comment`
16+
1317
## `approved`
1418

1519
If the Codeball approved the contribution (true or false)
1620

1721
## `suggested`
1822

1923
If the Codeball has suggestions for the contribution (true or false)
24+
25+
## `confidence`
26+
27+
The Codeball confidence that this contribution can be approved as-is. A number between 0 and 1. A value between 0 and 0.3 normally indicates that the contribution should be thoroughly reviewed. A value above 0.93 indicates that the contribution is very likely to be approved as-is.
28+
29+
Confidence is only set for contribution jobs.

Diff for: status/action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ outputs:
1717
description: 'If the Codeball approved the contribution (true or false)'
1818
suggested:
1919
description: 'If the Codeball has suggestions for the contribution (true or false)'
20+
confidence:
21+
description: 'The Codeball confidence that this contribution can be approved as-is. A number between 0 and 1. A value between 0 and 0.3 normally indicates that the contribution should be thoroughly reviewed. A value above 0.93 indicates that the contribution is very likely to be approved as-is. Confidence is only set for contribution jobs.'
2022

2123
runs:
2224
using: 'node16'

0 commit comments

Comments
 (0)