-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate coverage reports using only GitHub Actions, without codecov.…
…io (#447) * Initial coverage report. * Enable for windows. * Try to support windows paths for coverage. * Try the branch. * Update all-success to newer version that as no set-output warnings. * Add a comment. * Pass comment via a file to handle newlines. * Use nodejs like a pro. * Apply suggestions from code review Co-authored-by: Kyle Altendorf <sda@fstab.net> * Include diff. Wrap in markdown. * Enable test report. * Fix after re-review. * Remove run_id from coverage artifact. * Add a name for the comment script. * Remove comment about single artifact as this is what we have by default for a workflow. * Add restricted permissions for token. * Use markdown report for diff-cover. Co-authored-by: Kyle Altendorf <sda@fstab.net>
- Loading branch information
Showing
7 changed files
with
172 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Have a single comment on a PR, identified by a comment marker. | ||
Create a new comment if no comment already exists. | ||
Update the content of the existing comment. | ||
https://octokit.github.io/rest.js/v19 | ||
*/ | ||
module.exports = async ({github, context, process}) => { | ||
var octokit_rest = github | ||
if (context.eventName != "pull_request") { | ||
// Only PR are supported. | ||
return | ||
} | ||
|
||
var sleep = function(second) { | ||
return new Promise(resolve => setTimeout(resolve, second * 1000)) | ||
} | ||
|
||
/* | ||
Perform the actual logic. | ||
This is wrapped so that we can retry on errors. | ||
*/ | ||
var doAction = async function() { | ||
|
||
console.log(context) | ||
|
||
fs = require('fs'); | ||
|
||
const body = fs.readFileSync( | ||
process.env.GITHUB_WORKSPACE + "/" + process.env.COMMENT_BODY, 'utf8'); | ||
var comment_id = null | ||
var comment_marker = '\n' + process.env.COMMENT_MARKER | ||
var comment_body = body + comment_marker | ||
|
||
var comments = await octokit_rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.number, | ||
}) | ||
|
||
console.log(comments) | ||
|
||
comments.data.forEach(comment => { | ||
if (comment.body.endsWith(comment_marker)) { | ||
comment_id = comment.id | ||
} | ||
}) | ||
|
||
if (comment_id) { | ||
// We have an existing comment. | ||
// update the content. | ||
await octokit_rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: comment_id, | ||
body: comment_body, | ||
}) | ||
return | ||
} | ||
|
||
// Create a new comment. | ||
await octokit_rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.number, | ||
body: comment_body, | ||
}) | ||
|
||
} | ||
|
||
try { | ||
await doAction() | ||
} catch (e) { | ||
await sleep(5) | ||
await doAction() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ dist/ | |
venv/ | ||
htmlcov/ | ||
.coverage | ||
coverage.xml | ||
*~ | ||
*.lock | ||
apidocs/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.