Skip to content

Commit

Permalink
Allow post the report to job summary
Browse files Browse the repository at this point in the history
  • Loading branch information
06393993 committed Jul 29, 2023
1 parent a6a5a37 commit 45b31bf
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ inputs:
description: Set working directory if project is not in root folder
required: false
default: "./"
post-to:
description: Post the coverage report to either "comment" or "job-summary"
required: false
default: "comment"
title:
description: Title to add to the comment
required: false
Expand Down
38 changes: 24 additions & 14 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25484,6 +25484,7 @@ async function main$1() {
core$1.getInput("filter-changed-files").toLowerCase() === "true";
const shouldDeleteOldComments =
core$1.getInput("delete-old-comments").toLowerCase() === "true";
const postTo = core$1.getInput("post-to").toLowerCase();
const title = core$1.getInput("title");

const raw = await fs.promises.readFile(lcovFile, "utf-8").catch(err => null);
Expand Down Expand Up @@ -25530,20 +25531,29 @@ async function main$1() {
await deleteOldComments(githubClient, options, github_1);
}

if (github_1.eventName === "pull_request") {
await githubClient.issues.createComment({
repo: github_1.repo.repo,
owner: github_1.repo.owner,
issue_number: github_1.payload.pull_request.number,
body: body,
});
} else if (github_1.eventName === "push") {
await githubClient.repos.createCommitComment({
repo: github_1.repo.repo,
owner: github_1.repo.owner,
commit_sha: options.commit,
body: body,
});
switch (postTo) {
case "comment":
if (github_1.eventName === "pull_request") {
await githubClient.issues.createComment({
repo: github_1.repo.repo,
owner: github_1.repo.owner,
issue_number: github_1.payload.pull_request.number,
body: body,
});
} else if (github_1.eventName === "push") {
await githubClient.repos.createCommitComment({
repo: github_1.repo.repo,
owner: github_1.repo.owner,
commit_sha: options.commit,
body: body,
});
}
break
case "job-summary":
await core$1.summary.addRaw(body).write();
break
default:
core$1.warning(`Unknown post-to value: '${postTo}'`);
}
}

Expand Down
38 changes: 24 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function main() {
core.getInput("filter-changed-files").toLowerCase() === "true"
const shouldDeleteOldComments =
core.getInput("delete-old-comments").toLowerCase() === "true"
const postTo = core.getInput("post-to").toLowerCase()
const title = core.getInput("title")

const raw = await fs.readFile(lcovFile, "utf-8").catch(err => null)
Expand Down Expand Up @@ -67,20 +68,29 @@ async function main() {
await deleteOldComments(githubClient, options, context)
}

if (context.eventName === "pull_request") {
await githubClient.issues.createComment({
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.payload.pull_request.number,
body: body,
})
} else if (context.eventName === "push") {
await githubClient.repos.createCommitComment({
repo: context.repo.repo,
owner: context.repo.owner,
commit_sha: options.commit,
body: body,
})
switch (postTo) {
case "comment":
if (context.eventName === "pull_request") {
await githubClient.issues.createComment({
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.payload.pull_request.number,
body: body,
})
} else if (context.eventName === "push") {
await githubClient.repos.createCommitComment({
repo: context.repo.repo,
owner: context.repo.owner,
commit_sha: options.commit,
body: body,
})
}
break
case "job-summary":
await core.summary.addRaw(body).write()
break
default:
core.warning(`Unknown post-to value: '${postTo}'`)
}
}

Expand Down

0 comments on commit 45b31bf

Please sign in to comment.