Skip to content

Commit

Permalink
DEBUG: Add console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjfno1 committed Oct 5, 2021
1 parent 263805a commit ff81408
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ async function main() {
const baseFile = core.getInput("lcov-base")
const updateComment = core.getBooleanInput("update-comment")

console.log("=============================")
console.log("UPDATE COMMENT", updateComment)
console.log("=============================")

const raw = await fs.readFile(lcovFile, "utf-8").catch(err => null)
if (!raw) {
console.log(`No coverage report found at '${lcovFile}', exiting...`)
Expand Down Expand Up @@ -45,23 +49,37 @@ async function main() {
const body = await diff(lcov, baselcov, options)
const githubClient = new GitHub(token)

const createGitHubComment = () =>
githubClient.issues.createComment({
const createGitHubComment = () => {
console.log("=============================")
console.log("CREATE GITHUB COMMENT")
console.log("=============================")

return githubClient.issues.createComment({
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.payload.pull_request.number,
body,
})
}

const updateGitHubComment = commentId => {
console.log("=============================")
console.log("UPDATE GITHUB COMMENT")
console.log("=============================")

const updateGitHubComment = commentId =>
githubClient.issues.updateComment({
return githubClient.issues.updateComment({
repo: context.repo.repo,
owner: context.repo.owner,
comment_id: commentId,
body,
})
}

if (updateComment) {
console.log("=============================")
console.log("UPDATE COMMENT TRUE")
console.log("=============================")

const issueComments = await githubClient.issues.listComments({
repo: context.repo.repo,
owner: context.repo.owner,
Expand All @@ -73,11 +91,19 @@ async function main() {
)

if (existingComment) {
console.log("=============================")
console.log("HAS EXISTING COMMENT")
console.log("=============================")

await updateGitHubComment(existingComment.id)
return
}
}

console.log("=============================")
console.log("CREATING COMMENT")
console.log("=============================")

await createGitHubComment()
}

Expand Down

0 comments on commit ff81408

Please sign in to comment.