Skip to content

Commit

Permalink
Add annotations via console
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel committed Dec 11, 2024
1 parent 0c1b2a3 commit a1c2e34
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 74 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"project": "./tsconfig.json"
},
"rules": {
"no-console": "off",
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
Expand Down
34 changes: 3 additions & 31 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

47 changes: 5 additions & 42 deletions src/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,12 @@ export class GithubUtil {
if (input.annotations.length === 0) {
return 0
}
// github API lets you post 50 annotations at a time
const chunkSize = 50
const chunks: Annotations[][] = []
for (let i = 0; i < input.annotations.length; i += chunkSize) {
chunks.push(input.annotations.slice(i, i + chunkSize))
for (const ann of input.annotations) {
console.log(
`::warning file=${ann.path},line=${ann.start_line},endLine=${ann.end_line}::${ann.message}`
)
}
let lastResponseStatus = 0
let checkId
for (let i = 0; i < chunks.length; i++) {
let status = 'in_progress'
let conclusion = ''
if (i === chunks.length - 1) {
status = 'completed'
conclusion = 'success'
}
const params = {
...github.context.repo,
name: 'Annotate',
head_sha: input.referenceCommitHash,
status,
...(conclusion && {conclusion}),
output: {
title: 'Coverage Tool',
summary: 'Missing Coverage',
annotations: chunks[i]
}
}
let response
if (i === 0) {
response = await this.client.rest.checks.create({
...params
})
checkId = response.data.id
} else {
response = await this.client.rest.checks.update({
...params,
check_run_id: checkId
})
}
core.info(response.data.output.annotations_url)
lastResponseStatus = response.status
}
return lastResponseStatus
return 0
}

buildAnnotations(
Expand Down

0 comments on commit a1c2e34

Please sign in to comment.